mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-06 05:55:21 +02:00
Assert flows factor
This commit is contained in:
parent
27133f665c
commit
4170387aa1
2 changed files with 7 additions and 1 deletions
|
@ -133,7 +133,8 @@ class Balance::BaseCalculator
|
|||
non_cash_outflows: args[:non_cash_outflows] || 0,
|
||||
cash_adjustments: args[:cash_adjustments] || 0,
|
||||
non_cash_adjustments: args[:non_cash_adjustments] || 0,
|
||||
net_market_flows: args[:net_market_flows] || 0
|
||||
net_market_flows: args[:net_market_flows] || 0,
|
||||
flows_factor: account.classification == "asset" ? 1 : -1
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -135,6 +135,11 @@ module LedgerTestingHelper
|
|||
if expected
|
||||
assert calculated_balance, "Expected balance for #{date} but none was calculated"
|
||||
|
||||
# Always assert flows_factor is correct based on account classification
|
||||
expected_flows_factor = calculated_balance.account.classification == "asset" ? 1 : -1
|
||||
assert_equal expected_flows_factor, calculated_balance.flows_factor,
|
||||
"Flows factor mismatch for #{date}: expected #{expected_flows_factor} for #{calculated_balance.account.classification} account"
|
||||
|
||||
legacy_balances = expected[:legacy_balances]
|
||||
balances = expected[:balances]
|
||||
flows = expected[:flows]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue