Page 2 of 2
Re: Problem with total calculation and rounded prices
Posted: Mon Aug 18, 2014 3:41 am
by SXGuy
System -> Localization -> Currencies. Set your default currency to 1.00000000
Opencart allows for 8 decimal places as far as I can see.
By using 8 decimal places, you will limit rounding issues to very very rare orders.
If you can show me, where the law says you must use 4 decimal places, then i'll stand corrected.
In the UK, our government (HMRC) allows for rounding issues, because they understand, you can not round down every gross price to a whole number.
Its very unlikely, your government doesn't understand the same thing.
Your only issue, is the customer paying what he/she believes to be the price, and not finding the actual total differs. Therefore you if use the most amount of decimal places you will be fine.
Remember, you are rounding DOWN from price inc tax, to price ex tax to enter it in to opencart product
22 less 21% tax = 18.18181818181818 or for opencarts sake, 18.18181818 either way, when added multiple times, will still equal the correct amount
22 x 2 = 44. (18.18181818 x2 = 36.36363636 + 21% = 43.9999999956 or 44)
Or have I missed something here?
Re: Problem with total calculation and rounded prices
Posted: Mon Aug 18, 2014 7:03 am
by fabrizio
I have already set 1.00000000 in the currency (€).
The law ( Italy ) say that in the invoice you must write numbers with 2 decimals, rounded down 1c if the third decimals is <5 or rounded up 1c if the third decimals is >/= 5.
In the shop i set the prices with 4 decimals, why this?...as i wrote if i set 2 decimals in the cart i have a price and in the Total /sub-total ( no vat ) i have different numbers and this create a confusion in the customer. Orders are always hundreds and thousands of items!!!..i'm not talking about 1c of difference but much more.
This is the issue and for this i have the prices with vat with for decimals and the math is correct in the cart/totals...but i have to edit the invoice ( Sub-total, total, Iva, shipping cost mus be 2 decimals!) and i cannot use Paypal module----it's complicated but i have no choice.
I tried that module, with prices included vat in admin, but the problem is still there..i have tried other modules but no way to have the same number in the cart and in the Totals. Maybe with a low number of items it works.
I have understood that the problem is that OC calculate the Tax ( Vat/IVA ) on a not rounded number...instead it would be better to round the price first and then apply the Vat..this way i think all would be fine.
Re: Problem with total calculation and rounded prices
Posted: Fri Sep 26, 2014 5:51 pm
by takahashi1973
Posted this VAT + Round logic problem in Github OC 2.0 development.
Daniel responded quickly by saying it is a know issue and should be solved in OC 2.0
I posted some fixes which rougly/for most shops would work but it is not a 100% solution unfortunately.
In NL B2C shops should show all total values incl. vat so I know what headache this logic causes.
Re: Problem with total calculation and rounded prices
Posted: Mon Dec 08, 2014 4:48 pm
by light25
Why can't we just set the the column decimal places to 2
Re: Problem with total calculation and rounded prices
Posted: Fri Mar 06, 2015 3:50 pm
by roadrunner
Hello there,
Any updates about this after trying oc 2.0.*.*?
Re: Problem with total calculation and rounded prices
Posted: Sun May 31, 2015 8:09 pm
by froschgift
This problems exists in OC 2.0.3.1 !!
I tried to open a thread about it in the Bug Report forums for OC 2 but it seems my thread won't be approved to show up...
This needs to be fixed because this way it's useless in germany!
Take a look at the attached screenshot to see the problem
Re: Problem with total calculation and rounded prices
Posted: Tue Jun 02, 2015 11:08 pm
by fabrizio
Hi Froschgift,
i have already lost my hope on this issue, i was forced to switch to another platform because as you say in Europe OC is useless. The math only works if you have no decimals in admin product prices....45..100 etc etc..if you put 40,99€ you have the problem in the cart with wrong calculation...I tried everything as to introduce product prices already with VAT in admin but nothing works. The only solution is to show 4 decimals, and you have the right math but you cannot usePayPal..Good luck.
Fabrizio
Re: Problem with total calculation and rounded prices
Posted: Mon Jun 15, 2015 8:55 pm
by trueliar
same problem. Even if we have developed several things on opencart we have moved new shops to other cart systems.
Re: Problem with total calculation and rounded prices
Posted: Thu Aug 13, 2015 3:44 pm
by davidbfranks
Same issue here, I cannot believe this has not been fixed in OC2
Re: Problem with total calculation and rounded prices
Posted: Tue Nov 03, 2015 4:56 pm
by micrdy
Same issue here. Has somebody found a fix for this?
Re: Problem with total calculation and rounded prices
Posted: Tue Apr 26, 2016 11:32 pm
by michaelsen
Most of us display the price to our customers with 2 decimals, so why work with 4 decimals in the database?
The price field in the oc_product and oc_product_discount has 4 decimals. I haven't done it yet, but I think it will fix the problem if we changed that to 2.
Re: Problem with total calculation and rounded prices
Posted: Sat May 07, 2016 10:20 pm
by OneManShow
Same issue here.
It is really embarrassing for me, recently won the deal for 4 OpenCart installations, I've just found about this issue... I am not sure how to get this solved properly... please post here if you find out.
An extension that does the job would be fine as well...
Thakns!
Re: Problem with total calculation and rounded prices
Posted: Sat May 07, 2016 10:47 pm
by OneManShow
Well,
Now, I am a little bit confused with what I was doing just couple of minutes earlier and why it seemed an issue.
It looks like this issue is solved for me... I have the total amount (NET + VAT) of 19,00, I've just started to calculate VAT from the total amount with 4 decimals, entered into the price field the amount before VAT and it looks fine... of course...user does not see 4 decimals on the website, just h2.
Regards,
Re: Problem with total calculation and rounded prices
Posted: Wed Nov 02, 2016 2:04 am
by DaCrash
Hello, the problem is still not solved.
48 x 18.92 = 908,21

?? Every german accounting office is screaming if they see someting like that....
I should had take another shop system....
Any Ideas?
Re: Problem with total calculation and rounded prices
Posted: Wed Nov 02, 2016 9:13 am
by IP_CAM
Move to Switzerland, we don't even bother with such small Values, either, it 19.95, or then 20.00 !
Just joking, but in our Currency, 1+ 2 Cent pieces of money really dont exist anymore...
Ernie
Re: Problem with total calculation and rounded prices
Posted: Tue Nov 08, 2016 7:21 pm
by ADD Creative
DaCrash wrote:Hello, the problem is still not solved.
48 x 18.92 = 908,21

?? Every german accounting office is screaming if they see someting like that....
I should had take another shop system....
Any Ideas?
A work around is to set the excluding tax price to something that will be closer to 2 decimal places value shown including tax.
So instead of a price of 15.9000 which is (15.9000 * 1.19) 18.9210 including tax.
Set the price to 15.8892 which is (15.8992 * 1.19) 18.920048 including tax.
However you will always see these issues at some point.
Other than that you would need to make a lot of changes to the code to combine the tax calculation with the currency conversion so the individual price was always calculated to the correct amount decimal places.
Re: Problem with total calculation and rounded prices
Posted: Sat May 09, 2020 1:56 am
by Frances
ADD Creative wrote: ↑Tue Nov 08, 2016 7:21 pm
DaCrash wrote:Hello, the problem is still not solved.
48 x 18.92 = 908,21

?? Every german accounting office is screaming if they see someting like that....
I should had take another shop system....
Any Ideas?
A work around is to set the excluding tax price to something that will be closer to 2 decimal places value shown including tax.
So instead of a price of 15.9000 which is (15.9000 * 1.19) 18.9210 including tax.
Set the price to 15.8892 which is (15.8992 * 1.19) 18.920048 including tax.
However you will always see these issues at some point.
Other than that you would need to make a lot of changes to the code to combine the tax calculation with the currency conversion so the individual price was always calculated to the correct amount decimal places.
Thank you for this workaround, it's a perfect solution for my website A pain in the butt, but it works

Re: Problem with total calculation and rounded prices
Posted: Mon May 11, 2020 4:19 am
by victorj
Same problem here.
It even gets worde when large numbers are ordered.
Solved it by storing product price ex tax with 8 decimals in database.
used phpmyadmin to alter product price, set decimals to 8 and altered product template so 8 decimals can be used.
Re: Problem with total calculation and rounded prices
Posted: Wed Jan 06, 2021 7:10 pm
by MB242
victorj wrote: ↑Mon May 11, 2020 4:19 am
Solved it by storing product price ex tax with 8 decimals in database.
used phpmyadmin to alter product price, set decimals to 8 and altered product template so 8 decimals can be used.
Hello victorj,
I have exactly the same problem. Can you please share product template modifications? I could not find the right file...
Thank you.
Re: Problem with total calculation and rounded prices
Posted: Wed Jan 06, 2021 7:52 pm
by victorj
you need to change that in your database only.