Fix empty string $amount error
authorredcuillin <roland@tannerritchie.com>
Sat, 28 Jan 2023 04:11:26 +0000 (04:11 +0000)
committerredcuillin <roland@tannerritchie.com>
Sat, 28 Jan 2023 04:11:26 +0000 (04:11 +0000)
CRM/Utils/Number.php

index 790fdd1278e233b90f54f94591226b5e065c0a80..5262c3510600a094ce5c75bbbb6bcfa81a8889bb 100644 (file)
@@ -117,6 +117,10 @@ class CRM_Utils_Number {
    * @throws \Brick\Money\Exception\UnknownCurrencyException
    */
   public static function formatLocaleNumeric(string $amount, $locale = NULL): string {
+    if ($amount === "") {
+      return $amount;
+    }
+
     $formatter = new \NumberFormatter($locale ?? CRM_Core_I18n::getLocale(), NumberFormatter::DECIMAL);
     $formatter->setSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, CRM_Core_Config::singleton()->monetaryDecimalPoint);
     $formatter->setSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, CRM_Core_Config::singleton()->monetaryThousandSeparator);