Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Incorrect rounding of decimal places in final price #695
Commerce incorrectly adds 1-2c to our order total even though it shouldn't.
Steps to reproduce
This is a very big issue for us. We are essentially overcharging clients 2c that we would need to refund leading to much more complications.
Your adjustments and line item totals seem to be correct in the screenshots. That makes me wonder if
Recommend testing to see what the number is before and after it gets passed through that method.
Edit: It is the price for each line item being rounded causing this issue.
With the help of @ccchapman I was able to track down the bug.
salePrice is saved as a rounded value in the database before the tax adjuster gets a chance to produce a correct value. Rounding should be the last step not the first one.
If you change the line from
price field in database: 12.4170
FWIW, the currency helper is rounding to two places for Euro per ISO 4217.
This issue aside, should purchasables even be allowed to have a price with decimals that differ from the standard they'll be rounded to? This seems misleading to show a currency with three decimal points in the CP when it will be rounded for line items.
Yes you absolutely should be able to have prices with higher accuracy. We designed our prices in a way that they are mostly round numbers after tax has been applied. We'd still like to keep them without tax in the cms.
I understand that they need to be rounded once you send them to a payment gateway, but why round them before adjusters can be applied to them?
Or at least there should be an option to disable premature rounding if it's not a desired behavior