hledger/tests
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
..
add reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
addons reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
balance balance: fix partially-visible totals row 2014-12-27 16:46:37 -08:00
cli make --width and --debug require an argument (fixes #149) 2014-07-03 07:31:52 -07:00
csv reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
journal forgot to commit status tests 2015-05-16 13:04:22 -07:00
misc print: limit display precision of generated prices (#262) 2015-05-27 14:21:19 -07:00
nonascii reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
print reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
register register: support date:/date2:/--date2 better (fix #201, #221, #222) 2014-12-24 16:11:30 -08:00
stats reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
timelog timelog: support the description field (fix #247) 2015-04-28 13:54:36 -07:00
bench.tests tools: bench test update 2015-03-15 18:51:14 -07:00