From f18c74fff774b79e7241cec528e43aec38685651 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 5 Mar 2020 11:12:25 -0800 Subject: [PATCH] ;journal: a test for inclusive balance assignment, disabled (#1207) [ci skip] --- hledger-lib/Hledger/Data/Journal.hs | 2 +- tests/journal/balance-assertions.test | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 052338156..1fb4251e7 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -753,6 +753,7 @@ addOrAssignAmountAndCheckAssertionB p@Posting{paccount=acc, pamount=amt, pbalanc return p -- no explicit posting amount, but there is a balance assignment + -- TODO this doesn't yet handle inclusive assignments right, #1207 | Just BalanceAssertion{baamount,batotal} <- mba = do (diff,newbal) <- case batotal of -- a total balance assignment (==, all commodities) @@ -814,7 +815,6 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt if isinclusive then -- sum the running balances of this account and any of its subaccounts seen so far - -- XXX something wrong here, #1207 withRunningBalance $ \BalancingState{bsBalances} -> H.foldM (\ibal (acc, amt) -> return $ ibal + diff --git a/tests/journal/balance-assertions.test b/tests/journal/balance-assertions.test index 7bd47c438..3df348b5b 100755 --- a/tests/journal/balance-assertions.test +++ b/tests/journal/balance-assertions.test @@ -139,7 +139,7 @@ hledger -f - stats # >>>2 # >>>=0 -# 8. resetting a balance +# 8. Using balance assignment to set balances. hledger -f - stats <<< 2013/1/1 @@ -431,3 +431,22 @@ hledger -f- print >>>2 >>>=0 + +## 25. Inclusive balance assignments also work (#1207). +#hledger -f- print -x +#<<< +#2020-01-25 +# (a:aa) 1 +# +#2020-01-31 +# (a) ==* 1 +# +#>>> +#2020-01-25 +# (a:aa) 1 +# +#2020-01-31 +# (a) 0 ==* 1 +# +#>>>2 +#>>>=0