Skip to content

Commit

Permalink
CRM-19585, added function to Calculate Tax when Financial Type is cha…
Browse files Browse the repository at this point in the history
…nged.

----------------------------------------
* CRM-19585: Sales tax issue
  https://issues.civicrm.org/jira/browse/CRM-19585
  • Loading branch information
pradpnayak authored and monishdeb committed Apr 17, 2017
1 parent c5860d9 commit b610400
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -5570,6 +5570,33 @@ public static function calculateTaxAfterChangeInFinancialTypeForLineItems($lineI
}
}
return $taxAmount;

/**
* Calculate Tax when Financial Type is changed.
*
* @param array $params
* @param float $totalAmount
* @param array $oldTaxAmounts
* @param float $changeFTAmount
*
*/
public static function calculateTaxForChangeInFinancialType(
&$params, &$totalAmount,
&$oldTaxAmounts, &$changeFTAmount
) {
$taxAmountAfterFTChange = self::calculateTaxAfterChangeInFinancialTypeForLineItems($params['line_item'], $params['contribution']->id);
$previousTaxAmount = 0;
if (isset($params['prevContribution']->tax_amount)) {
$previousTaxAmount = $params['prevContribution']->tax_amount;
}
$taxDiff = $taxAmountAfterFTChange - $previousTaxAmount;
$changeFTAmount += $taxDiff;
$totalAmount -= $taxDiff;
if ($taxDiff > 0) {
$params['tax_amount'] = $taxAmountAfterFTChange;
$oldTaxAmounts['new_tax_amount'] -= $taxDiff;
$oldTaxAmounts['previous_tax_amount'] = $taxAmountAfterFTChange - $taxDiff;
}
}

}

0 comments on commit b610400

Please sign in to comment.