Skip to content
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

Fix failing tests on edge based on number formatting by using the Num… #16215

Closed
wants to merge 1 commit into from

Conversation

@civibot
Copy link

civibot bot commented Jan 5, 2020

(Standard links)

@civibot civibot bot added the master label Jan 5, 2020
@@ -62,9 +62,12 @@ public static function format($amount, $currency = NULL, $format = NULL, $onlyNu
}

if ($onlyNumber) {
if ($valueFormat === '!%i') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the default value maybe we should add some deprecation notice for other formats?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that is the case then yes probably

// money_format() exists only in certain PHP install (CRM-650)
if (is_numeric($amount) and function_exists('money_format')) {
$amount = money_format($valueFormat, $amount);
$amount = self::formatNumericByFormat($amount, $valueFormat);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some standardisation / re-use of functions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should if [..] function_exists('money_format') also be removed?

@eileenmcnaughton
Copy link
Contributor

@mattwire can you review this?

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Jan 28, 2020

@seamuslee001 I took a pretty thorough look & could not find a single instance where the $valueFormat is passed into this function - I should we should deprecate passing it in & ignore any passed in value. That would mean you could just call formatLocaleNumeric & restrict your weird handling to that function

However, I also suspect that in fact we are retaining code that is not really being used & would likely actively break things if it were - I need input from people like @jaapjansma @bjendres @mlutfy @mattwire but my reading is that the money_value config variable could be set to

  1. display in international format (the default)
  2. display in national format

Screen Shot 2020-01-28 at 6 48 01 PM

Screen Shot 2020-01-28 at 6 48 20 PM

money_format doc

But because the latter didn't work on all installs (money_format was not always present) we ALSO added all that thousand separator code blah blah & probably that meant that no-one alters the money_value under localisation & that if they do it would potentially actively break things.

I'm keen to hear back if people use it but if not I think it will simplify this code & allow us to switch to just the one preferred method (the new number formattter class )

@jaapjansma
Copy link
Contributor

My understanding is that the money format settings don't impact anything.
I would use the decimal and thousand separator settings to change how money is displayed.

This setting always sounded technical to me and I haven't seen any effect of changing this. So to me it is a useless setting (but that might be that I dont understand what it does).

I have also checked with Betty and see was also not aware of this setting.

@jaapjansma
Copy link
Contributor

By the way have you seen my pr: #16392
I have added a data provider to the test to test lots of different localization variations. It might be useful to add those as well to a test around money format.

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I posted in translation channel to solicit more feedback but @jaapjansma's comments support my belief we can kill that setting as an early attempt that didn't get traction

@mlutfy
Copy link
Member

mlutfy commented Jan 29, 2020

If we can rely on the locale for displaying in the correct format, then yes, let's remove this. The settings names and the code have always been confusing to me.

If I understand correctly, more cleanup would be done? Can you ping me before merging? I will apply it on our production sites.

@eileenmcnaughton
Copy link
Contributor

@mlutfy this is how I think the function would look without using that config var

https://github.com/civicrm/civicrm-core/compare/master...eileenmcnaughton:money_format?expand=1

Note the json change - but I think NumberFormatter is 'standard'?

@jaapjansma
Copy link
Contributor

@seamuslee001 could you fix the hard coded en_US localization?

@jaapjansma
Copy link
Contributor

Betty and I are reviewing PR's and we came across this one and we see there has been no work on this PR since Jan 29 so we will close this PR.
Feel free to reopen if you start working on it again @seamuslee001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants