Skip to content

Commit

Permalink
Fix divide by zero on 100% discount
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jan 20, 2018
1 parent 730ed80 commit c627727
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -5687,15 +5687,17 @@ public static function getSalesTaxFinancialAccounts() {
* Create tax entry in civicrm_entity_financial_trxn table.
*
* @param array $entityParams
*
* @param array $eftParams
*
*/
public static function createProportionalEntry($entityParams, $eftParams) {
$paid = $entityParams['line_item_amount'] * ($entityParams['trxn_total_amount'] / $entityParams['contribution_total_amount']);
// Record Entity Financial Trxn; CRM-20145
$eftParams['amount'] = CRM_Contribute_BAO_Contribution_Utils::formatAmount($paid);
civicrm_api3('EntityFinancialTrxn', 'create', $eftParams);
$contributionTotalAmount = (float) $entityParams['contribution_total_amount'];
if (!empty($contributionTotalAmount)) {
$paid = $entityParams['line_item_amount'] * ($entityParams['trxn_total_amount'] / $entityParams['contribution_total_amount']);
// Record Entity Financial Trxn; CRM-20145
$eftParams['amount'] = CRM_Contribute_BAO_Contribution_Utils::formatAmount($paid);
civicrm_api3('EntityFinancialTrxn', 'create', $eftParams);
}
}

/**
Expand Down

0 comments on commit c627727

Please sign in to comment.