Commit e05f4870 authored by eileen's avatar eileen 🎱 Committed by GitHub

Merge pull request #9866 from lcdservices/CRM-20145

CRM-20145 line_item $0 entity_financial_trxn fix
parents 4a6f91c1 d291b097
......@@ -5417,8 +5417,8 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
*/
public static function createProportionalEntry($entityParams, $eftParams) {
$paid = $entityParams['line_item_amount'] * ($entityParams['trxn_total_amount'] / $entityParams['contribution_total_amount']);
// Record Entity Financial Trxn
$eftParams['amount'] = round($paid, 2);
// Record Entity Financial Trxn; CRM-20145
$eftParams['amount'] = CRM_Contribute_BAO_Contribution_Utils::formatAmount($paid);
civicrm_api3('EntityFinancialTrxn', 'create', $eftParams);
}
......
......@@ -481,4 +481,20 @@ LIMIT 1
return $taxAmount;
}
/**
* Format monetary amount: round and return to desired decimal place
* CRM-20145
*
* @param float $amount
* Monetary amount
* @param int $decimals
* How many decimal places to round to and return
*
* @return float
* Amount rounded and returned with the desired decimal places
*/
public static function formatAmount($amount, $decimals = 2) {
return number_format((float) round($amount, (int) $decimals), (int) $decimals, '.', '');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment