books
books copied to clipboard
bug: incorrect rounding of JPY amounts
Description
While working with JPY, I encountered an issue related to incorrect rounding of amounts. I've traced the problem, which appears to be related to how the system handles precision.
Expected behavior: 123.99 should be rounded down to 123 Current behavior: 123.99 rounded up to 124
JPY typically has no decimals, the minimal denominator is 1, and amounts with decimals are typically rounded down to the nearest whole yen.
Setting Display Precision does help hide decimals but does not resolve the incorrect amount.
It might have something to do with countryInfo.json
and internalPrecision
fields on the SystemSettings
schema. I haven't figured out how to fix it yet. Changing currency_fraction
and currency_fraction_units
in the countryInfo.json
doesn't seem to do anything, even after creating a new Organization to instantiate a new DB. Tinkering with internalPrecision
didn't help it either.
Steps to Reproduce
- Use JPY as the system's currency
- Create Tax: in my case, it's a 10% Consumption Tax
- Create a Sales Item with the rate that would end up with >= .5 decimal when applying your Tax Rate
- Start creating a Sales Invoice. Select the Sales Item, and you'll see that the amount is rounded up
Info
Version: 0.19.0
Platform: darwin
Path: /edit/SalesInvoice/New Sales Invoice 01
Language: -
Country: jp
The money library under the hood is : https://github.com/frappe/pesa
internalPrecision
maps to pesa precision
parameter, and displayPrecision
maps to display
in https://github.com/frappe/pesa#options-and-value
I would believe that setting internalPrecision to 0 should work
What if you open your book file with sqlite and try to update the settings like this
update SingleValue set value = 0 where (parent, fieldname) = ('SystemSettings', 'displayPrecision');
update SingleValue set value = 0 where (parent, fieldname) = ('SystemSettings', 'internalPrecision');
then reopen it in Books?
Always work on backup copies.
Apparently for tax calculation, the calculation is performed over integers with no decimals: https://docs.oracle.com/en/applications/jd-edwards/localizations/9.2/eoajp/what-you-should-know-about-tax-rounding-in-japan.html#u30184160
I since moved on and no longer have the app nor records. Maybe updating values in the DB would help, but I'd imagine this isn't something most users would do themselves.