Developer forum

Forum » Ecommerce - Standard features » Rounding issues

Rounding issues

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

We are running into some issues with rounding with discounts and taxes. The difference is usually by 0,01€, but still depending on the settings in the backend there are 2 consequences:

  • The credit card is authorized for less
  • The customer complains because the "Total" does not add up correctly

 

In attachment you can see my findings for a matrix of 3 discount types with the 4 possible rounding settings (none, up, down, nearest). You will see they are never consistent, and if I manage to find a pattern that works (our client in not worried about the pennie difference as he with with the 2 situations described above), it's a matter of probability, because changing the discount percentage and/or product price breaks the pattern.

 

The scenario

  • 2 different products with the same price of $8,99 (1 qty each)
  • Flat tax rate of 7,25%
  • Flat shipping fee of $5,95

 

The problem

  • The order total is calculated without rounding, and only then rounding is applied
  • This sometimes results in a difference of $0,01

 

The solution

  • So far the only solution I see would be that when calculating the Order Total, to take the rounding into account, but that's easier said than done too, and would not be accurate in terms of data. What to do?
    • I'd have to defer to smarter people now.
    • We can make the templates look accurate by doing the calculations in Razor, however the authorized amount on the credit card would not be accurate

 

Using 9.2.9

 

Best Regards,

Nuno Aguiar

Rounding.jpg

Replies

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Nuno and I and others on our team just had a good discussion about this. It's something that has come up a few times so we would like to find out how it should be done, and ensure that it's being done the correct way in the platform. It may be different between Europe and the US.

Here's a good minimal example:

  Pre-rounded Rounded
Order Line1 4.4344 4.44
Order Line2 4.3654 4.37
Sum 8.7998 8.81
Sum Rounded 8.80 8.81

Notice that if you round each line and sum them up, you get a different result than if you sum them up and round. This has two issues.

  1. The math is off by a penny, which means that one of them is wrong. 
  2. You can't easily display the pre-rounded option on a website since you would round the lines to 2 decimal places for each line, and manually calculate it won't match the total at the bottom. (the website will look like it's using the rounded method for the lines, regardless of how the calculations work)

Our platform appears to be using the pre-rounded method. We would like to confirm what is correct, and we're open to talking to a US accounting firm to confirm. I'm hoping that the solution is to round for each line. That makes sense to me that every discount or tax item should be rounded as it's created, and then the sum of the rounded lines will give the total. For example, you get a 23% discount on a $21.21 item, the discount that you should get is $4.88 and not $4.8783.

Regarding taxes, Amazon mentions that the tax is generally calculated pre line (https://www.amazon.com/gp/help/customer/display.html/ref=hp_468512_calculated?nodeId=468512#calculated). I assume that means that it should be calculated and rounded per line. So that also takes care of this.

How do we find out for sure what is correct, and then have the calculations in the platform use that method?

Scott

 

 

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

I tested this feature in 9.2.1.16 and it's working as expected now. Thank you

 

Nuno

 

You must be logged in to post in the forum