I have an "order" with two "line item"
- Line item 1 (line_item_id=1):
+ unit_price:
+ amount=1000
+ currency_code: USD (decimals = 2)
- Line item 2 (line_item_id=2)
+ unit_price:
+ amount=2000
+ currency_code: XPF (decimals = 0)
When i save an order (press "Save order" button), the function "commerce_order_calculate_total($order)" is invoked.
The currency to use for the order total is USD.
Function "commerce_price_field_widget_validate()" convert line item's unit price from "decimal" (float) to "amount" (int) with function "commerce_currency_decimal_to_amount()". So the new unit price of two line item is : 100000 (decimal=2) & 2000 (decimal=0).
Finally, the order total "amount" is 100000+22.6 = 100022.6
After converting to "decimals", the order total "decimals" is 1,000.226 USD
This value seem to be wrong. The correct value is 1,022.6 USD
Is this a bug and need to be fixed?
Comments
Comment #1
rszrama commentedTagging.
Comment #2
rszrama commentedComment #3
mrsinguyen commented+1
Comment #4
rszrama commentedAlrighty, turned out that commerce_currency_convert() did not accommodate converting between currencies formatted with different numbers of decimals. This patch fixes that.
Commit: http://drupalcode.org/project/commerce.git/commitdiff/52f3bf6
Comment #5.0
(not verified) commentedfix some spell