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

POINTS_DECIMAL_PLACES doesn't behave correctly #110

Open
somas95 opened this issue Feb 2, 2022 · 2 comments
Open

POINTS_DECIMAL_PLACES doesn't behave correctly #110

somas95 opened this issue Feb 2, 2022 · 2 comments

Comments

@somas95
Copy link

somas95 commented Feb 2, 2022

There are at least two places where POINTS_DECIMAL_PLACES doesn't yield good results.

First, it doesn't respect LANGUAGE_CODE so I'll get a point where a decimal comma is expected in languages like Spanish

Second, round operators won't work properly. The rounding happens but non significative digits are still shown

For example, if the variable a = cu(0.32), and in the template I specify {{ a|to1 }} I'll get 0.30 where 0.3 is expected.

I can write a PR if desired (although the repo hasn't been updated for a while)

@oTree-org
Copy link
Owner

Hi, thank you for reporting. I was aware of some of these issues, but haven't fixed it yet because it was tricky in the code.

Honestly, I don't recommend using POINTS_DECIMAL_PLACES, and as you can see it is not documented. Using whole numbers avoids a number of complications. My recommendation is to set your point magnitudes high enough that you don't care about rounding error. There is a note about this here: https://otree.readthedocs.io/en/latest/currency.html#decimal-places

@somas95
Copy link
Author

somas95 commented Feb 7, 2022

Sadly that's not always possible, but thanks! If you need any help improving that let me know

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

2 participants