Thanks Martin for this proposal, as you know I've been bitten by this
and I'm looking forward to a proper solution.
On Mon, Jun 23, 2014 at 06:06:08PM -0400, Martin Michlmayr wrote:
> One final example: you buy 123 shares for 1.23456 each and later sell
> them for 2.345 each. So first of all, how much money do you get?
> 123*2.345 = 288.435. But do you really get that amount? No, you get
> 288.44 if you're lucky (or 288.43 if you're not).
>
> And how much capital gain was there? Again, the maths is simple:
> 123*(2.345-1.23456) = 136.58412
Eh, thanks for glorifying my IRC example :), I'm glad it has been
useful.
> Possible solution
> -----------------
>
> We could have a "commodity" directive called "precision" (or something
> similar):
>
> commodity EUR
> precision 2
I agree with both Martin-s that this is not enough, at the very least
precision should also be customizable at the account level. However, if
we have precision associated to both commodities and accounts, how would
they interact? Account might contain multiple commodities; would
specifying a precision for an account mean that all commodities
contained therein must have the same precision?
Sounds like we might need the ability to specify:
- a default commodity precision
- a default account precision
(with rules deciding who wins among these two)
- a specific precision for commodity/account pairs
> While precision is probably the same for one currency regardless of
> the account
I don't think that's necessarily the case. Either way, this seems to be
an arbitrary restriction to impose, and I'm unsure what it'd give us in
terms of simplicity of the flexible rounding model / design.
> Open questions
> --------------
>
> * Do we actually need to specify the precision? After all, ledger
> keeps track of the precision you use in your input data (and by
> default uses that for the display precision). Maybe we should just
> use that precision as the precision for rounding if rounding is
> enabled.
This is somewhat tangential to your question, but we do need a way to
specify the *display* precision, more flexible than what we have
now. Your initial example using D works in restricting the output
precision for lot prices, but AFAICT D doesn't work in restricting the
display precision for simple postings, e.g.:
zack@timira:~$ cat test-rounding.ledger
D 10.00 EUR
2014-01-01 Foo
Assets:Cash 10.1234 EUR
Income
zack@timira:~$ ledger -f test-rounding.ledger bal
10.1234 EUR Assets:Cash
-10.1234 EUR Income
--------------------
0
> * If we do implement a "precision" directive and someone says
> "precision 2", what would happen if someone then wrote a value like
> 10.123. Should this be rejected or should it override precision?
This is probably me thinking as a programmer :), but I don't see much
value in rejecting the posting. Just let the user write it down and
override the precision.
> * Does rounding only happen after the decimal point or are there
> currencies where 600 would be rounded to 1000? (I'm thinking of
> currencies where one million or billion is worth $1 or so). The
> proposal assumes that rounding only happens after the decimal point
> but maybe this assumption is wrong.
This would be easy to support, e.g. you can say that "precision -N"
rounds to digits *before* the decimal, rather than after it. (But this
won't solve weirder rounding issues.)
Cheers.
--
Stefano Zacchiroli . . . . . . . [email protected] . . . . o . . . o . o
Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o
Former Debian Project Leader . . @zack on identi.ca . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »
--
---
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.