Merge pull request #14103 from jitendrapurohit/core-889
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 10 Jun 2019 15:31:40 +0000 (10:31 -0500)
committerGitHub <noreply@github.com>
Mon, 10 Jun 2019 15:31:40 +0000 (10:31 -0500)
dev/core#889 - Refund throws a fatal error if the main contribution a…

CRM/Financial/BAO/Payment.php

index 1683e2e31b957e3b63218fea17a314423cd1a05a..be7c9042585ed21a1b1105fb82f69eac53da6a0d 100644 (file)
@@ -350,7 +350,10 @@ class CRM_Financial_BAO_Payment {
         if ($lineItemValue['qty'] == 0) {
           continue;
         }
-        $paid = $lineItemValue['line_total'] * ($financialTrxn->total_amount / $contributionDAO->total_amount);
+        $paid = $financialTrxn->total_amount;
+        if (!empty(floatval($contributionDAO->total_amount))) {
+          $paid = $lineItemValue['line_total'] * ($financialTrxn->total_amount / $contributionDAO->total_amount);
+        }
         $addFinancialEntry = [
           'transaction_date' => $financialTrxn->trxn_date,
           'contact_id' => $contributionDAO->contact_id,