Skip to content

Commit

Permalink
Merge pull request #16487 from mlutfy/core1019
Browse files Browse the repository at this point in the history
dev/core#1019 Calculate.tpl: fix the Total Amount currency formatting.
  • Loading branch information
yashodha authored Feb 10, 2020
2 parents e9ada0a + 5b3bb90 commit 0e840f3
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions templates/CRM/Price/Form/Calculate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,27 @@ function calculateTotalFee() {
* Display calculated amount.
*/
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 = CRM.formatMoney(totalfee);
cj('#pricevalue').html(totalFormattedFee);
// 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 totalEventFee = formatMoney( totalfee, 2, separator, thousandMarker);
document.getElementById('pricevalue').innerHTML = "<b>"+symbol+"</b> "+totalEventFee;
cj('#total_amount').val( totalfee );
cj('#pricevalue').data('raw-total', totalfee).trigger('change');
cj('#total_amount').val( totalfee );
cj('#pricevalue').data('raw-total', totalfee).trigger('change');
( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled');
if (typeof skipPaymentMethod == 'function') {
// Advice to anyone who, like me, feels hatred towards this if construct ... if you remove the if you
// get an error on participant 2 of a event that requires approval & permits multiple registrants.
skipPaymentMethod();
}
}
if (totalfee < 0) {
cj('table#pricelabel').addClass('disabled');
}
else {
cj('table#pricelabel').removeClass('disabled');
}
//money formatting/localization
function formatMoney (amount, c, d, t) {
var n = amount,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "," : d,
t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
if (typeof skipPaymentMethod == 'function') {
// Advice to anyone who, like me, feels hatred towards this if construct ... if you remove the if you
// get an error on participant 2 of a event that requires approval & permits multiple registrants.
skipPaymentMethod();
}
}
{/literal}
Expand Down

0 comments on commit 0e840f3

Please sign in to comment.