a credit card provider needs the transaction amount in cents or smallest available unit of the currency. since I want the code to be portable I have to get the smallest unit of a given currency and it's factor to the main unit. I've tried to get it from the locale module but i had no luck.
http://docs.python.org/library/locale.html
Example
i have a currency code as described in iso 4217
EUR for Euro
then i need 1 Euro is 100 Eurocents (only the information 1/100, no text is needed)
according to wikipedia there currencies which have more than 2 units like the old pund sterling
A penny is a coin ( pl. pennies) or a unit of currency (pl. pence) in various countries. Borrowed from the Carolingian denarius (hence its former abbreviation d.), it is usually the smallest denomination within a currency system.
Alternatively cou can use following simple mapping module: http://pastebin.com/K7kVXi8P
Save this pastebin into a module within your project (e.g. simple_currency_helper.py) and use the map (or the helper method get_currency_subunit
) to get out the currency subunit for a given ISO-Code.
>>> from simple_currency_helper import get_currency_subunit
>>> print get_currency_subunit('TND')
1000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With