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):
- A User deposites 1 EUR into an automated currency exchange machines.
- The amount is converted into USD with ex.rate of (1.1234223)
- The new converted amount (1.1234223) is saved to the database into a DECIMAL(10,2) column = 1.12 USD.
- The user then decides he want to do another conversion and eventually get his deposit as EUR.
- 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:
- Saving currencies in the DB.
- Doing multiple currency exchanges.
- Round - when to round and how?
- Displaying the results to the user - in which format?
Thanks a lot!