On 10/7/14 10:03 AM, Nathan Grigg wrote:
I wonder if inferring like Ledger works in all cases though;
consider this case:
Assets:Fidelity:Fund 11.27534 FUND {1.2357 USD}
Assets:Fidelity:Cash -13.93 USD
The precise cash amount is 13.932937638 USD.
How many digits should this use?
Ledger would infer 2 digits of precision for USD and 5 for FUND.
The price portion does not affect precision. Ledger also has a D
directive to specify the minimum precision per currency.
I'm not sure what that means... there is no need for any precision on
units of FUND, the balance amount of that leg is in USD calculated as
11.27534 x 1.2357. In USD. The balance residual is 11.27534 x 1.2357 +
-13.93. The only precision that matters is that of USD.
Does it use the precision inferred on units of FUND in any way?
If so, how?
In Ledger, the precision is not per-transaction, but file-wide. (Because
Ledger process the file in one pass, this means that the precision may
increase, but never decrease, as it processes the file.) So Ledger would
infer from this posting that FUND should always be measured and
displayed to 5 digits of precision (or at least from now on).
More data points for this intricate topic. hledger's per-commodity
display precisions are also file-wide, but here are some differences
from Ledger:
1 the whole file is processed first, then the precisions are selected.
So a high-precision amount at the end can set the precision for all
(actually, isn't that true for Ledger too ? My testing says yes).
2 the D directive itself does not influence the precision, but
hledger applies the D commodity to any commodity-less amounts,
in which case that adjusted amount will influence the precision
(see example at http://hledger.org/manual#default-commodity).
3 price amounts do not influence the precision, like Ledger... but they
can be used to balance an amountless posting, and that amount does
get displayed with the price's original full precision. This is how
hledger does better in your "Weird things happening" case 1:
D 1.00 USD
2014-01-01 Test
assets 1 CAD @ 1.005 USD
liabilities
2014-01-02 Test
assets 1 CAD @ 1.005 USD
liabilities
$ hledger -f tt.j reg liabilities -w66
2014/01/01 Test liabilities -1.005 USD -1.005 USD
2014/01/02 Test liabilities -1.005 USD -2.010 USD
But I see it still does not influence the canonical precision in
this case, which looks weird and should probably be fixed:
D 1.00 USD
2014-01-01 Test
assets 1 CAD @ 1.00500 USD
liabilities
2014-01-02 Test
assets 1 CAD @ 1.005 USD
liabilities
$ hledger -f tt.j reg liabilities -w66
2014/01/01 Test liabilities -1.00500 USD -1.00500 USD
2014/01/02 Test liabilities -1.005 USD -2.01000 USD
Fun, eh. :)
--
---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.