Skip to content

Commit

Permalink
Merge pull request civicrm#24 from pratikshad/VAT-500
Browse files Browse the repository at this point in the history
Display amount including tax on Offline Contribution
  • Loading branch information
pradpnayak committed Jul 3, 2014
2 parents 32b6da4 + 98b1964 commit 0320e90
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Price/BAO/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
22 changes: 22 additions & 0 deletions templates/CRM/Contribute/Form/Contribution.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@

{if $ppID}{ts}<a href='#' onclick='adjustPayment();'>adjust payment amount</a>{/ts}{help id="adjust-payment-amount"}{/if}
<br /><span class="description">{ts}Total amount of this contribution.{/ts}{if $hasPriceSets} {ts}Alternatively, you can use a price set.{/ts}{/if}</span>
<br /><span id="totalTaxAmount" class="label"></span>
</td>
</tr>

Expand Down Expand Up @@ -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;
});
</script>
{/literal}

0 comments on commit 0320e90

Please sign in to comment.