hledger/hledger-lib/Hledger/Data
Simon Michael 8d75635505 print: limit display precision of generated prices (#262)
When a transaction posts to two commodities without specifying the
conversion price, we generate a price which makes it balance
(cf http://hledger.org/manual.html#prices).

Until now, these generated prices were always shown with full precision
(all available decimal digits) so that a manual calculation with the
displayed numbers would agree.

If there's just one posting in the commodity being priced, we can use an
exact total price and the precision is no problem.

But if there are multiple postings in the commodity being priced, we
must show the averaged unit price. This can be an irrational number,
which with our current Decimal-based implementation would display an
excessive 255 decimal digits. So in this case we now set the price's
display precision to the sum of the (max) display precisions of the
commodities involved. An example:

hledgerdev -f- print
<<<
1/1
    c    C 10.00
    c    C 11.00
    d  D -320.00
>>>
2015/01/01
    c  C 10.00 @ D 15.2381
    c  C 11.00 @ D 15.2381
    d     D -320.00

>>>=0

There might still be cases where this will show more price decimal
places than necessary. For now, YAGNI.
2015-05-27 14:21:19 -07:00
..
Account.hs balance, register, register-csv: depth 0 shows summary items (#206) 2014-10-19 17:53:20 -07:00
AccountName.hs balance, register, register-csv: depth 0 shows summary items (#206) 2014-10-19 17:53:20 -07:00
Amount.hs timelog: show hours with 2 decimal places, not 1 2015-02-27 08:37:16 -08:00
Commodity.hs strip trailing whitespace from all Haskell files 2014-10-14 18:48:24 -07:00
Dates.hs hledger-lib: Update for base-compat-0.8.0 (see #245) 2015-04-23 15:41:59 +08:00
Journal.hs handle pending status correctly, add --pending (#250) 2015-05-16 11:51:35 -07:00
Ledger.hs refactor amount filtering helpers 2014-05-23 13:10:36 -07:00
OutputFormat.hs hledger-lib: Update for base-compat-0.8.0 (see #245) 2015-04-23 15:41:59 +08:00
Posting.hs tighten up status:X parsing, cleanups 2015-05-16 12:21:50 -07:00
RawOptions.hs cli: with a repeated flag, the last takes precedence 2014-12-04 12:41:47 -08:00
TimeLog.hs handle pending status correctly, add --pending (#250) 2015-05-16 11:51:35 -07:00
Transaction.hs print: limit display precision of generated prices (#262) 2015-05-27 14:21:19 -07:00
Types.hs handle pending status correctly, add --pending (#250) 2015-05-16 11:51:35 -07:00