Skip to content

Commit

Permalink
dev/core#1019 Fix currency formatting of Total Amount on Event and Co…
Browse files Browse the repository at this point in the history
…ntribution pages (with multi-currency form support)
  • Loading branch information
mlutfy committed Dec 9, 2020
1 parent fb86dcb commit f59ca3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public function preProcess() {
$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->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));
Expand Down
3 changes: 3 additions & 0 deletions CRM/Event/Form/Registration/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ public function buildQuickForm() {
// 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
$this->assign('moneyFormat', CRM_Utils_Money::format(1234.56));

CRM_Core_Payment_ProcessorForm::buildQuickForm($this);

$contactID = $this->getContactID();
Expand Down
6 changes: 5 additions & 1 deletion templates/CRM/Price/Form/Calculate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
var thousandMarker = '{/literal}{$config->monetaryThousandSeparator}{literal}';
var separator = '{/literal}{$config->monetaryDecimalPoint}{literal}';
var symbol = '{/literal}{$currencySymbol}{literal}';
var moneyFormat = '{/literal}{$moneyFormat}{literal}';
var optionSep = '|';
// Recalculate the total fees based on user selection
Expand Down Expand Up @@ -161,7 +162,10 @@ 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, to support
// forms using a currency other that the site default. Also make sure to
// support various currency formatting options, supported by formatMoney.
var totalFormattedFee = CRM.formatMoney(totalfee, false, moneyFormat);
cj('#pricevalue').html(totalFormattedFee);
cj('#total_amount').val( totalfee );
Expand Down

0 comments on commit f59ca3b

Please sign in to comment.