mirror of
https://github.com/we-promise/sure.git
synced 2026-05-31 16:29:03 +00:00
* fix(snaptrade): import non-primary-currency cash as cash holdings Fixes #1809. SnaptradeAccount#upsert_balances! picked a single cash entry (account currency -> USD -> first) and stored only that in cash_balance; every other currency's cash was discarded. A moomoo Canada account with CAD $500 + USD $1000 imported only the CAD. Persist the full balances snapshot (new raw_balances_payload column) and surface each non-primary-currency cash entry as a synthetic per-currency cash holding (Security.cash_for(account, currency:)), mirroring the existing cash-security pattern. The primary currency stays in cash_balance. HoldingsProcessor now also runs for cash-only balances, and the Processor invokes it when there are holdings OR non-primary cash. Cash holdings use a stable external_id so repeated syncs update rather than duplicate. * fix(snaptrade): encrypt raw_balances_payload and drop cash amount from log Addresses PR #1979 review: Codex P1 (encrypt the newly persisted balances snapshot at rest, matching the other raw provider payloads) and CodeRabbit nitpick (do not log monetary amounts at info level). * refactor(snaptrade): extract primary_cash_entry and harden balances test PR #1979 review: extract the shared account-currency->USD->first cash selection into a private helper (CodeRabbit DRY nitpick); reorder the upsert_balances! test so the primary currency is not first, proving dig(:currency,:code) resolves it on string-keyed payloads rather than the entries.first fallback (jjmata).