When converting the currency in a line item, the currency price are stored with many decimals. Let's look at the following item in cart where the product prices are in GBP and this module converts them to NOK:

Some product 130,72 NOK 6x 784,33 NOK

As you can see are the price per unit = 130,72 and the total x6 units should be 784,32 BUT it is being calculated to 784,33.
The reason for this is $line_item_wrapper->commerce_unit_price['und'][0]['amount'] that stores a lot of decimals, so 130,72 is stored as 13072.23442218. The rounding are not done before calculation, this leads to the difference.

A minor issue you may think? NO NOT AT ALL, this makes you loose business !
If you try to checkout this cart with Paypal for example, you will get an error in your review page that something is wrong in the form, but if you examine the Paypal log you will realize that Paypal rejects the transaction since the order lines and total amount does not add up. The total of the items must match exactly the total amount so if you send order lines with 6x 130,72 and a total amount of 784,33 you will not get paid, it has to be 100% correct.

There are several discussion on this in different modules like the discount module and the issue should probably be solved in the commerce core, but it should be possible to solve this for multicurrency by using only 2 decimals?

CommentFileSizeAuthor
#1 problem conversion.png120.6 KBmozh92

Comments

mozh92’s picture

StatusFileSize
new120.6 KB

I have this problem too!

My solution here https://www.drupal.org/node/1697378#comment-11770724