Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rounding field on Currency model #18

Open
ydaniv opened this issue Dec 5, 2014 · 3 comments
Open

rounding field on Currency model #18

ydaniv opened this issue Dec 5, 2014 · 3 comments

Comments

@ydaniv
Copy link
Contributor

ydaniv commented Dec 5, 2014

Hi!

I have a working implementation of a rounding field on Currency model that enable cofiguring the rounding rules for each currency.
It also includes a round() method on Currency that takes a value 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!

@panosl
Copy link
Owner

panosl commented Dec 10, 2014

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!

@racitup
Copy link
Collaborator

racitup commented Nov 30, 2018

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)

@racitup
Copy link
Collaborator

racitup commented Nov 30, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants