SQL Server data type for currency conversions

320 views Asked by At

What is the best practice for saving and display currency data in a system with a lot of currency exchanges?

Example Scenario from our system (Currently, with problems which we are trying to fix):

  1. A User deposites 1 EUR into an automated currency exchange machines.
  2. The amount is converted into USD with ex.rate of (1.1234223)
  3. The new converted amount (1.1234223) is saved to the database into a DECIMAL(10,2) column = 1.12 USD.
  4. The user then decides he want to do another conversion and eventually get his deposit as EUR.
  5. The new USD amount (1.12) is converted into EUR and the amount is 0.99 EUR.

The result is that the user lost a 1 euro cent.

What would be the best practice for the following issues:

  1. Saving currencies in the DB.
  2. Doing multiple currency exchanges.
  3. Round - when to round and how?
  4. Displaying the results to the user - in which format?

Thanks a lot!

0

There are 0 answers