Rounding errors in shopping basket.

Author Message

Richard Lundberg

Tuesday 16 November 2010 3:30:02 am

Apologies if this has been addressed, but I could not find any mention which did surprise me as this is a potential fundamental flaw in the shop module.

If you apply a discount of for example 30% to products in the webshop, the calculation produces numbers of many decimal points. These are rounded for the display in the shopping basket. However, the stored number that is used to produce the total is not rounded. Therefore, as the number of products in the basket increase, the totals do not equal a sum of the listed products. In large shopping baskets this can add up to a difference of 10s or cents, which becomes unacceptable. Because of rounding, the totals are less than the sum of the line items so customers are not being overcharged, the problem for me is that the order is generated by the shop module, but invoices are generated by my ERP system which does get the pricing correct, so customers think they are being overcharged from their order.

does anyone have any ideas how to fix this, as getting the totals correct should be quite a fundemental element of a shopping cart.

Update. Even if you do not apply discount, the rounding error effects the excluding VAT total and the amount of VAT. If you are preparing your VAT tax returns from the webshop calculations, they will be wrong. You will be paying to much VAT so the tax man will be happy.

www.peakm3.com

Richard Lundberg

Monday 29 November 2010 3:09:58 pm

Anyone??

Am I missing something. I thought this issue would solicit some response or is it normal for a shopping cart not to add up the totals correctly. If you are using the shopping cart, do you simply ignore this, or are you not aware, or does it not manifest itself in your webshop?

www.peakm3.com

Heath

Monday 29 November 2010 11:14:19 pm

Hello Richard,

Not everyone who uses eZ Publish uses the shop module.

Also it sounds like (from the lack of response) that others are not having the problems you describe. I honestly have not encountered the problem you describe.

You might be better served by posting a new issue at http://issues.ez.no/ezpublish

Cheers,

Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Richard Lundberg

Thursday 02 December 2010 7:22:48 am

Hi Heath,

Thanks for at least an acknowledgment. I have already raised this as an issue #017667, a couple of weeks ago, and applied a priority of medium. My concern is that for all those using the webshop, they might not be aware of the problem, you naturally assume that it is doing the calculations correctly and do not double check with a calculator. It was not until I entered orders created by the webshop into a different accounting system that the problem became apparent.

It is easy to recreate the problem. Simply create a product with a price of 99.99. Apply a discount of 30%. The new price is displayed as 69.99 (69.993 rounded). Add it to your basket, change the quantity to 2, and already there is an error. The shopping cart will now display the total as 139.99 (69.993 *2 =139.986 rounded up) , not 139.98 (2*69.99) and the customer is being overcharged. I have tested this on 4.02, 4.2 and 4.3.

This has to be happening to all webshop users who are applying sales tax, or discounts. Should I change the issue priority to high as overcharging customers is not a good feature of a webshop?

www.peakm3.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:25:33
Script start
Timing: Jan 18 2025 04:25:33
Module start 'layout'
Timing: Jan 18 2025 04:25:33
Module start 'content'
Timing: Jan 18 2025 04:25:34
Module end 'content'
Timing: Jan 18 2025 04:25:34
Script end

Main resources:

Total runtime1.5061 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.2891152.6250
Module start 'layout' 0.00590.0039 741.914139.4531
Module start 'content' 0.00991.4945 781.3672555.4141
Module end 'content' 1.50440.0017 1,336.781316.1563
Script end 1.5060  1,352.9375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2276160.0002
Check MTime0.00150.0989160.0001
Mysql Total
Database connection0.00060.037510.0006
Mysqli_queries1.447096.0775600.0241
Looping result0.00060.0411580.0000
Template Total1.453496.520.7267
Template load0.00230.152120.0011
Template processing1.451196.350620.7256
Template load and register function0.00010.006110.0001
states
state_id_array0.00110.073110.0011
state_identifier_array0.00090.060420.0005
Override
Cache load0.00180.1206260.0001
Sytem overhead
Fetch class attribute can translate value0.00080.051920.0004
Fetch class attribute name0.00130.088260.0002
XML
Image XML parsing0.00100.066920.0005
class_abstraction
Instantiating content class attribute0.00000.001180.0000
General
dbfile0.00110.0701230.0000
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs