From 8833b1a2eded252bad9c2c0c59d7ef6716d6d82b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 13 May 2021 07:34:44 +1200 Subject: [PATCH] Fix money formatting opps As Matt points out we regressed this when adding 2 decimal places https://github.com/civicrm/civicrm-core/commit/78b338e07464becd1555a2c7d2d04ac0e4e9180c#diff-3d2a990f0b1960f0b3e6671c645e18033883e6d1eaf535b8d19d085b67dde00bR1171 --- CRM/Core/Payment.php | 4 ++-- CRM/Utils/Money.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 7e11e61429..4254f3ce47 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -1166,9 +1166,9 @@ abstract class CRM_Core_Payment { protected function getAmount($params = []) { if (!CRM_Utils_Rule::numeric($params['amount'])) { CRM_Core_Error::deprecatedWarning('Passing Amount value that is not numeric is deprecated please report this in gitlab'); - return CRM_Utils_Money::formatLocaleNumericRoundedByPrecision(filter_var($params['amount'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 2); + return CRM_Utils_Money::formatUSLocaleNumericRounded(filter_var($params['amount'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 2); } - return CRM_Utils_Money::formatLocaleNumericRoundedByPrecision($params['amount'], 2); + return CRM_Utils_Money::formatUSLocaleNumericRounded($params['amount'], 2); } /** diff --git a/CRM/Utils/Money.php b/CRM/Utils/Money.php index a67ac1b633..2d59748678 100644 --- a/CRM/Utils/Money.php +++ b/CRM/Utils/Money.php @@ -194,7 +194,7 @@ class CRM_Utils_Money { * * @return string */ - protected static function formatUSLocaleNumericRounded($amount, int $numberOfPlaces): string { + public static function formatUSLocaleNumericRounded($amount, int $numberOfPlaces): string { if (!extension_loaded('intl') || !is_numeric($amount)) { // @todo - we should not attempt to format non-numeric strings. For now // these will not fail but will give notices on php 7.4 -- 2.25.1