-
-
Notifications
You must be signed in to change notification settings - Fork 625
-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Price (and other Number based) field bug/question #86
Comments
Yes, the How about we take the following actions for release 1.2.0:
Then, in 2.0:
Thoughts? |
Oh, and also change the rounding to We could also add a |
You already have my implementation of it. #72
Sure.
Uhm, no. Mark it for PendingDeprecation as well. It doesn't make any sense as a field when you have Numeric. They will do the same thing.
No, don't do this. For instance, ROUND_HALF_EVEN is good for USD (but not for EUR). Just mark the field for PendingDeprecation without any further change. |
Looks good after a quick pass. Made a few suggestions for minor changes. Will review again when you send another PR.
I wasn't able to serialize a
My thought was to include the So sure, I think it can be marked for |
import simplejson as json
from decimal import Decimal
json.dumps({'foo':Decimal('12.34')}) The result is: '{"foo": 12.34}'. Instead, having it in this way: '{"foo": "12.34"}' is very wrong (note that now "foo" is a string and not a number anymore). |
Before you say it. Yes, simplejson IS a requirement! |
We can't assume the user is using any custom JSON encoder. Marshmallow fields are meant to serialize to primitive types.
|
Done. It's here #89 with the class based validators. |
Closed by #103 |
Below the steps to reproduce the bug:
The problem is ROUND_HALF_EVEN used in utils.decimal_to_fixed.
In general, it's false that ROUND_HALF_EVEN is the right rounding method for an amount of money.
For instance, in Europe the law prescribes the use of ROUND_HALF_UP to round amounts in EUR currency.
Moreover the use of float for money is very dangerous. Something we are going to regret.
More info here: http://spin.atomicobject.com/2014/08/14/currency-rounding-errors/
(a quick search on google will show a lot of horror stories about this)
Last but not least a question. Why it deserializes to a string and not to a Decimal?
The text was updated successfully, but these errors were encountered: