Handling money/currency with MongoDB
These are examples for (fictive) user input:
- 12301,12€
- $124.97
- -340.12€
- -$1213.12
I need to store that in my MongoDB database. That should be quite easy, just store the string, right?
Well, no. I need to take, for example, "-$1213.12" and figure out if the amount is negative or positive and in which currency the amount is, and store it accordingly. Furthermore, I need to be able to pull out these entries later and use them for calculations. Another problem I discovered is that some countries use a dot to seperate decimal places, and some use a comma. Ruby can only handle dots.
Any suggestions, possibly?
EDIT// I solved one problem by banning currency symbols in the user input. That leaves me with the negative/positive problem and the seperator problem.
User input now may look like this:
-11238,12 USD






Cartoon Clouds
Mountains
Sunrise
Clouds
Green Clouds
None
















Help