From 5b3bb90c3a96867b371fe0514aaeedfad8aaa649 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 6 Feb 2020 15:05:04 -0500 Subject: [PATCH] dev/core#1019 Calculate.tpl: fix the Total Amount currency formatting (code reformatting). --- templates/CRM/Price/Form/Calculate.tpl | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/templates/CRM/Price/Form/Calculate.tpl b/templates/CRM/Price/Form/Calculate.tpl index 66c6ca1126..153fb4af44 100644 --- a/templates/CRM/Price/Form/Calculate.tpl +++ b/templates/CRM/Price/Form/Calculate.tpl @@ -154,22 +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 totalFormattedFee = CRM.formatMoney(totalfee); - cj('#pricevalue').html(totalFormattedFee); + 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'); + if (totalfee < 0) { + cj('table#pricelabel').addClass('disabled'); + } + else { + cj('table#pricelabel').removeClass('disabled'); + } - ( 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 (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} -- 2.25.1