From e49e825ef483c515f5dd206b88a74928f280eb46 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 6 Feb 2020 14:56:41 -0500 Subject: [PATCH] dev/core#1019 Calculate.tpl: fix the Total Amount currency formatting. --- templates/CRM/Price/Form/Calculate.tpl | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/templates/CRM/Price/Form/Calculate.tpl b/templates/CRM/Price/Form/Calculate.tpl index 5ef0a00c5e..66c6ca1126 100644 --- a/templates/CRM/Price/Form/Calculate.tpl +++ b/templates/CRM/Price/Form/Calculate.tpl @@ -158,8 +158,8 @@ 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 totalEventFee = formatMoney( totalfee, 2, separator, thousandMarker); - document.getElementById('pricevalue').innerHTML = ""+symbol+" "+totalEventFee; + var totalFormattedFee = CRM.formatMoney(totalfee); + cj('#pricevalue').html(totalFormattedFee); cj('#total_amount').val( totalfee ); cj('#pricevalue').data('raw-total', totalfee).trigger('change'); @@ -172,16 +172,5 @@ function display(totalfee) { } } -//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) : ""); -} - {/literal} -- 2.25.1