rounding problem

  • Posts: 30
  • Thank you received: 1
  • Hikashop Business
2 months 2 weeks ago #358907

-- HikaShop version -- : 5.0.3
-- Joomla version -- : 4.1.2
-- PHP version -- : 7.4.33
-- Browser(s) name and version -- : chrome latest, firefox, etc.
-- Error-message(debug-mod must be tuned on) -- : no error message

Hi there!

I encountered a rounding issue.

If there's a product priced at, say, 536.41 forints (HUF), it rounds it to 536 forints gross. However, the issue arises when someone buys two of these products, which would amount to 1073 forints, as the gross value is actually 1072.82. Now, if I don't round it up with Hikashop to 1073, the Barion (payment module) rejects it with an error, and it's impossible to make a payment on the website (in Hungary, non-whole numbers cannot be used for payments, unlike Euro cents). But if I round it up, it disregards the decimal value (from 1072.82, it only takes 1072 HUF), and thus 1 HUF is lost. However, Barion only accepts the value if we round up the prices beforehand.

The more one orders, the greater the discrepancy.

Thanks in advance!
FRIK

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 months 2 weeks ago #358910

Hi,

First, it should be up to the payment plugin you're using to round the total amount based on the capabilities of the payment gateway.

Second, when you edit your currency in the menu System>Currencies, you can edit your currency and enter the number of decimals. If you set it to 0 it will round the prices when displayed on the frontend.
Then, you have the "round prices during calculations" setting in the HikaShop configuration.
What you're describing indicates that you've activated this setting and thus, the prices are rounded before being summed.
However, with that setting turned off, 536.41 would still be rounded to 536 on display, but 536.41+536.41 would be displayed as 1073 since the rounding would happen on display, after the calculation is made.
However, in that case, the order_full_total value of the order will still be 1072.82 in the database. So that means that it still requires the payment plugin to do the rounding too when passing the value to the payment gateway.

So, either way, I suggest contacting the developer of the payment plugin to properly round the total amount so that it is compatible with the payment gateway if the total amount has more decimals than possible with that payment gateway.

Please Log in or Create an account to join the conversation.

Time to create page: 0.036 seconds
Powered by Kunena Forum