-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ledger needs support for rounding (BZ#992) #992
Comments
Comment author: Bradley M. Kuhn (@bkuhn) This fails: with: This works: 2013-11-18 Test as does this: 2013-11-18 test2 But merged together: 2013-11-18 Test I get: What gives? |
Comment author: Tripun (@tripun) Created attachment 96 Round off occur when the amount of commodity in a transaction has less precision than the calculation involved. with: ============== ===================== 2013-11-18 test2 " =====================================
|
Comment author: Tripun (@tripun) " After conversion balance is $0.008(approx), the reporting precision is 2 digits since the amounts(quantity) involved have maximum of 2 digit precision. After round off the balance is $0.01 and hence there is unbalanced amount and the test fails. |
Comment author: John Wiegley (@jwiegley) Bradley, you have a point that if the @ version works, the {=} version should |
Comment author: Martin Michlmayr (@tbm) I'm changing this to an enhancement request: ledger needs support for rounding. As Tripun pointed out, there is no bug as such. It's just that ledger keeps a lot of precision internally and this can lead to errors. In most cases, we want to round to 2 digits. There should be a way for ledger to do such rounding. |
Comment author: Martin Michlmayr (@tbm) (In reply to comment #2)
Yes, and you can see this if you put the following in the file: D $1000.000 Unbalanced remainder is: |
Comment author: Martin Michlmayr (@tbm) So here's an interesting example which shows that you can get different results to what you'd expect because of ledger keeping so much precision. Using a lot of precision using figures like @ $1.3762 gives us: 2014-01-01 * Expense in EUR 2014-02-01 * Person paid 4338.00 CZK, not 154.90 EUR Note that Expenses:Currency is $4.85. But now let's use amounts rounded to 2 digits: 2014-01-01 * Expense in EUR 2014-02-01 * Person paid 4338.00 CZK, not 154.90 EUR Now Expenses:Currency is $4.86. Why the difference? With full precision: 154.90 * 1.3762 = 213.17338 4.8545, which is rounded to 4.85 at display precision 2. On the other hand, using the amounts that were rounded to 2 digits fo precision: 213.17 - 218.03 = -4.86 Obviously, both solutions are correct. But there should be a way to specify a rounding precision, so you can have the first example (i.e. exchange amounts specified as @ $1.3762) and still get an Expenses:Currency of $4.86. |
Note: the issue was created automatically with bugzilla2github
Bugzilla bug ID: BZ#992
From: Bradley M. Kuhn (@bkuhn)
CC: @aleksejrs, @jwiegley, @tbm, @thdox, @tripun
The text was updated successfully, but these errors were encountered: