hledger icon indicating copy to clipboard operation
hledger copied to clipboard

Two decimal separators in an assertion mess up the total balance without warning

Open elfehr opened this issue 3 years ago • 2 comments
trafficstars

I accidentally left the dot as thousands separator when copying-pasting my bank balance and only changed the decimal separator from coma to dot, so that my assertion had two of them:

commodity 1 000.00 €
account assets:example
account assets:example2
account equity:adjustments

2022-08-02 checking balances
	assets:example2                  = 2.50 €
	assets:example                  = 10.999.99 €
	equity:adjustments

I only noticed something was wrong when looking at the total balance: it seems to recognize both dots as thousands separators. Maybe at least the strict check mode should enforce that the amounts are formatted like in the commodity directive?

hledger -f test bal assets -s
         1 099 999 €  assets:example
              2.50 €  assets:example2
--------------------
      1 100 001.50 €  

Version: hledger 1.26, linux-x86_64

elfehr avatar Aug 02 '22 10:08 elfehr

Related doc: https://hledger.org/1.26/hledger.html#decimal-marks-digit-group-marks

The decimal-mark directive is best, otherwise commodity directives will also work.

But even with decimal-mark . it seems not to complain. I agree, either the commodity or decimal-mark directive should be triggering a parse error here.

simonmichael avatar Aug 02 '22 11:08 simonmichael

Thank you for pointing out decimal-mark! It had escaped my attention.

elfehr avatar Aug 03 '22 15:08 elfehr