dev/core#1019 Fix currency formatting of Total Amount on Event and Contribution pages...
authorMathieu Lutfy <mathieu@symbiotic.coop>
Wed, 9 Dec 2020 14:28:25 +0000 (09:28 -0500)
committereileen <emcnaughton@wikimedia.org>
Sat, 12 Dec 2020 00:32:05 +0000 (13:32 +1300)
CRM/Contribute/Form/Contribution/Main.php
CRM/Event/Form/Registration/Register.php
templates/CRM/Price/Form/Calculate.tpl

index 6ff333e145f9022c99553835a4dc5304880d8408..fa76918ee72240cc22257d34cdfa914e070640bd 100644 (file)
@@ -58,6 +58,13 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
 
+    // Required for currency formatting in the JS layer
+    // this is a temporary fix intended to resolve a regression quickly
+    // And assigning moneyFormat for js layer formatting
+    // will only work until that is done.
+    // https://github.com/civicrm/civicrm-core/pull/19151
+    $this->assign('moneyFormat', CRM_Utils_Money::format(1234.56));
+
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean'));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean',
       CRM_Core_DAO::$_nullObject));
index 423f635d8d588b891466dff3df6ecb423abd1aee..cc88542e02fbd9976d3bb65a6773d89d1f75749e 100644 (file)
@@ -319,6 +319,15 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     // CRM-18399: used by template to pass pre profile id as a url arg
     $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
 
+    // Required for currency formatting in the JS layer
+
+    // Required for currency formatting in the JS layer
+    // this is a temporary fix intended to resolve a regression quickly
+    // And assigning moneyFormat for js layer formatting
+    // will only work until that is done.
+    // https://github.com/civicrm/civicrm-core/pull/19151
+    $this->assign('moneyFormat', CRM_Utils_Money::format(1234.56));
+
     CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
 
     $contactID = $this->getContactID();
index dab6017c0150993adaa98bace6736fe31c759211..170334b499be0d678f6ebd6271873e9d03d16eb9 100644 (file)
 var thousandMarker = '{/literal}{$config->monetaryThousandSeparator}{literal}';
 var separator      = '{/literal}{$config->monetaryDecimalPoint}{literal}';
 var symbol         = '{/literal}{$currencySymbol}{literal}';
+// moneyFormat is part of a temporary fix. it should
+// not be expected to be present in future versions
+// see https://github.com/civicrm/civicrm-core/pull/19151
+
+var moneyFormat    = '{/literal}{$moneyFormat}{literal}';
 var optionSep      = '|';
 
 // Recalculate the total fees based on user selection
@@ -161,7 +166,13 @@ function display(totalfee) {
   // totalfee is monetary, round it to 2 decimal points so it can
   // go as a float - CRM-13491
   totalfee = Math.round(totalfee*100)/100;
-  var totalFormattedFee = symbol + ' ' + CRM.formatMoney(totalfee, true);
+  // dev/core#1019 Use the moneyFormat assigned to the template as an interim fix
+  // to support forms using a currency other that the site default. Also make sure to
+  // support various currency formatting options,
+  // temporary measure - pending
+  // our preferred fix.
+  // see https://github.com/civicrm/civicrm-core/pull/19151
+  var totalFormattedFee = CRM.formatMoney(totalfee, false, moneyFormat);
   cj('#pricevalue').html(totalFormattedFee);
 
   cj('#total_amount').val( totalfee );