CRM-21721, fixed notice error for Division by zero
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 29 Jan 2018 05:13:03 +0000 (10:43 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 29 Jan 2018 05:13:03 +0000 (10:43 +0530)
----------------------------------------
* CRM-21721: Notice : Division by zero
  https://issues.civicrm.org/jira/browse/CRM-21721

CRM/Contribute/BAO/Contribution.php

index b4fe8f809a88d614b96a4a9ced7414cbe948e815..b7fdedacbb660a1f781cc1813a243263ebcc8f60 100644 (file)
@@ -5692,7 +5692,10 @@ LIMIT 1;";
    *
    */
   public static function createProportionalEntry($entityParams, $eftParams) {
-    $paid = $entityParams['line_item_amount'] * ($entityParams['trxn_total_amount'] / $entityParams['contribution_total_amount']);
+    $paid = 0;
+    if ($entityParams['contribution_total_amount'] != 0) {
+      $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);