oTree
oTree copied to clipboard
POINTS_DECIMAL_PLACES doesn't behave correctly
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)
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
Sadly that's not always possible, but thanks! If you need any help improving that let me know