feat: investment contribution as a transfer switch is added

IM
4d ago
+285-7

Problem

A transfer into an investment or crypto account becomes an investment contribution by default: it counts as spending in budgets and reports. Since #4177, users can switch a single transfer to a plain transfer, for example when a brokerage or crypto account only converts money into another currency. Users whose investment transfers are mostly currency conversions have to flip that switch on every transfer.

The existing Count investing as spending preference doesn't cover this. It's all-or-nothing: it stops every contribution from counting as spending and leaves no way to opt individual transfers back in.

What changes

A new admin-only preference under Settings → Preferences → Budget: Mark new investment transfers as contributions. It is on by default, so nothing changes for existing families.

When it's off, a new confirmed transfer into an investment or crypto account from a non-investment account starts as a plain transfer:

  • the outflow is funds_movement, not investment_contribution
  • the Investment Contributions category is dropped
  • the kind is locked

This is the same state Transfer#update_investment_contribution!(false) produces when a user flips the switch, so users can still turn individual transfers back into contributions.

Behaviour

  • Only new transfers are affected. Flipping the setting doesn't touch existing transfers. Because the default is stored as a locked choice, Transfer::InvestmentKindReconciler and provider re-syncs through Account::ProviderImportAdapter keep it too.
  • Where the default applies: in Transfer::Creator (transfer form and trades), and in Transfer#confirm!, which covers manual matches, auto-match confirmations, rules (SetAsTransferOrPayment), the assistant's match and review tools, and Sharesight.
  • Imports are unaffected. Family::DataImporter doesn't call either path, so imported transfers keep the kinds and choices they were exported with.
  • Investment-to-investment transfers and liability payments are unchanged.

Summary by cubic

Adds an admin-only preference for marking new investment transfers as contributions, so users who mostly convert currency in brokerage or crypto accounts don't have to flip the switch on every transfer.

  • New Mark new investment transfers as contributions setting is on by default, so nothing changes for existing families.
  • When off, new transfers into investment or crypto accounts start as plain transfers: kind locked to funds_movement, no investment contributions category.
  • The default applies only the first time a transfer is confirmed; re-confirms, provider re-syncs, and imports keep existing kinds, and flipping the setting back doesn't touch existing transfers.
  • A user's locked contribution choice always wins; other locked kinds (like one_time) are replaced by the default.
  • Match previews report the kind the transfer will confirm with.
  • Individual transfers can still be switched back to contributions at any time.

Summary by CodeRabbit

  • New Features
    • Administrators can choose whether new transfers into brokerage or crypto accounts count as spending. By default, they do; when disabled, these transfers are treated as funds movements.
    • This preference is available only to administrators and applies to new transfers. Existing transfers retain their current classification and can still be changed individually.
    • Transfer previews show the applicable classification for investment-account transfers, including when a transfer’s classification has been locked.