Open ydaniv opened 9 years ago
I'm sure some people would want to fine-tune the way currencies handles the rounding, so if you can provide a patch for it, I'll include it!
I presume when you say rounding, you mean the number of decimal places?
This is half-covered in the latest code by the addition of the info
field. If you import the currency from the CurrencyISO source, what is called the ISO4217Exponent
will be imported, which is the number of decimal places for the currency.
The bit we're missing is the bit of code that looks this information up and uses it in the conversion. Unfortunately because other currency sources don't provide this information, we would have to also leave the default (currently 2)
I thought about adding the extra code to utils.py but it's already a bit ugly in there. If we were to do it properly as you say we should implement methods on the Currency model like the Money class here and here Also look at python-money and py-moneyed
Hi!
I have a working implementation of a
rounding
field onCurrency
model that enable cofiguring the rounding rules for each currency. It also includes around()
method onCurrency
that takes avalue
and retuns it rounded.No tests for now, but just checking if this is something you'll be interested in adding to django-currencies.
Thanks!