From 136473f4517641be6e47065fbc3fc9d0205dd7da Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 27 Feb 2021 12:50:23 +1300 Subject: [PATCH] dev/core:2394 Fix for number formatting regression This function has been picking up the formatting for the locale meaning that the currency separator replacement is already done and is swapped back by formatLocaleNumericRoundedByPrecision Doing it via brickmoney is better than our custom separator replacement - but we need a quick fix for the rc --- CRM/Utils/Money.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/Money.php b/CRM/Utils/Money.php index 786fccd64c..02b0ed54cc 100644 --- a/CRM/Utils/Money.php +++ b/CRM/Utils/Money.php @@ -208,7 +208,14 @@ class CRM_Utils_Money { return self::formatNumericByFormat($amount, '%!.' . $numberOfPlaces . 'i'); } $money = Money::of($amount, CRM_Core_Config::singleton()->defaultCurrency, new CustomContext($numberOfPlaces), RoundingMode::CEILING); - $formatter = new \NumberFormatter(CRM_Core_I18n::getLocale(), NumberFormatter::CURRENCY); + // @todo - we specify en_US here because we don't want this function to do + // currency replacement at the moment because + // formatLocaleNumericRoundedByPrecision is doing it and if it + // is done there then it is swapped back in there.. This is a short term + // fix to allow us to resolve formatLocaleNumericRoundedByPrecision + // and to make the function comments correct - but, we need to reconsider this + // in master as it is probably better to use locale than our currency separator fields. + $formatter = new \NumberFormatter('en_US', NumberFormatter::CURRENCY); $formatter->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, ''); $formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $numberOfPlaces); return $money->formatWith($formatter); -- 2.25.1