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

dev/financial#166 Fix for inconsistency around currency symbol #19680

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Feb 26, 2021

Overview

Potential fix for inconsistencies around money handling in code that should not display a currency symbol

Before

On some (most?) installs

CRM_Utils_Money::formatLocaleNumericRounded(20.453, 2)

returns 20.45 or 20,45 depending on the locale

But on others appears to return $20.45

After

Hopefully it's more consistent (pending response from @MegaphoneJon & @larssandergreen )

Technical Details

From https://lab.civicrm.org/dev/financial/-/issues/166 we learn that the existing code
(tested via testFormatLocaleNumericRoundedByCurrency) is not consistent across
all platforms. I think this may be

Comments

@civibot
Copy link

civibot bot commented Feb 26, 2021

(Standard links)

@civibot civibot bot added the master label Feb 26, 2021
@eileenmcnaughton eileenmcnaughton changed the base branch from master to 5.35 February 26, 2021 05:16
@civibot civibot bot added 5.35 and removed master labels Feb 26, 2021
@MegaphoneJon
Copy link
Contributor

I can confirm that this resolves the issue in my environment.

I'm not sure what all is relevant here - but I'm using PHP 7.3 on Ubuntu with the Sury Ondrej repos with php-intl installed (via the repo).

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 @mattwire @monishdeb - looks promising

Thanks @MegaphoneJon - I didn't have the problem & it still works. You did & this fixes so it seems at least better!

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Feb 27, 2021

I couldn't replicate the original issue with the symbol, but noting that in some locales $formatter->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, ''); wouldn't have been completely correct anyway because you get trailing spaces, e.g. in some locales the usual way of writing might be 12,34 €, so you end up with a trailing space.

@colemanw
Copy link
Member

colemanw commented Mar 1, 2021

@eileenmcnaughton can you pls rebase

From https://lab.civicrm.org/dev/financial/-/issues/166 we learn that the existing code
(tested via testFormatLocaleNumericRoundedByCurrency) is not consistent across
all platforms. I think this may be
@eileenmcnaughton
Copy link
Contributor Author

@colemanw done

@seamuslee001
Copy link
Contributor

Test fails un related

@seamuslee001 seamuslee001 merged commit 7937515 into civicrm:5.35 Mar 1, 2021
@seamuslee001 seamuslee001 deleted the money branch March 1, 2021 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants