From 98b1964d8283db623c049f27b12afdde2655562d Mon Sep 17 00:00:00 2001 From: pratikshad Date: Wed, 2 Jul 2014 16:46:36 +0530 Subject: [PATCH] Optimization of code --- templates/CRM/Contribute/Form/Contribution.tpl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 7b5a87b91b4d..3859d1eab6e0 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -632,14 +632,12 @@ if(event.handled !== true) { var financialType = cj('#financial_type_id').val(); var taxRates = '{/literal}{$taxRates}{literal}'; var taxRates = JSON.parse(taxRates); - var taxRate = taxRates[financialType]; + var taxRate = taxRates[financialType]; + if (!taxRate) { + taxRate = 0; + } var totalAmount = cj('#total_amount').val(); - if (taxRate) { - var totalTaxAmount = Number((taxRate/100)*totalAmount)+Number(totalAmount); - } - else { - totalTaxAmount = totalAmount ; - } + var totalTaxAmount = Number((taxRate/100)*totalAmount)+Number(totalAmount); cj( "#totalTaxAmount" ).html('Total Amount : '+totalTaxAmount); event.handled = true; }