November Happy Hour will be moved to Thursday December 5th.

Exchange rates stored as floats in DB leading to conversion errors

Vote:
 

Exchange rates stored as floats in DB leading to potential precision errors

In Commerce 7.5 it appears the currency exchange rates stored here [dbo].[CurrencyRate] are stored as floats rather than decimals and that the entered value is lost during the conversion process which can lead to inaccuracies during on site conversion.

If the value 194.292 is entered as the exchange rate between 2 currencies via either the admin UI or directly with the DTO objects from CurrencyManager this is persisted as 194.292007446289.

This loss of precision is not dealt with via the CurrencyFormatter\data retreival methods and the internal GetRates method returns the value as stored.

To test this the conversion of 10000 between two currencies and an exchange rate entered at 194.292 was attempted the expected result is 1942920 however the system gives 1942920.07 via a call to Mediachase.Commerce.Shared.CurrencyFormatter.ConvertCurrency(Money moneyFrom, Currency currencyTo)

Is this a known issue, is our system misconfigured or is there an alternate conversion system that should be used?

Thanks,

Andrew

#89487
Aug 18, 2014 17:43
Vote:
 

Hi,

I believe that in real world scenario, the currency rates are loaded from a live service, which ensures to up to date rates. And an alternative way to solve price problem is that you use rates and update the prices directly, instead of convert money at checkout.

But you're correct in the concern of currency rates being stored as float. I'll file a bug to see if we can improve the situation when I back to work :).(if none of my collague did not do it already)

Regards.

/Q

#89672
Aug 22, 2014 2:21
Vote:
 

Thanks for the update Quan, can you post a link to the bug in the bug list once it has been created.

#89696
Aug 22, 2014 11:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.