edwintorok · GitHub

hledger 1.18.1 on Fedora 33:

$ cat >f.csv <<EOF
12/31/2018,21.058,$256.1300
EOF
$ cat >f.rules <<EOF
fields date, quantity, price
date-format %m/%d/%Y
amount1 0
balance %quantity @ %price
EOF
$ hledger print --rules-file f.rules --file f.csv
2018-12-31
    expenses:unknown               0 = 21 @ $256.1300

I've ommited the 'currency' statement for a minimal example, in my actual example I have a currency1 STOCKSYMBOL, reproduces both ways.

There is some documentation here on how the display style is guessed
https://hledger.org/hledger.html#commodity-display-style

However it is very unexpected that one commodity has no decimals guessed, and the other one has 4
(and this will lead to a balance assertion failure further down the line because the 21.058 is the correct value).
There is no way to specify a 'commodity' in a rules file, so have to rely on hledger guessing.

If I modify amount1 0 to amount1 0.000 then I get the correct result, this was very unexpected. Perhaps hledger should print a warning if it ever does truncation on a line that has values with larger number of decimals?
FWIW -O json has the correct amount printed.

I only added amount1 0 because without it balance assertions wouldn't work.

Read the original on github.com ↗