Skip to content
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

Extra Cent on Tax Inclusive Calculation / Banker's Rounding #469

Open
fahimalizain opened this issue Mar 5, 2024 · 1 comment
Open

Extra Cent on Tax Inclusive Calculation / Banker's Rounding #469

fahimalizain opened this issue Mar 5, 2024 · 1 comment

Comments

@fahimalizain
Copy link

fahimalizain commented Mar 5, 2024

Please consider an Item that costs $40 with inclusive tax of 5%. When we break this into SubTotal, TaxAmount and GrandTotal, the following is what we get:

- SubTotal = 40 - (40 * 5 / (100 + 5)) = 38.0952.. = $38.10
- Tax Amount = 38.1 * 5 / 100 = 1.905 = $1.91
- Grand Total = 38.10 + 1.91 = $40.01                                    <-- Extra 0.01 Cent

The expectation is that Bankers Rounding / Round to Nearest, Ties to Even will fix this issue?

@jameswtc
Copy link

Use higher precision when doing the multiplication / division.

The following should give you the same grand total. But yeah, the package is missing the Bankers Rounding. However, tax is only rounded when filing the tax report. $1.91 is what you see on the tax invoice.

const total = currency(40, {precision: 4});
const subtotal = total.divide(1.05)
const tax = subtotal.multiply(0.05)

console.log(subtotal.value, ' -> ', currency(subtotal, { precision: 2 }).value)
console.log(tax.value, ' -> ', currency(tax, subtotal).value)
console.log(subtotal.add(tax).value)```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants