mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
fix balance accumulation across assertions (#195)
A sequence of balance assertions asserting first one commodity, then another, then the first again, was not working.
This commit is contained in:
parent
6543f44d82
commit
257ce57383
@ -446,10 +446,9 @@ checkBalanceAssertion :: ([String],MixedAmount) -> [Posting] -> ([String],MixedA
|
||||
checkBalanceAssertion (errs,startbal) ps
|
||||
| null ps = (errs,startbal)
|
||||
| isNothing assertion = (errs,startbal)
|
||||
|
|
||||
-- bal' /= assertedbal -- MixedAmount's Eq instance currently gets confused by different precisions
|
||||
not $ isReallyZeroMixedAmount (bal - assertedbal) = (errs++[err], bal)
|
||||
| otherwise = (errs,bal)
|
||||
| -- bal' /= assertedbal -- MixedAmount's Eq instance currently gets confused by different precisions
|
||||
not $ isReallyZeroMixedAmount (bal - assertedbal) = (errs++[err], fullbal)
|
||||
| otherwise = (errs,fullbal)
|
||||
where
|
||||
p = last ps
|
||||
assertion = pbalanceassertion p
|
||||
@ -473,7 +472,7 @@ checkBalanceAssertion (errs,startbal) ps
|
||||
-- assertion are discarded.
|
||||
splitAssertions :: [Posting] -> [[Posting]]
|
||||
splitAssertions ps
|
||||
| null rest = [[]]
|
||||
| null rest = []
|
||||
| otherwise = (ps'++[head rest]):splitAssertions (tail rest)
|
||||
where
|
||||
(ps',rest) = break (isJust . pbalanceassertion) ps
|
||||
|
@ -101,7 +101,20 @@ hledgerdev -f - stats
|
||||
>>>2
|
||||
>>>=0
|
||||
|
||||
# 7. what should happen here ? Currently,
|
||||
# 7. balances should accumulate (#195)
|
||||
hledgerdev -f - stats
|
||||
<<<
|
||||
1/1
|
||||
(a) 1F = 1F
|
||||
(a) 2G = 2G
|
||||
|
||||
1/2
|
||||
(a) 3F = 4F
|
||||
>>> !/assertion failed/
|
||||
>>>2
|
||||
>>>=0
|
||||
|
||||
# 8. what should happen here ? Currently,
|
||||
# in a, 3.4 EUR @@ $5.6 and -3.4 EUR cancel out (wrong ?)
|
||||
# in b,
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user