-
Notifications
You must be signed in to change notification settings - Fork 9
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
Some improvements #32
Conversation
prolic
commented
Jun 20, 2016
- Update to use Zend\Hydrator instead of Zend\Stdlib\Hydrator
- Bug fix of ODM\MongoDB\Types\CurrencyType
- update mapping
- Don't hydrate object if form values wasn't present
* shouldn't use stringtype
Fixation bug currency type
Fixed money hydrator
* at mongo persistence should nor a instance only string
Fixation bug currency type
update mapping
@@ -20,7 +20,7 @@ class MoneyHydrator implements HydratorInterface | |||
public function extract($object) | |||
{ | |||
return [ | |||
'amount' => $object->getAmount(), | |||
'amount' => $object->getAmount() / 100, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this? I want the amount in the smallest unit available. Not every currency has decimals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which currency for example? I like to verify your statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently I can only think of cryptocurrencies not having decimals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, cryptocurrencies is fair enough, so I changed this line again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a few actually. Here's a list: https://support.stripe.com/questions/which-zero-decimal-currencies-does-stripe-support
Beside this being a BC-break, I really want discourage this change. Working with the smallest unit available is very common practice when performing payments. It's also less error prone (rounding problems).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the provided list, CLP (chilean peso) is a zero-decimal currency, but it's not! There are 100 Centavos for 1 CLP. However GNF (Franc Guinéen) is valid.
BC BREAK! Because it uses Zend\Hydrator instead of Zend\Stdlib\Hydrator |
Thanks @prolic! |