Use specific function when formatting money for a default
authorMonish Deb <monish.deb@jmaconsulting.biz>
Mon, 15 Feb 2021 14:02:53 +0000 (19:32 +0530)
committerMonish Deb <monish.deb@jmaconsulting.biz>
Mon, 15 Feb 2021 14:02:53 +0000 (19:32 +0530)
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/CustomGroup.php
CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipConfig.php
CRM/Member/Page/AJAX.php
CRM/Member/Tokens.php
CRM/PCP/Form/Campaign.php

index 2ca7070c76cb464c25e66bf1e7ae4793cde6f19a..3057d18153f164b3be6f6c9ca4506a1db4fa52de 100644 (file)
@@ -1187,7 +1187,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         if ($field['data_type'] == 'Money' && isset($value)) {
           // $value can also be an array(while using IN operator from search builder or api).
           foreach ((array) $value as $val) {
-            $disp[] = CRM_Utils_Money::format($val, NULL, NULL, TRUE);
+            $disp[] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($val);
           }
           $display = implode(', ', $disp);
         }
index 61da4970e4f8c3e300a871d8fa73c11f9dc792c1..2ea810c725a72875eaad379a9074f7ba3aa85e65 100644 (file)
@@ -1383,7 +1383,7 @@ ORDER BY civicrm_custom_group.weight,
             elseif ($field['data_type'] == 'Money' &&
               $field['html_type'] == 'Text'
             ) {
-              $defaults[$elementName] = CRM_Utils_Money::format($value, NULL, '%a');
+              $defaults[$elementName] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($value);
             }
             else {
               $defaults[$elementName] = $value;
index 3b0b0b140ede0a05c7146f3c0c7f3a41b4e08b77..f42d033084d0fd5817d912a6d2f6b107f21e847c 100644 (file)
@@ -488,7 +488,7 @@ DESC limit 1");
       // - set the max related block
       $allMembershipInfo[$key] = [
         'financial_type_id' => $values['financial_type_id'] ?? NULL,
-        'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'),
+        'total_amount' => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($totalAmount),
         'total_amount_numeric' => $totalAmount,
         'auto_renew' => $values['auto_renew'] ?? NULL,
         'has_related' => isset($values['relationship_type_id']),
index b1a8937256377c758db56c4e69bc225af5157a80..6e887244a4563d9643e536ad1f13af12aabfdd08 100644 (file)
@@ -52,7 +52,7 @@ class CRM_Member_Form_MembershipConfig extends CRM_Core_Form {
     }
 
     if (isset($defaults['minimum_fee'])) {
-      $defaults['minimum_fee'] = CRM_Utils_Money::format($defaults['minimum_fee'], NULL, '%a');
+      $defaults['minimum_fee'] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($defaults['minimum_fee']);
     }
 
     if (isset($defaults['status'])) {
index c9e14a83a948bdcf0546ca872bb53ead9e67945d..ce7ecd79ba50b32994f627c42dfa85b4a1d90020 100644 (file)
@@ -46,7 +46,7 @@ WHERE   id = %1";
     }
     $details['total_amount_numeric'] = $details['total_amount'];
     // fix the display of the monetary value, CRM-4038
-    $details['total_amount'] = CRM_Utils_Money::format($details['total_amount'], NULL, '%a');
+    $details['total_amount'] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($details['total_amount']);
     $options = CRM_Core_SelectValues::memberAutoRenew();
     $details['auto_renew'] = $options[$details]['auto_renew'] ?? NULL;
     CRM_Utils_JSON::output($details);
index 64d3e5b79c583f93cdbed05491aa27e97980be57..686cc71f4652102c7c29e474dfd94c4102fb0592 100644 (file)
@@ -79,7 +79,7 @@ class CRM_Member_Tokens extends \Civi\Token\AbstractTokenSubscriber {
       $row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->$field));
     }
     elseif ($field == 'fee') {
-      $row->tokens($entity, $field, \CRM_Utils_Money::format($actionSearchResult->$field, NULL, NULL, TRUE));
+      $row->tokens($entity, $field, \CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($actionSearchResult->$field));
     }
     elseif (isset($actionSearchResult->$field)) {
       $row->tokens($entity, $field, $actionSearchResult->$field);
index 4c244a29dd9eacdc11cd6781fa7de7d84e49ae5b..6445366044aac3d33b80abd2ca04b51725221a5c 100644 (file)
@@ -65,7 +65,7 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form {
       }
       // fix the display of the monetary value, CRM-4038
       if (isset($defaults['goal_amount'])) {
-        $defaults['goal_amount'] = CRM_Utils_Money::format($defaults['goal_amount'], NULL, '%a');
+        $defaults['goal_amount'] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($defaults['goal_amount']);
       }
 
       $defaults['pcp_title'] = $defaults['title'] ?? NULL;