Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Form] ability to set rounding strategy for MoneyType#26767
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedApr 3, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
would you mind adding some tests please? |
e63a499 tof3b1424Comparesyastrebov commentedApr 4, 2018
@nicolas-grekas You're welcome :) Added tests for the changes, please take a look. |
fabpot commentedApr 4, 2018
Thank you@syastrebov. |
…(syastrebov)This PR was merged into the 4.1-dev branch.Discussion----------[Form] ability to set rounding strategy for MoneyType| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | no| License | MIT| Doc PR |symfony/symfony-docs#9543Added `rounding_mode` to the `MoneyType` to be possible to change rounding strategy for money values. For now it's just `ROUND_HALF_UP` but it's good to have `ROUND_DOWN` as well. E.g. to transform `15.999` to `15.99` instead of `15.1`.Commits-------f3b1424 rounding_mode for money type
This PR was merged into the master branch.Discussion----------rounding_mode for money typeAdded docs forsymfony/symfony#26767Commits-------819d0a6 rounding_mode for money type
| )); | ||
| $resolver->setAllowedValues('rounding_mode',array( | ||
| NumberToLocalizedStringTransformer::ROUND_FLOOR, |
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 usingNumberToLocalizedStringTransformer and notNumberFormatter here ? Adding a dependency to a transformer without using it doesn't seem right.
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.
NumberToLocalizedStringTransformer is the parent class of theMoneyToLocalizedStringTransformer which is used by this form type and that is configured through these options.
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.
Then why notMoneyToLocalizedStringTransformer::ROUND_FLOOR ?
erlangparasu commentedMay 29, 2018
@syastrebov how to round-up by 100, sir? round-down by 100? |
Added
rounding_modeto theMoneyTypeto be possible to change rounding strategy for money values. For now it's justROUND_HALF_UPbut it's good to haveROUND_DOWNas well. E.g. to transform15.999to15.99instead of15.1.