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>
This commit is contained in:
LPW
2026-01-19 16:17:27 -05:00
committed by GitHub
parent 63dd231787
commit 8b8ac705f6
5 changed files with 125 additions and 36 deletions

View File

@@ -19,6 +19,9 @@ class SimplefinHoldingsApplyJobTest < ActiveSupport::TestCase
end
test "materializes holdings from raw_holdings_payload and is idempotent" do
# Clear existing fixture holdings so we can test clean creation
@account.holdings.delete_all
# Two holdings: one AAPL (existing security), one NEWCO (should be created)
@sfa.update!(
raw_holdings_payload: [
@@ -27,16 +30,14 @@ class SimplefinHoldingsApplyJobTest < ActiveSupport::TestCase
"symbol" => "AAPL",
"quantity" => 10,
"market_value" => 2000,
"currency" => "USD",
"as_of" => (Date.current - 2.days).to_s
"currency" => "USD"
},
{
"id" => "h2",
"symbol" => "NEWCO",
"quantity" => 5,
"market_value" => 500,
"currency" => "USD",
"as_of" => Date.current.to_s
"currency" => "USD"
}
]
)