It's currentlly possible, if you have a commodity directive limiting display precision, to have a balance assertion failure where both amounts in the error message look identical, eg:
commodity $1000.00
2019/01/01
(a) $1.006 = $1.01
$ hledger stats
...
calculated: $1.01
asserted: $1.01 (difference: +0)
This is unhelpful. Perhaps there was some discussion of this in 2018, but I don't remember where.
How should balance assertions work when there is a limited display precision ?
Some options:
- compare the exact calculated balance with the exact asserted balance; display precision is ignored (current behaviour)
-
problem: the failure message shows the amounts with display precision, sometimes hiding the reason for failure. Solutions:
- in the failure message, show amounts at full precision ?
- show the amounts with just enough precision so they look different ?
-
compare the calculated balance rounded to display precision, with the exact asserted balance ?
-
compare both balances rounded to display precision ?
- problem: I think both of the above allow multiple different asserted balances to succeed, which feels a little loosey goosey
- compare both exact balances by calculating the difference between them, and checking if that looks like zero when rendered at display precision. (I think this is distinct from the above but I'm not certain.)