- Posts: 20
- Thank you received: 0
Rounding problem with product prices
12 years 10 months ago #134180
by Jeffq
Rounding problem with product prices was created by Jeffq
Hi,
On a few of my products, I'm having a price rounding problem. The saved price is not the one input by the the user.
I configured one of them at 35€ (in price with tax), but when I save, it turns into 34.99999516 (FYI, tax is 19.6)
On the front end, it does appear as 35.00€. When I proceed to checkout, it still appears as 35.00, but when I'm transferred to the payment gateway, the amount charged is 34.99.
This happens with the hikashop systempay module (French banks), and not with the paypal module.
I'm guessing the systempay module doesn't round up the price the way the paypal module does. But since the price stored in database is 34.99999516, it seems to me the problem is with the tax calculation, and not with this payment module, right? Is there anyway to force hikashop to save Exactly the price with tax input by the merchant?
It's the only problem preventing me from launching my site
Thanks in advance.
Regards
Hikashop 2.2.2
Joomla 2.5
PS: I've posted this on an archived topic, not sure if I should have, so I created a new one... apologies for the mess
On a few of my products, I'm having a price rounding problem. The saved price is not the one input by the the user.
I configured one of them at 35€ (in price with tax), but when I save, it turns into 34.99999516 (FYI, tax is 19.6)
On the front end, it does appear as 35.00€. When I proceed to checkout, it still appears as 35.00, but when I'm transferred to the payment gateway, the amount charged is 34.99.
This happens with the hikashop systempay module (French banks), and not with the paypal module.
I'm guessing the systempay module doesn't round up the price the way the paypal module does. But since the price stored in database is 34.99999516, it seems to me the problem is with the tax calculation, and not with this payment module, right? Is there anyway to force hikashop to save Exactly the price with tax input by the merchant?
It's the only problem preventing me from launching my site
Thanks in advance.
Regards
Hikashop 2.2.2
Joomla 2.5
PS: I've posted this on an archived topic, not sure if I should have, so I created a new one... apologies for the mess
Please Log in or Create an account to join the conversation.
12 years 10 months ago #134375
by nicolas
Replied by nicolas on topic Rounding problem with product prices
Hi,
The problem is with the systempay plugin which doesn't round the price correctly before sending it to the payment gateway.
It's normal that the price are stored like that. That's because of the tax calculation which is done based on the price without tax.
It needs to store the decimals so that it can properly sum the products/quantities/etc without loosing precision so that it is valid accounting-wise.
I guess that the line:
$amount = $order->cart->full_total->prices[0]->price_value_with_tax;
should be :
$amount = round($order->cart->full_total->prices[0]->price_value_with_tax,2);
in the file plugins/hikashoppayment/systempay/systempay.php
Please contact systempay's plugin provider so that they can fix the issue in the package they propose on their website once you test the change.
The problem is with the systempay plugin which doesn't round the price correctly before sending it to the payment gateway.
It's normal that the price are stored like that. That's because of the tax calculation which is done based on the price without tax.
It needs to store the decimals so that it can properly sum the products/quantities/etc without loosing precision so that it is valid accounting-wise.
I guess that the line:
$amount = $order->cart->full_total->prices[0]->price_value_with_tax;
should be :
$amount = round($order->cart->full_total->prices[0]->price_value_with_tax,2);
in the file plugins/hikashoppayment/systempay/systempay.php
Please contact systempay's plugin provider so that they can fix the issue in the package they propose on their website once you test the change.
Please Log in or Create an account to join the conversation.
12 years 10 months ago #134460
by Jeffq
Replied by Jeffq on topic Rounding problem with product prices
Hello,
As usual, awesome support
This works indeed. I'll test it a bit more before submitting this change to the plugin provider.
Regards,
Jeff
As usual, awesome support
This works indeed. I'll test it a bit more before submitting this change to the plugin provider.
Regards,
Jeff
Please Log in or Create an account to join the conversation.
Time to create page: 0.255 seconds