Fix Trade Republic Saveback and Round Up routing
Closed
NI
2mo ago+421+421+012345678901234567890123456789-4-4-0123456789
Summary
- Route
SAVEBACK_AGGREGATEas a portfolio-only trade (never a cash withdrawal) when ISIN/quantity/amount are complete - Route
SPARE_CHANGE_AGGREGATE(Round Up) as both a portfolio trade and a cash outflow on the linked cash account - On sync, remove stale unprotected Saveback cash entries while preserving user-modified or split transactions
This is a partial fix for #3475: it only corrects Saveback and Round Up event routing/reconciliation. It does not close the issue.
Still out of scope / follow-up work for #3475:
- Savings-plan mapping (
SAVINGS_PLAN_INVOICE_CREATED/ related cash deductions) - Timeline detail backfill beyond the current detail-request limit
- Status / deleted / hidden filtering
- Unknown-event counting
- ISIN → ticker security resolution
Test plan
- Run
bin/rails test test/models/trade_republic_account_activities_processor_test.rb test/models/trade_republic_item_importer_test.rb - Sync a Trade Republic account with Saveback history: confirm portfolio buy appears and no Saveback cash withdrawal remains (unless user-edited)
- Sync with Round Up history: confirm portfolio buy plus cash "Round up" outflow for the same event id
- Re-sync and confirm no duplicate entries
- Confirm incomplete aggregate details do not create a bad Saveback cash withdrawal; Round Up cash still imports without a trade