Post by dydyt » Fri Jan 04, 2013 7:53 pm

This is Opencart offical demo site and i found the bug:

Image

And of course, i have the same problem!

Now i working to fix it .. if you know how, please tell us!

Newbie

Posts

Joined
Wed Oct 17, 2012 3:28 am

Post by SXGuy » Fri Jan 04, 2013 9:54 pm

no bug, check the tax thats applied.

eco tax - 2.00% plus 17.5%

:) if it didnt have eco tax, it would calculate correctly.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by dydyt » Fri Jan 04, 2013 10:31 pm

Emm .. nope, it calculate without tax incorrectly. I set my store prices without tax and anyway total price show incorrectly.

Newbie

Posts

Joined
Wed Oct 17, 2012 3:28 am

Post by Qphoria » Sat Jan 05, 2013 2:52 am

its because of rounding.

The real underlying price is likely 236.9883
it gets rounded to 236.99, but the math is done on the raw price.

100 * 236.9883 = 23698.83

It is a known issue in OpenCart that causes price match problems with paypal as well... tho I've not seen any expressed interest by Daniel to fix it.

Other topics:
http://forum.opencart.com/viewtopic.php?t=36916
http://forum.opencart.com/viewtopic.php?t=51687
http://forum.opencart.com/viewtopic.php?t=37837

Perhaps the fix can be made in the currency format function to round to 2 after currency exchange conversion, before the rest of the math. I'll have to look at it.

IIRC, It only happens for people with other currencies when other non-default currencies are in use.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by rph » Sat Jan 05, 2013 4:47 am

((quantity * price) * VAT) + (quantity * flat fee tax) = total price
((100 * 199.99) * 1.175) + (100 * 2) = 23698.825 = 23698.83

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by victorj » Thu Jan 10, 2013 5:11 am

It simply is a calulating and roundig problem.
om most shops it is of no importance at all since only low volumes are bought and saleprice excl tax is calculated from price incl tax

problem starts when high volume of single products are purchased.
solution is pretty simple make it so oc can do the math correct.

now product price in admin is rounded at max 4 decimals wich is not enough for large numbers so it has to be 7 or 8 decimals

solution:

it can be changed with phpmyadmin

open your database an look for table products.

alter table price and change 15,4 in 15,7 (7 decimals)
now the price can have 7 decimals

now dont be lazy but input all decimals or for better living use the vqmod from uksitebuilder listed in this topic
http://forum.opencart.com/viewtopic.php?f=10&t=81408

it has to be altered to your needs and number of decimals

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


User avatar
Expert Member

Posts

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

Post by Daniel » Thu Jan 10, 2013 8:50 am

just updated all prices from decimal(15,4) to decimal(15,8).

really not sure if this is going to cause errors though.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by rph » Sat Jan 12, 2013 3:31 pm

victorj wrote:It simply is a calulating and roundig problem.
Where are you getting that from? It's perfectly accurate. Look at the calculations I posted.

The only issue would be the number of digits used to display the price with VAT which users can control if they really want.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by rph » Sat Jan 12, 2013 3:33 pm

Daniel wrote:just updated all prices from decimal(15,4) to decimal(15,8).

really not sure if this is going to cause errors though.
I don't see how this helps. It just makes prices in Admin a huge unwieldy mess.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by blurb » Sat Jan 12, 2013 6:27 pm

In Admin - Products - [item] - Data ....

Price: 2500.0000 [ I gave up changing this to what it should be 2500.00 - keeps adding extra two 00's when Save is clicked ]

Tax Class: None

No discount applied nor is the item on Special.

Shopfront

The Item shows as having a price of $2,091.25 ???

Have problems with others product prices as well

ie - product item - Price: 900.0000 [ I gave up changing this to what it should be 900.00 - keeps adding extra two 00's when Save is clicked ]

Tax Class: None

In the Special tab, I have this product on Special for 500.0000 [ I gave up changing this to what it should be 500.00 - keeps adding extra two 00's when Save is clicked ]

Shopfront

The Item shows two prices $752.85 $418.25 ???

Do I need to place an , (comma) between the 2 and 5 ie 2,500.00 or is there a bug in the system that is causing this.

Have a great day everyone :)


User avatar
New member

Posts

Joined
Fri Jan 11, 2013 3:52 pm
Location - New Zealand

Post by Qphoria » Sat Jan 12, 2013 11:25 pm

rph wrote:
victorj wrote:It simply is a calulating and roundig problem.
Where are you getting that from? It's perfectly accurate. Look at the calculations I posted.

The only issue would be the number of digits used to display the price with VAT which users can control if they really want.
It is accurate except that the conversion from 4 precision to 2 is the problem. I think part of it comes down to the way all prices are calculated first, then after all math is done, it coverts the final price.

So for example, if you have 2 currencies USD and EUR
USD is 1.000000000
EUR is 0.783637682

The product is 100
option +2.10
discount -1.25
= 100.85
converted to EUR is: (100.85 * 0.783637682) = 79.0298602297
rounded to 2 is 79.03

But if you converted each price first, before the math:
product is (100 * 0.783637682) = 78.3637682
option +(2.10 * 0.783637682) = 1.6456391322
discount is (-1.25 * 0.783637682) = 0.9795471025
Total = 80.9889544347
rounded to 2 is 80.99

Which is more correct?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by blurb » Sun Jan 13, 2013 1:15 am

blurb wrote:In Admin - Products - [item] - Data ....

Price: 2500.0000 [ I gave up changing this to what it should be 2500.00 - keeps adding extra two 00's when Save is clicked ]

Tax Class: None

No discount applied nor is the item on Special.

Shopfront

The Item shows as having a price of $2,091.25 ???

Have problems with others product prices as well

ie - product item - Price: 900.0000 [ I gave up changing this to what it should be 900.00 - keeps adding extra two 00's when Save is clicked ]

Tax Class: None

In the Special tab, I have this product on Special for 500.0000 [ I gave up changing this to what it should be 500.00 - keeps adding extra two 00's when Save is clicked ]

Shopfront

The Item shows two prices $752.85 $418.25 ???

Do I need to place an , (comma) between the 2 and 5 ie 2,500.00 or is there a bug in the system that is causing this.
Issue Resolved

When I was setting up the store I removed all countries except NZ and USA

After pulling all my hair out over the last couple of days I thought I would get rid of the USA currency

This fixed the issue for my store

I'm starting to love opencart again

Have a nice day folks

Have a great day everyone :)


User avatar
New member

Posts

Joined
Fri Jan 11, 2013 3:52 pm
Location - New Zealand

Post by rph » Sun Jan 13, 2013 5:53 am

Qphoria wrote:
rph wrote:
victorj wrote:It simply is a calulating and roundig problem.
Where are you getting that from? It's perfectly accurate. Look at the calculations I posted.

The only issue would be the number of digits used to display the price with VAT which users can control if they really want.
It is accurate except that the conversion from 4 precision to 2 is the problem. I think part of it comes down to the way all prices are calculated first, then after all math is done, it coverts the final price.

So for example, if you have 2 currencies USD and EUR
USD is 1.000000000
EUR is 0.783637682

The product is 100
option +2.10
discount -1.25
= 100.85
converted to EUR is: (100.85 * 0.783637682) = 79.0298602297
rounded to 2 is 79.03

But if you converted each price first, before the math:
product is (100 * 0.783637682) = 78.3637682
option +(2.10 * 0.783637682) = 1.6456391322
discount is (-1.25 * 0.783637682) = 0.9795471025
Total = 80.9889544347
rounded to 2 is 80.99

Which is more correct?
Definitely not the second one since you added the discount instead of subtracting it. :P

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by Qphoria » Sun Jan 13, 2013 9:40 am

rph wrote: Definitely not the second one since you added the discount instead of subtracting it. :P
LOL shit.. anyway the calculation in this case worked out the same anyway.. I had some working calculation example but can't remember it.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Daniel » Mon Jan 14, 2013 8:54 pm

blurb wrote:In Admin - Products - [item] - Data ....

Price: 2500.0000 [ I gave up changing this to what it should be 2500.00 - keeps adding extra two 00's when Save is clicked ]

Tax Class: None

No discount applied nor is the item on Special.

Shopfront

The Item shows as having a price of $2,091.25 ???

Have problems with others product prices as well

ie - product item - Price: 900.0000 [ I gave up changing this to what it should be 900.00 - keeps adding extra two 00's when Save is clicked ]

Tax Class: None

In the Special tab, I have this product on Special for 500.0000 [ I gave up changing this to what it should be 500.00 - keeps adding extra two 00's when Save is clicked ]

Shopfront

The Item shows two prices $752.85 $418.25 ???

Do I need to place an , (comma) between the 2 and 5 ie 2,500.00 or is there a bug in the system that is causing this.

you need to set more than 2 0's after decimal points to make the pricing more accreate

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by Daniel » Mon Jan 14, 2013 8:57 pm

putting the match back to 4 decimals not 8

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by dydyt » Thu Mar 07, 2013 7:21 pm

Dose anyone know how to fix this problem? ???

Newbie

Posts

Joined
Wed Oct 17, 2012 3:28 am

Post by bon_garcon » Thu Mar 14, 2013 6:48 pm

I really think this issue should be resolved as it shows wrong prices to customers and headaches for accountants.

You can also replicate this bug on OC demo page too. Just put 100 iPhones in your cart, and check the cart page.

What you will get is following:
Unit price: $120.68 x 100 = $12,067.50 that is clearly wrong.

If someone can produce extension that fix this bug I'm more than happy to buy this extension.

Newbie

Posts

Joined
Thu Mar 14, 2013 6:22 pm

Post by rph » Thu Mar 14, 2013 11:46 pm

The price isn't wrong. That's how rounding works.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by gob33 » Fri Mar 15, 2013 8:31 am

Use the BC math PHP functions to do calculus and avoid propagation of error precision on float numbers.
Using a string representation of numbers is 20x slower than normal math functions, but give good results.

All my extensions


Active Member

Posts

Joined
Wed Feb 10, 2010 8:43 am
Location - France
Who is online

Users browsing this forum: No registered users and 27 guests