From 01096c1b104c9abab9d3dba97b58125587b0fbf6 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Tue, 17 May 2016 18:22:59 +0530 Subject: [PATCH] CRM-18405: When creating a contribution in the back-end, total amount is incorrect --- .../CRM/Contribute/Form/Contribution.tpl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 6c48e96a64..d9dc0c0f26 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -608,11 +608,14 @@ function showStartDate( ) { } {/literal}{/if}{literal} +var thousandMarker = "{/literal}{$config->monetaryThousandSeparator}{literal}"; +var separator = "{/literal}{$config->monetaryDecimalPoint}{literal}"; + cj('#fee_amount').change( function() { - var totalAmount = cj('#total_amount').val(); - var feeAmount = cj('#fee_amount').val(); - var netAmount = totalAmount.replace(/,/g, '') - feeAmount.replace(/,/g, ''); - if (!cj('#net_amount').val() && totalAmount) { + var totalAmount = cj('#total_amount').val().replace(thousandMarker,'').replace(separator,'.'); + var feeAmount = cj('#fee_amount').val().replace(thousandMarker,'').replace(separator,'.'); + var netAmount = totalAmount - feeAmount; + if (totalAmount) { cj('#net_amount').val(CRM.formatMoney(netAmount, true)); } }); @@ -650,16 +653,14 @@ CRM.$(function($) { cj("#totalTaxAmount").show( ); } var totalAmount = $('#total_amount').val(); - var thousandMarker = '{/literal}{$config->monetaryThousandSeparator}{literal}'; - var seperator = '{/literal}{$config->monetaryDecimalPoint}{literal}'; - // replace all thousandMarker and change the seperator to a dot - totalAmount = totalAmount.replace(thousandMarker,'').replace(seperator,'.'); + // replace all thousandMarker and change the separator to a dot + totalAmount = totalAmount.replace(thousandMarker,'').replace(separator,'.'); var totalTaxAmount = '{/literal}{$totalTaxAmount}{literal}'; var taxAmount = (taxRate/100)*totalAmount; taxAmount = isNaN (taxAmount) ? 0:taxAmount; var totalTaxAmount = taxAmount + Number(totalAmount); - totalTaxAmount = formatMoney( totalTaxAmount, 2, seperator, thousandMarker ); + totalTaxAmount = formatMoney( totalTaxAmount, 2, separator, thousandMarker ); $("#totalTaxAmount" ).html('Amount with tax : ' + currencySymbol + ' '+ totalTaxAmount); } -- 2.25.1