diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index f80f9ebd2857..8671dc81bc1e 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -501,6 +501,8 @@ public function buildQuickForm() { return; } $allPanes = array(); + //tax rate from financialType + $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates())); // build price set form. $buildPriceSet = FALSE; diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 43cb11fa4d02..572b2804cf91 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -327,7 +327,7 @@ static function processPriceSet($entityId, $lineItem, $contributionDetails = NUL $lineItems = CRM_Price_BAO_LineItem::create($line); if (!$update && $contributionDetails) { CRM_Financial_BAO_FinancialItem::add($lineItems, $contributionDetails); - if (isset($contributionDetails->tax_trxn_id) && !empty($contributionDetails->tax_trxn_id)) { + if (isset($contributionDetails->tax_trxn_id) && !empty($contributionDetails->tax_trxn_id) && isset($line['tax_amount'])) { CRM_Financial_BAO_FinancialItem::add($lineItems, $contributionDetails, TRUE); } } diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 7c5597dac574..3859d1eab6e0 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -119,6 +119,7 @@ {if $ppID}{ts}adjust payment amount{/ts}{help id="adjust-payment-amount"}{/if}
{ts}Total amount of this contribution.{/ts}{if $hasPriceSets} {ts}Alternatively, you can use a price set.{/ts}{/if} +
@@ -621,5 +622,26 @@ cj('#fee_amount').change( function() { cj('#net_amount').val(netAmount); } }); + +cj("#financial_type_id").on("change",function(){ + cj('#total_amount').trigger("change"); +}) + +cj('#total_amount').on("change",function(event) { +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]; + if (!taxRate) { + taxRate = 0; + } + var totalAmount = cj('#total_amount').val(); + var totalTaxAmount = Number((taxRate/100)*totalAmount)+Number(totalAmount); + cj( "#totalTaxAmount" ).html('Total Amount : '+totalTaxAmount); + event.handled = true; + } + return false; +}); {/literal}