lib: test for issue with sign checking code + fix

This commit is contained in:
Dmitry Astapov 2020-06-01 22:27:08 +01:00 committed by Simon Michael
parent 8b0618ce4d
commit cbf4029b8b
2 changed files with 25 additions and 0 deletions

View File

@ -610,6 +610,7 @@ isNegativeMixedAmount m =
[] -> Just False
[a] -> Just $ isNegativeAmount a
as | all isNegativeAmount as -> Just True
as | not (any isNegativeAmount as) -> Just False
_ -> Nothing -- multiple amounts with different signs
-- | Does this mixed amount appear to be zero when rendered with its

View File

@ -131,3 +131,27 @@ real postings all have the same sign
b 1B
>=1
# 12. Typical "hledger equity --close" transaction does not trigger sign error.
<
2019-01-01 opening balances
assets:a1 $3
assets:a2 £10
equity:opening/closing balances
2019-12-31 closing balances
assets:a1 $-3 = $0.00
assets:a2 £-10 = £0.00
equity:opening/closing balances
$ hledger -f- print
2019-01-01 opening balances
assets:a1 $3
assets:a2 £10
equity:opening/closing balances
2019-12-31 closing balances
assets:a1 $-3 = $0
assets:a2 £-10 = £0
equity:opening/closing balances
>=0