Let users count an investment transfer as a plain transfer
Problem
A transfer from a cash account into an investment or crypto account always becomes an investment_contribution, which budgets, reports, the cashflow Sankey and the transactions page "Outflow" count as spending. That's the intended default, but many users treat brokerage and crypto accounts as currency converters rather than investments: they move money in (say, rubles), convert it at the broker's or exchange's rate ā usually far better than the bank's ā and move it straight back out in the other currency, to pay for purchases or transfer it on. The return leg is a plain funds_movement, so the round trip shows up as an expense with no way to fix it per transfer.
Behavior
- The transfer drawer's Details section gets an Investment contribution switch right below the category (in its own form, so category and notes edits don't submit it), shown only for a confirmed transfer whose destination makes it a contribution (cash ā investment/crypto) and only when the user can write to both accounts. On by default ā nothing changes unless the user turns it off.
- Off: the outflow becomes
funds_movement, so it drops out of budgets/reports through the existingBUDGET_EXCLUDED_KINDS. The auto-assigned Investment Contributions category is cleared (a category the user picked stays) and the category field hides, as for any plain transfer. On: back toinvestment_contribution, category re-assigned if empty. - The choice survives syncs: the outflow's
kindis locked (lock_attr!(:kind)), andTransfer#kind_for_leg/#categorizable?honour a locked contribution choice, soAccount::ProviderImportAdapterre-imports andTransfer::InvestmentKindReconcilerkeep it. Unlinking/rejecting the transfer drops the lock with the kind. - After toggling, the page reloads (turbo-stream redirect) so the Outflow/expense totals update.
- New
update_transferassistant/MCP tool (investment_contribution: true|false,dry_run) makes the same switch for agents; the transfer lookup it shares withunmatch_transfermoved toAssistant::Function::TransferSupport.
Partially addresses #1313 and #1750 (per transfer rather than family-wide, so the existing default and the "budget my monthly investing" use case stay intact). Related: #3845.
Validation
- New tests:
TransferTest(switch both ways, user category kept, non-switchable/pending transfers refused,kind_for_leg, lock dropped on reject),ProviderImportAdapterTest(re-import keeps the choice),TransfersControllerTest(switch shown only for investment transfers, turbo-stream redirect, HTML path, write permission on both sides),UpdateTransferTest. - Full
bin/rails test: 11800 runs, 0 failures; 2 errors are local-environment only (no image processor for ActiveStorage variants; same onmain). rubocop,erb_lint,brakeman(no warnings),i18n-tasks missing -l en,ruclean. No JS changes.
Screenshot:
š¤ Generated with Claude Code
Summary by CodeRabbit
Summary by CodeRabbit
- New Features
- Confirmed transfers into investment or crypto accounts can be counted as spending in budgets and reports, or treated as plain transfers.
- The setting is available when you have write access to both accounts. You can also ask the AI assistant to change it or preview the proposed change.
- Transfer investment-contribution choices are included in data exports and restored on import.
- Bug Fixes
- Re-importing a provider transaction no longer overwrites your choice to treat an eligible transfer as a plain transfer.