On Tue, Oct 7, 2014 at 4:23 PM, Simon Michael <[email protected]> wrote:

> 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).
>

That's great. IMO it's a bad idea to change whatever value is derived as
the system parses the file. Ordering should never matter, even for
precision or formatting.


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
>

What do you do about the display precision when you have a mix of
transactions with differing precisions?



On Tue, Oct 7, 2014 at 4:37 PM, Simon Michael <[email protected]> wrote:

> I'm not following this interesting discussion in every detail, so I'm not
> sure if this can help any part of this problem space, but just in case:
> Have you considered or already implemented hledger's approach for balancing
> transactions, which is based on display precision ? Ie amounts are
> considered to balance if their sum appears to be zero when it's rendered
> using the canonical display precision. This seems to fit user expectations
> well.
>

How do you define the canonical display precision?
You mean the precision derived from the legs that have a simple explicit
amount?

-- 

--- 
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.

Reply via email to