-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Ensure comma not formatted into amount #23356
Conversation
(Standard links)
|
c372344
to
bb26c70
Compare
CRM/Core/Payment.php
Outdated
return CRM_Utils_Money::formatUSLocaleNumericRounded($params['amount'], 2); | ||
// Amount is already formatted to a machine-friendly format but may NOT have | ||
// decimal places - eg. it could be 1000.1 so this would return 1000.10. | ||
return Civi::format()->machineMoney($params['amount'], 'USD', 'en_US'); |
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.
@eileenmcnaughton This passes a third parameter (en_US
); in the actual method, it doesn't take a third parameter, but it does hard-code a reference to en_US
.
I'm trying to understand the difference between "moneyNumber" and "machineNumber". Is the idea that "machineNumber" is supposed to be less context-sensitive (ie the machineNumber format isn't actually about your specific locale; it's about some general norm that's seen most wire-protocols; and a way to match that norm is to use en_US
with GROUPING=>false
)?
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.
@totten so moneyNumber is a number formatted per the currency (but without the currency symbol) - eg. as you would do it in data entry
machineMoney is money formatted with the number of decimal places that the would be used for that currency but is machine-ready
You are right the locale can go now - I changed it - the currency is only relevant in that it might (in future) be something like JPY in which case it would be 1000 not 1000.10
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.
OK, cool.
Flagging "merge ready" (ie any additional feedback from @stesi561 could sway it), but it's de-facto "merge on pass" (ie the time for 5.49 is at-hand; after another test-run, there's no specific reason to hold it up).
The relevant test is passing. The test failure There's a change in the method I don't have the specific environment to It would be appropriate to add more coverage via I added a comment/question about |
Probably the function doesn't add anything as params['amount'] should be correctly formatted - however, it shouldn't add a comma - per eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor#227
New test-run mentions a failure in |
Overview
Ensure comma not formatted into amount
Before
Calling
getAmount
onCRM_Core_Payment
adds a thousand separatorAfter
It doesn't
Technical Details
Probably the function doesn't add anything as params['amount']
should be correctly formatted - however,
it shouldn't add a comma - per
eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor#227
Comments
I think this must have regressed recently-ish when we messed with money formatting - but I'm not 100% sure when