simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
3.07k stars 320 forks source link

prices should always show market prices with all decimal places #1107

Closed simonmichael closed 5 years ago

simonmichael commented 5 years ago

A confusing bug that bit me several times: if you had a commodity directive limiting a commodity's precision, say to two decimal places, that would also affect the output of the prices command. Now prices shows market prices (whether declared by P directives or inferred from --costs/--inverted-costs)

  1. with all decimal places and
  2. otherwise with the appropriate commodity style.
psb777 commented 4 years ago

This issue is marked "closed" and so therefore seems to be rejected. But the bug still exists (in version 1.14 at least) If I set a price thusly P 2020/01/16 ZAR 0.0533172 then this price is correctly used in hledger and an amount 10,000 ZAR is shown with -V value 533.17 However the prices report incorrectly shows the price like this P 2020/1/16 ZAR 0.05 The commodity format is used but it should not be! This is a price, and all digits are significant. The prices report is essentially deeply flawed if not useless while this bug exists.

simonmichael commented 4 years ago

Hi @psb777, I can't reproduce this with latest or 1.14. Could you show a reproducible example.

psb777 commented 4 years ago

Sorry @simonmichael, this shortest of examples makes the point rather well :-)

$ cat x.ledger              
commodity 1,000,000.
P 2020/01/16 XRP 0.17474
$ 
$ hledger -f x.ledger prices
P 2020-01-16 XRP 0
simonmichael commented 4 years ago

Ah there it is, thanks. Indeed the bug was still in 1.14, it was fixed by 1.16: https://hledger.org/release-notes.html#hledger-cli-1-16.