# hledger close prints ambiguous amounts #1137

Closed
opened this issue Nov 27, 2019 · 3 comments
Labels

### maralorn commented Nov 27, 2019

 hledger close prints (for the commodity 1.000,00€) integer values without cent values. ``````\$ cat bug.hledger 2019-12-31 test a 1.000,00€ b 10,05€ c \$ hledger -f bug.hledger close 2019/11/27 closing balances a -1.000€ = 0€ b -10,05€ = 0€ c 1.010,05€ = 0€ equity:closing balances 0 2019/11/28 opening balances a 1.000€ = 1.000€ b 10,05€ = 10,05€ c -1.010,05€ = -1.010,05€ equity:opening balances 0 `````` As the hledger manual says ``````Note, a number containing a single group mark and no decimal mark is ambiguous. Are these group marks or decimal marks ? 1,000 1.000 hledger will treat them both as decimal marks by default (cf #793). `````` So my understanding is that it should be `````` a 1.000,00€ = 1.000,00€ `````` to prevent ambiguities. I think this is really a bug because of this: ``````\$ hledger -f bug.hledger close | hledger -f- print hledger: "-" (lines 1-5) could not balance this transaction (real postings are off by 999.000€) 2019/11/27 closing balances a -1.000€ = 0.000€ b -10.050€ = 0.000€ c 1.010.050€ = 0.000€ equity:closing balances 0 `````` I am on `hledger 1.15.2` on nixos stable (19.09).
added the label Nov 27, 2019
added the label Nov 28, 2019

### simonmichael commented Nov 30, 2019 • edited

 Thanks for the report. In your example: ``````2019-12-31 test a 1.000,00€ b 10,05€ c `````` the comma is parsed as a decimal mark in both amounts (correct). But `close` elides the first amount's decimal digits in the output: ``````\$ hledger close --closing 2019/11/28 closing balances a -1.000€ = 0€ b -10,05€ = 0€ c 1.010,05€ = 0€ equity:closing balances 0 `````` It does it even if you add a commodity directive to set the display style: ``````commodity 1.000,00€ 2019-12-31 test a 1.000,00€ b 10,05€ c `````` ``````\$ hledger close --closing 2019/11/28 closing balances a -1.000€ = 0€ b -10,05€ = 0€ c 1.010,05€ = 0€ equity:closing balances 0 `````` ..which it shouldn't. `print` shows it correctly, with or without the directive: ``````\$ hledger print 2019/12/31 test a 1.000,00€ b 10,05€ c `````` This `-1.000€` amount is what causes the second print to fail at balancing the transaction, since the single period is parsed as a decimal mark. Unless you add a commodity directive to the second print's input (and the -I flag, since we need to ignore the assertions in this small example): ``````\$ (echo "commodity 1.000,00€"; hledger close --closing) | hledger -f- print -I 2019/11/28 closing balances a -1.000,00€ = 0,00€ b -10,05€ = 0,00€ c 1.010,05€ = 0,00€ equity:closing balances 0 `````` The close output for your example should be: ``````\$ hledger close 2019/11/28 closing balances a -1.000,00€ = 0€ b -10,05€ = 0€ c 1.010,05€ = 0€ equity:closing balances 0 2019/11/29 opening balances a 1.000,00€ = 1.000€ b 10,05€ = 10,05€ c -1.010,05€ = -1.010,05€ equity:opening balances 0 `````` Ie with the `,00` in both `a` amounts. As you clearly said. :)
added the label Nov 30, 2019

### maralorn commented Nov 30, 2019

 Yeah, exactly. I used exactly that commodity workaround.
closed this in ``` 5b6dbe8 ``` Dec 1, 2019
removed the label Dec 1, 2019

### maralorn commented Dec 1, 2019

 Wow. That was quick!