CRM-16611 fix - Fatal error on batch processing membership when Payment status =...
authormonishdeb <monish.deb@webaccessglobal.com>
Tue, 16 Jun 2015 07:19:39 +0000 (12:49 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Tue, 16 Jun 2015 07:19:39 +0000 (12:49 +0530)
https://issues.civicrm.org/jira/browse/CRM-16611

CRM/Contribute/BAO/Contribution.php

index 062d8ab24faacd4a1179bf5edc801e9cb2e45bdf..a4ab84a2a4f1a1f9bfd89c8f5ad63834a32d8b3d 100644 (file)
@@ -2736,7 +2736,7 @@ WHERE  contribution_id = %1 ";
         if (!empty($params['payment_processor'])) {
           $balanceTrxnParams['payment_processor_id'] = $params['payment_processor'];
         }
-        CRM_Core_BAO_FinancialTrxn::create($balanceTrxnParams);
+        $financialTxn = CRM_Core_BAO_FinancialTrxn::create($balanceTrxnParams);
       }
     }
 
@@ -2927,8 +2927,9 @@ WHERE  contribution_id = %1 ";
       CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update);
     }
 
-    // create batch entry if batch_id is passed
-    if (!empty($params['batch_id'])) {
+    // create batch entry if batch_id is passed and
+    // ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
+    if (!empty($params['batch_id']) && !empty($financialTxn)) {
       $entityParams = array(
         'batch_id' => $params['batch_id'],
         'entity_table' => 'civicrm_financial_trxn',