Commit Graph

483 Commits

Author SHA1 Message Date
Juan José Mata
ef4f5f7b8b feat: CORS support (#813)
* feat: Add CORS support for Flutter mobile client

Add rack-cors gem and configure CORS for API and OAuth endpoints
to enable cross-origin requests from mobile clients and other
external applications.

https://claude.ai/code/session_01RJ6MKLkjBv7x5AQLEUn8AF

* feat: Add /sessions/* to CORS for webview authentication

Enable CORS for session endpoints to support webview-based
authentication flows in the Flutter mobile client.

https://claude.ai/code/session_01RJ6MKLkjBv7x5AQLEUn8AF

* test: Add integration tests for CORS configuration

Test that CORS middleware is configured and returns proper headers
for API, OAuth, and session endpoints including preflight requests.

https://claude.ai/code/session_01RJ6MKLkjBv7x5AQLEUn8AF

* Gemfile.lock

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-28 17:25:02 +01:00
MkDev11
eeff4edbea Add warning for TwelveData plan-restricted tickers (#803)
* Add warning for TwelveData plan-restricted tickers

Fixes #800

- Add Security::PlanRestrictionTracker concern using Rails cache
- Detect plan upgrade errors during Security::Price::Importer sync
- Display amber warning on /settings/hosting with affected tickers
- Include unit tests for the new functionality

* Scope plan restriction cache by provider

Addresses review feedback:
- Cache key now includes provider name to support multiple data providers
- Methods now require provider parameter for proper scoping
- Added tests for provider-scoped restrictions
- Added documentation explaining instance-level API key architecture

* Fix RuboCop array bracket spacing

* Fix empty array bracket spacing

* Move plan upgrade detection to Provider::TwelveData

* Fix provider scoping tests to use direct cache writes

---------

Co-authored-by: mkdev11 <jaysmth689+github@users.noreply.github.com>
2026-01-27 15:45:50 +01:00
charsel
33df3b781e fix: Handle uncategorized transactions filter correctly (#802)
* fix: Handle uncategorized transactions filter correctly

When filtering for 'Uncategorized' transactions, the filter was not working
because 'Uncategorized' is a virtual category (Category.uncategorized returns
a non-persisted Category object) and does not exist in the database.

The filter was attempting to match 'categories.name IN (Uncategorized)' which
returned zero results.

This fix removes 'Uncategorized' from the category names array before querying
the database, allowing the existing 'category_id IS NULL' condition to work
correctly.

Fixes filtering for uncategorized transactions while maintaining backward
compatibility with all other category filters.

* test: Add comprehensive tests for Uncategorized filter

- Test filtering for only uncategorized transactions
- Test combining uncategorized with real categories
- Test excluding uncategorized when not in filter
- Ensures fix prevents regression

* refactor: Use Category.uncategorized.name for i18n support

- Replace hard-coded 'Uncategorized' string with Category.uncategorized.name
- Conditionally build SQL query based on include_uncategorized flag
- Avoid adding category_id IS NULL clause when not needed
- Update tests to use Category.uncategorized.name for consistency
- Cleaner logic: only include uncategorized condition when requested

Addresses code review feedback on i18n support and query optimization.

* test: Fix travel category fixture error

Create travel category dynamically instead of using non-existent fixture

* style: Fix rubocop spacing in array brackets

---------

Co-authored-by: Charsel <charsel@charsel.com>
2026-01-27 12:28:33 +01:00
Dream
51579d3731 FR: Add transaction type as rule condition option (#790)
* Add transaction type condition filter for rules

Add ability to filter rules by transaction type (income, expense, transfer).
This allows users to create rules that differentiate between transactions
with the same name but different types.

- Add Rule::ConditionFilter::TransactionType with select dropdown
- Register in TransactionResource condition_filters
- Add tests for income, expense, and transfer filtering

Closes #373

* Address PR review feedback for transaction type filter

- Fix income filter to exclude transfers and investment_contribution
- Fix expense filter to include investment_contribution regardless of sign
- Add i18n for option and operator labels
- Add tests for edge cases (transfer inflows, investment contributions)

Logic now matches Transaction::Search#apply_type_filter for consistency.
2026-01-26 16:53:05 +01:00
Juan José Mata
c7ab25b866 Use browser Accept-Language for login and onboarding locale (#768)
* Use Accept-Language for unauthenticated locale

* Add per-user locale overrides

* Fix test

* Use more than the top `accept-language` entry

* Localization of string
2026-01-24 22:00:41 +01:00
LPW
6197419f6c Add protection indicator to entries and unlock functionality (#765)
* feat: add protection indicator to entries and unlock functionality

- Introduced protection indicator component rendering on hover and in detail views.
- Added support to unlock entries, clearing protection flags (`user_modified`, `import_locked`, and locked attributes).
- Updated routes, controllers, and models to enable unlock functionality for trades and transactions.
- Refactored views and localized content to support the new feature.
- Added relevant tests for unlocking functionality and attribute handling.

* feat: improve sync protection and turbo stream updates for entries

- Added tests for turbo stream updates reflecting protection indicators.
- Ensured user-modified entries lock specific attributes to prevent overwrites.
- Updated controllers to mark entries as user-modified and reload for accurate rendering.
- Enhanced protection indicator rendering using turbo frames.
- Applied consistent lock state handling across trades and transactions.

* Address PR review comments for protection indicator

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-24 16:03:23 +01:00
LPW
d98711d4ea Rename raw_investments_payload to raw_holdings_payload for Plaid accounts (#760)
* refactor: rename `raw_investments_payload` to `raw_holdings_payload`

- Update references and models to use consistent naming.
- Adjust migrations, tests, and encryption setup accordingly.

* fix: improve safety when accessing raw_holdings_payload keys

- Use `dig` with safe navigation to prevent potential nil errors.
- Add support for decryption from the old column name `raw_investments_payload`.
- Adjust related methods and calculations for consistency.

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-24 11:16:26 +01:00
Mark Hendriksen
9b84c5bdbc Enhanced Import Amount Type Selection (#506)
* Enhanced Import Amount Type Selection

updated version of https://github.com/we-promise/sure/pull/179

* copilot sugestions

* ai sugestions

* Update import.rb

* Update schema.rb

* Update schema.rb

* Update schema.rb

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-23 22:12:02 +01:00
soky srm
696ff0966b Initial security fixes (#461)
* Initial sec

* Update PII fields

* FIX add tests

* FIX safely read plaintext data on rake backfill

* Update user.rb

* FIX tests

* encryption_ready? block

* Test conditional to encryption on

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-23 22:05:28 +01:00
Juan José Mata
6b5a5b1877 fix: Show cancellation message when subscription is pending cancellation (#752)
* fix: Show cancellation message when subscription is pending cancellation

When a subscription is cancelled via Stripe, the UI incorrectly showed
"Your contribution continues on..." instead of reflecting the cancellation
status. This fix adds tracking of `cancel_at_period_end` from Stripe webhooks
and displays "Your contribution ends on..." when a subscription has been
cancelled but is still active until the billing period ends.

https://claude.ai/code/session_01Y8ELTdK1k9o315iSq43TRN

* chore: Update schema.rb with cancel_at_period_end column

https://claude.ai/code/session_01Y8ELTdK1k9o315iSq43TRN

* Schema version

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-23 18:55:51 +01:00
LPW
c504ba9b99 Add security remapping for holdings with sync protection (#692)
* Add security remapping support to holdings

- Introduced `provider_security` tracking for holdings with schema updates.
- Implemented security remap/reset workflows in `Holding` model and UI.
- Updated routes, controllers, and tests to support new functionality.
- Enhanced client-side interaction with Stimulus controller for remapping.

# Conflicts:
#	app/components/UI/account/activity_feed.html.erb
#	db/schema.rb

* Refactor "New transaction" to "New activity" across UI and tests

- Updated localized strings, button labels, and ARIA attributes.
- Improved error handling in holdings' current price display.
- Scoped fallback queries in `provider_import_adapter` to prevent overwrites.
- Added safeguard for offline securities in price fetching logic.

* Update security remapping to merge holdings on collision by deleting duplicates

- Removed error handling for collisions in `remap_security!`.
- Added logic to merge holdings by deleting duplicates on conflicting dates.
- Modified associated test to validate merging behavior.

* Update security remapping to merge holdings on collision by combining qty and amount

- Modified `remap_security!` to merge holdings by summing `qty` and `amount` on conflicting dates.
- Adjusted logic to calculate `price` for merged holdings.
- Updated test to validate new merge behavior.

* Improve DOM handling in Turbo redirect action & enhance holdings merge logic

- Updated Turbo's custom `redirect` action to use the "replace" option for cleaner DOM updates without clearing the cache.
- Enhanced holdings merge logic to calculate weighted average cost basis during security remapping, ensuring more accurate cost_basis updates.

* Track provider_security_id during security updates to support reset workflows

* Fix provider tracking: guard nil ticker lookups and preserve merge attrs

- Guard fallback 1b lookup when security.ticker is blank to avoid matching NULL tickers
- Preserve external_id, provider_security_id, account_provider_id during collision merge

* Fix schema.rb version after merge (includes tax_treatment migration)

* fix: Rename migration to run after schema version

The migration 20260117000001 was skipped in CI because it had a timestamp
earlier than the schema version (2026_01_17_200000). CI loads schema.rb
directly and only runs migrations with versions after the schema version.

Renamed to 20260119000001 so it runs correctly.

* Update schema: remove Coinbase tables, add new fields and indexes

* Update schema: add back `tax_treatment` field with default value "taxable"

* Improve Turbo redirect action: use "replace" to avoid form submission in history

* Lock merged holdings to prevent provider overwrites and fix activity feed template indentation

* Refactor holdings transfer logic: enforce currency checks during collisions and enhance merge handling

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-23 12:54:55 +01:00
Juan José Mata
e0fb585bda Hide contribution payments from demo user(s) (#738)
* Hide payment contribution options from demo and manually created users

Demo data users and manually created users don't have stripe_customer_id
set on their family, so they should not see payment/contribution options.

Changes:
- Add can_manage_subscription? method to Family::Subscribeable that checks
  for presence of stripe_customer_id
- Guard Settings::PaymentsController to return 403 for users without
  stripe_customer_id
- Guard SubscriptionsController#show action (Stripe portal redirect) for
  users without stripe_customer_id
- Update settings navigation to hide the payment link when
  stripe_customer_id is not present
- Add tests for the new behavior

* Fix broken test

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-23 12:35:49 +01:00
Jose
69d9f51d57 # test(api): Add request specs for merchants and tags endpoints (#645)
* Add files via upload

Signed-off-by: Jose <39016041+jospaquim@users.noreply.github.com>

* Add merchants and tags resources to routes

Signed-off-by: Jose <39016041+jospaquim@users.noreply.github.com>

* update

* update spaces

* fix: Apply CodeRabbit suggestions and add YARD documentation

* docs: Add API documentation for merchants and tags endpoints

* fix: Address CodeRabbit feedback on documentation

* fix: Use authorize_scope! instead of ensure_read_scope

* test(api): Add request specs for merchants and tags endpoints

* test(api): Add request specs for merchants and tags endpoints

* test(api): Convert specs to Minitest format in test/

* fix: Correct indentation for private methods

* fix: merchant and tag test

* Enhance tag tests for family scope and access

Added tests to ensure tags from other families are not returned and that attempts to access them return 404.

Signed-off-by: Jose <39016041+jospaquim@users.noreply.github.com>

* Enhance merchants controller tests for family scope

Added tests to ensure that merchants from other families are not returned in the index action and that accessing a merchant from another family returns a 404 error.

Signed-off-by: Jose <39016041+jospaquim@users.noreply.github.com>

* Fix test/implementation

* Remove old token test code

* Improve test

---------

Signed-off-by: Jose <39016041+jospaquim@users.noreply.github.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-23 10:18:22 +01:00
soky srm
87b77bb7df Merge pull request #744 from alessiocappa/FT-UpdateReportPageUI
feat: Improve report page UI
2026-01-23 09:19:17 +01:00
AdamWHY2K
3f5fff27ea feat: process pending transactions from lunchflow (#731)
* feat(config): add Lunchflow runtime configuration flags

* feat(api): add include_pending parameter to Lunchflow API

* feat(processor): add pending metadata support to Lunchflow processor

* feat(processor): generate temporary IDs for pending transactions

* feat(importer): integrate pending transaction support in sync

* fix(importer): improve deduplication for transactions without IDs

* feat(model): add Lunchflow pending support to Transaction scopes

* test: add Lunchflow processor pending metadata tests

* docs: update AGENTS.md for Lunchflow pending support

* chore: remove unused variable

* fix: simplify key check

* fix: dotenv-linter key order

* fix: avoid collapsing distinct pending transactions

* fix: prevent unbounded raw payload growth for blank IDs
2026-01-23 00:53:24 +01:00
Alessio Cappa
96dfad1cfb fix: fix tests 2026-01-23 00:49:47 +01:00
LPW
6279bfc497 Add comprehensive tests for SnaptradeAccount processors and data helpers. (#742)
Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-23 00:27:00 +01:00
LPW
7bd1058b6e Exclude tax-advantaged account activity from budget & add provider data quality warnings (#724)
* Add tax-advantaged account exclusions and investment data warnings

* Address PR review feedback: translations + cache key stability

- Add proper translations for provider warnings in 8 locales (de, es, nb, pt-BR, ro, tr, zh-CN, zh-TW)
- Fix cache key stability: use SHA256.hexdigest instead of Array#hash (randomized per process)

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-22 22:23:09 +01:00
Juan José Mata
bf76d6b88d Let /settings/providers work in demo site 2026-01-22 20:01:18 +00:00
LPW
a83f70425f Add SnapTrade brokerage integration with full trade history support (#737)
* Introduce SnapTrade integration with models, migrations, views, and activity processing logic.

* Refactor SnapTrade activities processing: improve activity fetching flow, handle pending states, and update UI elements for enhanced user feedback.

* Update Brakeman ignore file to include intentional redirect for SnapTrade OAuth portal.

* Refactor SnapTrade models, views, and processing logic: add currency extraction helper, improve pending state handling, optimize migration checks, and enhance user feedback in UI.

* Remove encryption for SnapTrade `snaptrade_user_id`, as it is an identifier, not a secret.

* Introduce `SnaptradeConnectionCleanupJob` to asynchronously handle SnapTrade connection cleanup and improve i18n for SnapTrade item status messages.

* Update SnapTrade encryption: make `snaptrade_user_secret` non-deterministic to enhance security.

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-22 20:52:49 +01:00
soky srm
179552657c Mercury integration (#723)
* Initial mercury impl

* FIX both mercury and generator class

* Finish mercury integration and provider generator

* Fix schema

* Fix linter and tags

* Update routes.rb

* Avoid schema drift

---------

Signed-off-by: soky srm <sokysrm@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-22 20:37:07 +01:00
Juan José Mata
7842b4a044 Fixes to contributions payment copy 2026-01-22 19:22:55 +00:00
Copilot
558bf7eeda feat: Support optional balance date column in account CSV imports (#736)
* Initial plan

* Add ability to specify balance date in AccountImport CSV

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Restore original Ruby version

* Fix linting issues - remove trailing whitespace

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Add error handling for date parsing in AccountImport

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Revert unintended Gemfile.lock changes

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>
2026-01-22 15:25:43 +01:00
Juan José Mata
051197137c Fix Polish translation template error (and increase testing/fix other locales as well) (#734)
* Add Polish locale support for money formatting

The Money::Formatting module handles locale-specific currency formatting
for French, German, Spanish, Italian, and Portuguese (Brazil), but was
missing support for Polish locale. This caused formatting issues when
users with Polish locale viewed account valuations.

- Add Polish locale handling to locale_options method
- Polish formatting uses: space as thousands delimiter, comma as
  decimal separator, symbol after number ("%n %u" format)
- Add test coverage for Polish locale formatting

* Add locale support for all supported locales in Money::Formatting

Extend the Money::Formatting module to handle all locales from
SUPPORTED_LOCALES to prevent template errors when users select
different languages.

Added locale-specific formatting for:
- Turkish (tr): dot delimiter, comma separator, symbol after number
- Norwegian Bokmål (nb): space delimiter, comma separator, symbol after
- Catalan (ca): dot delimiter, comma separator, symbol after number
- Romanian (ro): dot delimiter, comma separator, symbol after number
- Dutch (nl): dot delimiter, comma separator, symbol before number

Also improved Dutch handling to work with all currencies (not just EUR).

Added comprehensive tests for:
- All newly supported locales
- Chinese (zh-CN, zh-TW) which use default English-style formatting
- A test that verifies all SUPPORTED_LOCALES can format without errors

* Fix broken money formatting tests

- Fix Chinese Traditional locale test: TWD currency uses "TW$" symbol
  (prefixed with first 2 chars of ISO code to distinguish from USD)
- Fix all supported locales test: replace assert_nothing_raised (which
  doesn't accept message argument in Minitest) with explicit assertions

* Refactor Money::Formatting to consolidate locale patterns

Group locales by their formatting patterns into constants to reduce
repetition and make it easier to add new locales:

- EUROPEAN_SYMBOL_AFTER: de, es, it, tr, ca, ro
  (dot delimiter, comma separator, symbol after)
- SPACE_DELIMITER_SYMBOL_AFTER: pl, nb
  (space delimiter, comma separator, symbol after)
- EUROPEAN_SYMBOL_BEFORE: nl, pt-BR
  (dot delimiter, comma separator, symbol before)

French locale remains separate due to its unique non-breaking space usage.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-22 14:27:12 +01:00
LPW
dd991fa339 Add Coinbase exchange integration with CDP API support (#704)
* **Add Coinbase integration with item and account management**
- Creates migrations for `coinbase_items` and `coinbase_accounts`.
- Adds models, controllers, views, and background tasks to support account linking, syncing, and transaction handling.
- Implements Coinbase API client and adapter for seamless integration.
- Supports ActiveRecord encryption for secure credential storage.
- Adds UI components for provider setup, account management, and synchronization.

* Localize Coinbase-related UI strings, refine account linking for security, and add timeouts to Coinbase API requests.

* Localize Coinbase account handling to support native currencies (USD, EUR, GBP, etc.) across balances, trades, holdings, and transactions.

* Improve Coinbase processing with timezone-safe parsing, native currency support, and immediate holdings updates.

* Improve trend percentage formatting and enhance race condition handling for Coinbase account linking.

* Fix log message wording for orphan cleanup

* Ensure `selected_accounts` parameter is sanitized by rejecting blank entries.

* Add tests for Coinbase integration: account, item, and controller coverage

- Adds unit tests for `CoinbaseAccount` and `CoinbaseItem` models.
- Adds integration tests for `CoinbaseItemsController`.
- Introduces Stimulus `select-all` controller for UI checkbox handling.
- Localizes UI strings and logging for Coinbase integration.

* Update test fixtures to use consistent placeholder API keys and secrets

* Refine `coinbase_item` tests to ensure deterministic ordering and improve scope assertions.

* Integrate `SyncStats::Collector` into Coinbase syncer to streamline statistics collection and enhance consistency.

* Localize Coinbase sync status messages and improve sync summary test coverage.

* Update `CoinbaseItem` encryption: use deterministic encryption for `api_key` and standard for `api_secret`.

* fix schema drift

* Beta labels to lower expectations

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-21 22:56:39 +01:00
Copilot
0357cd7d44 Allow subcategories to inherit parent budget without individual limits (#579)
* Initial plan

* Implement subcategory budget inheritance feature

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Fix available_to_spend calculation for parent categories with mixed subcategories

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Optimize budget category calculations to avoid redundant filtering

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Add documentation for subcategory budget inheritance feature

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Add edge case tests for budget inheritance feature

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Fix linting issues - remove trailing whitespace

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Replace hardcoded '(shared)' label with i18n translation

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Fix test failures due to duplicate category names

Use unique names with timestamps to avoid validation errors when creating test categories. The Category model has a uniqueness validation on name scoped to family_id, and the test fixtures already contain categories like "Restaurants" which were causing conflicts.

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Remove LLM `.md` spec file

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Juan José Mata <jjmata@jjmata.com>
2026-01-21 22:10:15 +01:00
Juan José Mata
4e425ce4e5 Add option for FOSS contribution payments (#730)
* First commit

* Use subscription flow for monetary contributions

* Removed only part of the SPAN

* Localize Stripe payments message

* More localization of contribution strings

* Missed two billing to payment changes

* Fix tests

* Localization of "Open Demo" strings

* Fix grammar error

* Update for consistency

* Localize CTA

* More localilzation strings
2026-01-21 20:45:04 +01:00
Juan José Mata
8e36c8e736 Rename billing to payment throughout the codebase (#726)
* Rename billing to payment throughout the codebase

This change updates terminology from "billing" to "payment" to better
reflect that these are contributions/payments rather than bills.

Changes include:
- Rename BillingsController to PaymentsController
- Rename billing_email to payment_email
- Rename next_billing_date to next_payment_date
- Rename create_billing_portal_session_url to create_payment_portal_session_url
- Update routes from billing to payment
- Update all 12 locale files with new terminology
- Update views, helpers, and tests

* Update app/views/subscriptions/upgrade.html.erb

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Juan José Mata <jjmata@jjmata.com>

---------

Signed-off-by: Juan José Mata <jjmata@jjmata.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-21 19:06:00 +01:00
soky srm
abab66675c Implement a setting to retrieve high res logos (#725)
* Implement a setting to retrieve high res logos

* Update _brand_fetch_settings.html.erb

* Add fallback for stock tickers also to use Brandfetch

* Update security.rb

* Update toggle logic for high-res logos setting

Signed-off-by: Juan José Mata <jjmata@jjmata.com>

* Update security.rb

* Update security.rb

---------

Signed-off-by: Juan José Mata <jjmata@jjmata.com>
Co-authored-by: Juan José Mata <jjmata@jjmata.com>
2026-01-21 17:16:51 +01:00
luckyPipewrench
480e53710a Centralize investment_contributions category handling using i18n key and streamline related references. 2026-01-20 17:36:56 -05:00
luckyPipewrench
4727a391a7 Refactor Investment Contributions category handling to use a centralized constant and streamline related logic. 2026-01-20 17:18:49 -05:00
luckyPipewrench
196d12466f Handle investment_contribution classification and update related logic. 2026-01-20 16:50:45 -05:00
Julien Orain
777fbdc4ca feat(settings): add pagination to imports and exports pages (#598)
* feat(settings): split imports and exports

* feat(security): sanitize pagination params to prevent abuse

* fix(settings): fix syntax in settings nav

* feat(settings): internationalize family_exports and imports UI strings

* fix(settings): fix coderabbit review

* fix(settings): fix coderabbit review

* fix(settings): fix coderabbit review

* Change default per_page value from 20 to 10

Signed-off-by: Juan José Mata <jjmata@jjmata.com>

* Add `/family_export` to navigation

* Consistency with old defaults

* Align `safe_per_page` even if not DRY

---------

Signed-off-by: Julien Orain <julien.orain@gmail.com>
Signed-off-by: Juan José Mata <jjmata@jjmata.com>
Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: JulienOrain <your-github-email@example.com>
Co-authored-by: Juan José Mata <jjmata@jjmata.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-20 00:11:22 +01:00
David Gil
3d91e60a8a feat: Add subcategory breakdown to Cash Flow Sankey and Reports (#639)
* feat: Add subcategory breakdown to Cash Flow and Reports

Implements Discussion #546 - adds hierarchical category/subcategory
visualization to both the Sankey chart and Reports breakdown tables.

Sankey chart changes:
- Income: subcategory → parent category → Cash Flow
- Expense: Cash Flow → parent category → subcategory
- Extracted process_category_totals helper to DRY up income/expense logic

Reports breakdown changes:
- Subcategories display nested under parent categories
- Smaller dots and indented rows for visual hierarchy
- Extracted _breakdown_table partial to eliminate duplication

* fix: Dynamic node padding for Sankey chart with many nodes

- Add dynamic nodePadding calculation to prevent padding from dominating
  chart height when there are many subcategory nodes
- Extract magic numbers to static constants for configuration
- Decompose monolithic #draw() into focused methods
- Consolidate duplicate tooltip/currency formatting code
- Modernize syntax with spread operators and optional chaining

* fix: Hide overlapping Sankey labels, show on hover

- Add label overlap detection by grouping nodes by column depth
- Hide labels that would overlap with adjacent nodes
- Show hidden labels on hover (node rectangle or connected links)
- Add hover events to node rectangles (not just text)

* fix: Use deterministic fallback colors for categories

- Replace Category::COLORS.sample with Category::UNCATEGORIZED_COLOR
  for income categories in Sankey chart (was producing different colors
  on each page load)
- Add nil color fallback in reports_controller for parent and root
  categories

Addresses CodeRabbit review feedback.

* fix: Expand CSS variable map for d3 color manipulation

Add hex mappings for commonly used CSS variables so d3 can manipulate
opacity for gradients and hover effects:
- var(--color-destructive) -> #EC2222
- var(--color-gray-400) -> #9E9E9E
- var(--color-gray-500) -> #737373

* test: Add tests for subcategory breakdown in dashboard and reports

- Test dashboard renders Sankey chart with parent/subcategory transactions
- Test reports groups transactions by parent and subcategories
- Test reports handles categories with nil colors
- Use EntriesTestHelper#create_transaction for cleaner test setup

* Fix lint: use Number.NEGATIVE_INFINITY

* Remove obsolete nil color test

Category model now validates color presence, so nil color categories
cannot exist. The fallback handling in reports_controller is still in
place but the scenario is unreachable.

* Update reports_controller.rb

* FIX trade category

---------

Co-authored-by: sokie <sokysrm@gmail.com>
2026-01-20 00:01:55 +01:00
Alessio Cappa
2e081ea82d fix: Move rule application to perform_post_sync method (#705)
* Move rule application to perform_post_sync method

Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com>

* fix: Update test

---------

Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com>
2026-01-19 22:57:46 +01:00
LPW
8b8ac705f6 Correct brokerage cash calculation for SimpleFIN investment accounts (#710)
* Refactor: Enhance cash balance calculation and holdings management with money market classification and provider-sourced data handling

* Fix: Clear fixture holdings in test to ensure clean creation and update raw_holdings_payload format

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-19 22:17:27 +01:00
LPW
64dc5c2fb8 Add tax treatment classification for investment accounts with international support (#693)
* Add tax treatment support for accounts, investments, and cryptos

* Replace hardcoded region labels with I18n translations

* Add I18n support for subtype labels with fallback to hardcoded values

* fixed schema

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-18 17:29:02 +01:00
LPW
f97ff419e8 Allow manual entry on linked accounts (#689)
* Update activity menu to conditionally display options for linked and investment accounts

* Update transaction test to reflect "New activity" menu change

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-18 15:08:27 +01:00
foXaCe
302fb84086 feat: Support multiple crypto wallets with same token (#676)
* feat: Support multiple crypto wallets with same token

Allows users to import multiple wallets containing the same
cryptocurrency (e.g., ETH on different wallet addresses).

Changes:
- Add wallet_address column to coinstats_accounts
- Update uniqueness validation to include wallet_address
- Extract and store wallet address in WalletLinker
- Add composite unique index on [item_id, account_id, wallet_address]
- Add tests for multi-wallet support and backwards compatibility

Users can now have:
- ETH (0xAAA...) → "Ethereum (0xAA...AA)"
- ETH (0xBBB...) → "Ethereum (0xBB...BB)"

Backwards compatible: existing accounts with wallet_address: nil
continue to work.

* style: Fix array bracket spacing in migration

* chore: Update schema.rb with wallet_address column and index

Add the missing wallet_address column and composite unique index
to db/schema.rb for CI compatibility with db:schema:load

* test: Add test for wallet deletion with same token different addresses

Verifies that deleting one wallet does not affect other wallets
that share the same token but have different addresses.

Addresses review comment from @EthanC via @jjmata

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-18 11:27:09 +01:00
Juan José Mata
47e0185409 fix: Allow locale preview on onboarding preferences page (#682)
* fix: Allow locale preview on onboarding preferences page

When a user selects a different language on /onboarding/preferences,
the page now immediately displays in the selected language. This is
achieved by checking for a valid locale URL parameter before falling
back to the family's saved locale setting.

* fix: Harden locale param handling and restore locale in tests

- Add type check to ensure params[:locale] is a String before calling
  .to_sym, preventing 500 errors from array/hash injection attacks
- Add teardown to tests to restore original locale, preventing test
  pollution

* fix: Reload family in teardown to handle update_column

* fix: Remove edge case test that used update_column with nil locale

* fix: Simplify localize tests - rely on fixture defaults and transactional isolation

* fix: Update system test to expect Spanish button text after locale preview

* refactor: Use I18n.t for button text in system test instead of hardcoded string

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-17 17:59:10 +01:00
foXaCe
917101853b fix: Locale-aware currency formatting (#677)
* fix: Locale-aware currency formatting

Add locale-specific formatting for money display:
- French (fr): symbol after number with non-breaking space (1 000,12 €)
- German (de): symbol after number (1.000,12 €)
- Spanish (es): symbol after number (1.000,12 €)
- Italian (it): symbol after number (1.000,12 €)
- Portuguese-Brazil (pt-BR): symbol before with space (R$ 1.000,12)

This follows international conventions where most European languages
place the currency symbol after the number, unlike English.

* fix: Address CodeRabbit review comments

- Use non-breaking spaces (NBSP) for French locale formatting
- Add nil guard in locale_options to prevent NoMethodError
- Add test coverage for Portuguese (Brazil) locale

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 23:55:51 +01:00
LPW
9792ab838f Make first user of instance automatically super_admin (#655)
* Implement dynamic role assignment for new family creators.

Introduced `User.role_for_new_family_creator` to assign `super_admin` to the first user of an instance and a configurable fallback role (e.g., `admin`) to subsequent users. Updated controllers and tests accordingly.

* Update default fallback role for family creators to admin.

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-16 21:27:55 +01:00
LPW
0c2026680c Improve investment activity labels UX and add convert-to-trade feature (#649)
* Add `investment_activity_label` to trades and enhance activity label handling

- Introduced `investment_activity_label` column to the `trades` table with a migration.
- Backfilled existing `trades` with activity labels based on quantity (`Buy`, `Sell`, or `Other`).
- Replaced `category_id` in trades with `investment_activity_label` for better alignment with transaction labels.
- Updated views and controllers to display and manage activity labels for trades.
- Added localized badge components for displaying and editing labels dynamically.
- Enhanced `PlaidAccount::Investments::TransactionsProcessor` to assign and process activity labels automatically.
- Added investment flows section to reports for tracking contributions and withdrawals.
- Refactored related tests and models for consistency and to ensure proper validation and filtering.

* Improve handling of `investment_activity_label`, trade type, and security selection in trades and transactions

- Refined label assignment logic in `trades_controller` to default to `Buy`/`Sell` based on transaction nature.
- Simplified security selection in `transactions_controller` by resolving via unique IDs or custom tickers.
- Streamlined UI for trade and transaction forms by updating dropdown options and label text.
- Enabled quick-edit badges to open `convert_to_trade` modal when applicable, enhancing flexibility.
- Adjusted tests and views to align with updated workflows and ensure consistent behavior.

* Improve handling of `investment_activity_label`, trade type, and security selection in trades and transactions

- Refined label assignment logic in `trades_controller` to default to `Buy`/`Sell` based on transaction nature.
- Simplified security selection in `transactions_controller` by resolving via unique IDs or custom tickers.
- Streamlined UI for trade and transaction forms by updating dropdown options and label text.
- Enabled quick-edit badges to open `convert_to_trade` modal when applicable, enhancing flexibility.
- Adjusted tests and views to align with updated workflows and ensure consistent behavior.

* Improve handling of `investment_activity_label`, trade type, and security selection in trades and transactions

- Refined label assignment logic in `trades_controller` to default to `Buy`/`Sell` based on transaction nature.
- Simplified security selection in `transactions_controller` by resolving via unique IDs or custom tickers.
- Streamlined UI for trade and transaction forms by updating dropdown options and label text.
- Enabled quick-edit badges to open `convert_to_trade` modal when applicable, enhancing flexibility.
- Adjusted tests and views to align with updated workflows and ensure consistent behavior.

* Add safeguard for `dropdownTarget` existence in quick edit controller

- Prevent errors by ensuring `dropdownTarget` is present before toggling its visibility.

* Fix undefined method 'category' for Trade on mobile view

Trade model uses investment_activity_label, not category. The upstream
merge introduced a call to trade.category which doesn't exist. Use the
activity label badge on mobile instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix activity label logic for zero/blank quantity and sell inference

- Return `nil` for blank or zero quantity in `investment_activity_label_for`.
- Correct `is_sell` logic to use the amount’s sign properly in `transactions_controller`.

* Fix i18n key paths in transactions controller for convert_to_trade

- Update flash message translations to use full i18n paths.
- Use `BigDecimal` for quantity and price calculations to improve precision.

---------

Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 21:04:10 +01:00
LPW
1ca84d8048 Fix missing SSO JIT account creation template (#679)
* Add UI and functionality for new user registration via OIDC integration

* Add tests and localization for new user registration via OIDC

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-16 21:00:24 +01:00
soky srm
d1b8d585ce FIX merchant regression (#659) 2026-01-15 13:14:10 +01:00
soky srm
0e22c60286 FIX Yahoo issues (#636)
* FIX Yahoo issues

* Update yahoo_finance_test.rb

* FIX proper cookie access
2026-01-13 16:46:07 +01:00
Juan José Mata
88241cf5cb Fix tags getting removed after / during bank sync (#634)
* fix: Preserve transaction tags during rule application

When rules set tags, they now ADD to existing tags instead of replacing
them. This fixes issue #518 where tags were being removed during bank sync.

The root cause was that SetTransactionTags called enrich_attribute with
just the single tag from the rule, which replaced all existing tags.
Now it merges the new tag with existing tags using .uniq to prevent
duplicates.

This preserves:
- User-applied tags that shouldn't be overwritten by rules
- Tags from other rules when multiple rules match the same transaction
- Tags set during previous syncs

* fix: Add nil guard for tag in SetTransactionTags

Return early with 0 if the tag is not found, preventing NoMethodError
when find_by_id returns nil. This matches the pattern used in
SetTransactionMerchant.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-13 14:33:46 +01:00
Juan José Mata
accdbb799b Merge branch 'main' into add-config-import-csv-skip-first-x-rows
Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-13 12:56:22 +01:00
soky srm
0c92eb91b3 Merge pull request #608 from luckyPipewrench/investment-activity
Investment activity labels and classification
2026-01-13 10:13:31 +01:00
LPW
7c3af7d85e refactor: streamline SimpleFIN connection updates for improved efficiency (#631)
- Introduced `update_access_url!` method to reuse existing SimpleFIN items during reconnections, preserving account linkages.
- Refactored `SimplefinConnectionUpdateJob` to update access URLs in place without creating new items or transferring accounts.
- Adjusted sync logic to leverage `repair_stale_linkages` for seamless reconnections.
- Enhanced `SimplefinItem::Importer` to auto-recover the `good` status if no auth errors are found during sync.
- Updated tests to validate in-place updates and preserved account relationships.

Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
2026-01-13 09:39:26 +01:00