### Re: Problem with total calculation and rounded prices

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?

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

### Re: Problem with total calculation and rounded prices

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.

Newbie

Posts

Joined
Thu Apr 04, 2013 1:06 am

### Re: Problem with total calculation and rounded prices

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.

Active Member

Posts

Joined
Thu Oct 13, 2011 11:41 pm

### Re: Problem with total calculation and rounded prices

Why can't we just set the the column decimal places to 2

Newbie

Posts

Joined
Wed Dec 03, 2014 3:54 pm

### Re: Problem with total calculation and rounded prices

Hello there,

Newbie

Posts

Joined
Thu May 29, 2014 2:02 pm

### Re: Problem with total calculation and rounded prices

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

#### Attachments

Screen Shot 2015-05-29 at 22.22.56.png (177.33 KiB) Viewed 6807 times

Newbie

Posts

Joined
Sat May 30, 2015 4:16 am

### Re: Problem with total calculation and rounded prices

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

Newbie

Posts

Joined
Thu Apr 04, 2013 1:06 am

### Re: Problem with total calculation and rounded prices

same problem. Even if we have developed several things on opencart we have moved new shops to other cart systems.

New member

Posts

Joined
Sat Jan 11, 2014 12:09 am

### Re: Problem with total calculation and rounded prices

Same issue here, I cannot believe this has not been fixed in OC2

Active Member

Posts

Joined
Mon Mar 04, 2013 10:31 pm
Location - London

### Re: Problem with total calculation and rounded prices

Same issue here. Has somebody found a fix for this?

New member

Posts

Joined
Mon Mar 09, 2015 6:40 pm

### Re: Problem with total calculation and rounded prices

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.

New member

Posts

Joined
Tue May 03, 2011 3:17 am

### Re: Problem with total calculation and rounded prices

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!

Newbie

Posts

Joined
Sun Sep 29, 2013 10:35 pm

### Re: Problem with total calculation and rounded prices

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,

Newbie

Posts

Joined
Sun Sep 29, 2013 10:35 pm

### Re: Problem with total calculation and rounded prices

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?

#### Attachments

2016-11-01 16_13_49-Aufträge.png (9.08 KiB) Viewed 5175 times

DG-Webservices- Webdesign und Programmierung aus Friesland

New member

Posts

Joined
Mon Feb 22, 2010 8:02 pm
Location - Germany

### Re: Problem with total calculation and rounded prices

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

Please don't send me OC Forum Personal Messages, just contact: jti@jacob.ch
---
OC 1.5.6.5 LIGHT Test Site: http://www.bigmax.ch/shop/
OC 1.5.6.5 V-PRO Test Site: http://www.jacob.ch/shop/
My Github OC Site: https://github.com/IP-CAM
2'450+ FREE OC Extensions from the World's largest Github OC Repository Archive Site.

Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

### Re: Problem with total calculation and rounded prices

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.

Active Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

### Re: Problem with total calculation and rounded prices

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

Newbie

Posts

Joined
Sun Mar 04, 2018 3:21 am

### Re: Problem with total calculation and rounded prices

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.

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Alle niet stekplichtige onderdelen zoals scharnieren, sloten, randverwarming en verlichting voor alle typen koelingen en vriezers.
https://koelcel-onderdelen.com

Expert Member

Posts

Joined
Sat Jun 25, 2011 4:09 am
Location - Alkmaar Holland
Who is online

Users browsing this forum: No registered users and 9 guests