-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
dev/core#1522 Handle space as thousand separator #16392
Conversation
(Standard links)
|
In terms of background about related issues we have hit - the current cleanMoney code doesn't cope well when the same string is passed through it twice. We had a lot of issues with money being converted to the wrong value. We determined that we should cleanMoney as close to form submission as possible & it should always be clean by the time it hit the BAO. I thought at the time it should be clean before hitting the api but the risks in changing that were pretty high. @colemanw it would be good to agree the best place to clean this for apiv4 while we can still change things In terms of how the above affects this - a lot of the code in that function was because money was regularly being 'cleaned' more than once & it sought to avoid messing it up. When we added more decimal places to some fields the double-clean checks stopped working & we got a bunch of bugs. I guess all of that is a long way of saying I'd be keen to have you run this in production for a bit @jaapjansma (also on sites with other separators preferably) & maybe we can merge once the next rc is cut so you will have had it in prod for a couple of months by the time it goes out, in case it surfaces some cases where double-cleaning causes issues. |
test this please |
@@ -84,7 +84,10 @@ public function numericDataProvider() { | |||
* @param $inputData | |||
* @param $expectedResult | |||
*/ | |||
public function testMoney($inputData, $expectedResult) { | |||
public function testMoney($inputData, $decimalPoint, $thousandSeparator, $currency, $expectedResult) { |
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.
I think this will cause jenkins to fail - not sure if that is the issue giving the weird test error atm - the params need to be in the comment block (can you also add 'type' to the exisiting ones as we are trying to up our game - ie @param array $inputData
@jaapjansma I took another look at this & as it is just the rule it seems much safer to change & there is quite a bit of cover to ensure the later regex doesn't let through weird things so I think that this is pretty solid & if we can get tests passing we can merge. Note the old issue mentioned is a loosening not a tightening https://issues.civicrm.org/jira/browse/CRM-7122 |
@jaapjansma style warnings.... |
@eileenmcnaughton the test failed but it is an api v4 failure which does not have anything to do with what I have changed (I hope at least). Not sure what to do now |
Unrelated fail |
Overview
, as decimal separator, and [space] as thousand separators leads to api errors
This PR fixes that. It also includes tests for testing different localization.
Issue 1522 contains a table of the analyses of which localized options are going wrong.
Before
After
CRM_Utils_Rule::money
CRM_Utils_Rule::money
so it accepts different localized options.Comments
Added deprecated flag to
setCurrencySeparators
in test/phpunit/CiviTest/CiviUnitTestCase.phpAlso added three new functions
setMonetaryThousandSeparator
,setMonetaryDecimalPoint
andsetDefaultCurrency
The reasoning behind this is that the setCurrencySeperator only sets the thousand seperator and somehow magically decides what than the decimal seperator is.
I need more control of setting each of those, including the currency.
If necessary I can create a separate PR which removed the
setCurrencySeparators
from all tests and replace them by the new functions. I can and will do that after this PR has been approved and merged.