Developer forum

Forum » Ecommerce - Standard features » Rounding issue with vouchers/discounts

Rounding issue with vouchers/discounts

Melissa Borgmann
Melissa Borgmann
Reply

We have a customer experiencing rounding issues when utilizing standard DynamicWeb vouchers. The issue was first identified on 9.15.13, and was not resolved with an upgrade to 9.16.2. Example:

  • PROD Solution (running 9.15.3 / 1.22.0) / TEST Solution (running 9.16.2 / 1.22.0)
  • ORDER6180 - customer used a 15% off voucher (WELCOME15).
    • The expected behavior is:
      • Subtotal: 60.50
      • Discount: 60.50*0.15 = 9.075
      • Total: 60.50-9.075 = 51.425 (rounded to 51.43)
    • The actual behavior is:
      • Subtotal: 60.50
      • Discount: 60.50*0.15 = 9.075 (rounded to 9.8)
      • Total: 60.50-9.8 = 51.42

If we set 'Round orderline discounts per quantity' = False, the total is rounded up to 51.43 which is the desired total, however then the math does not align, as the discount is still rounded:

  • Subtotal: 60.50
  • Discount: 60.50*0.15 = 9.075 (rounded to 9.8)
  • Total: 60.50-9.8 = 51.43 (correct value, but math doesn't add up: 60.50-9.8= 51.42)

Is it possible to not round the discount value?

 


Replies

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply

Hi Melissa, 

I have just tested it out on the test site and I don't see any issues. But the displayed price is rounded. 

If you have the rounding off. Then it calculates on the unrounded price in the db. 60,5-9,075 = 51,425 = 51,43 (displayed)

 

And with rounding on. 60,5-9,08 = 51,42

BR Rasmus

 

 
Melissa Borgmann
Melissa Borgmann
Reply

Rasmus, thanks for the quick response!

So to confirm, there is no configurable way to display the non-rounded discount price?

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply

Hi Melissa, 

No, we don't have any plans for showing non-rounded prices, but we do consider the ability to configure showing more decimals. Though it will not solve your problem. If it's important for the customer to have all prices aligned there is not other way forward than to round the prices, it's not DW, it's math. :-)

Take a look at our improved rounding calculations, available from 9.16. Settings -> Ecommerce -> Adv. config. -> Prices:

 

BR Rasmus

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

There is the workaround to change the template and use another property of the price to render it.

The price is in the PriceViewmodel - it has different properties https://doc.dynamicweb.com/apix/api/Dynamicweb.Ecommerce.ProductCatalog.PriceViewModel.html

In the templates we use PriceFormatted which includes rounding rules and currency code. If you use the Price property, which is a double, it contains the full number - then you have to render the currency and the amount of decimals in the template.

The normal curency formatting is using this method: https://doc.dynamicweb.com/apix/api/Dynamicweb.Ecommerce.International.CurrencyService.html#Dynamicweb_Ecommerce_International_CurrencyService_FormatCurrency_Dynamicweb_Ecommerce_International_Currency_System_Double_System_Boolean_System_Boolean_

Buy you can do @Model.Price.Price.ToString("") and add a formatting string that is 3 or more decimals and then add the currency code your self.

 
Melissa Borgmann
Melissa Borgmann
Reply

Thank you both, Rasmus & Nicolai. Was hoping to come out of this conversation with some tangible options to present to the customer and you did not disappoint. Appreciate the quick responses!

 

You must be logged in to post in the forum