--CRM-16259, set is_payment flag for non pending statuses payments
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 16 Dec 2015 11:36:58 +0000 (17:06 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Fri, 18 Dec 2015 12:35:57 +0000 (18:05 +0530)
CRM/Contribute/BAO/Contribution.php

index 7e261629b879d62ace7e5d3407a6464272ed8887..0bd626ac6109b28a07544c27b6abd08ba1678053 100644 (file)
@@ -2999,6 +2999,11 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
         $balanceTrxnParams['status_id'] = $statusId;
         $balanceTrxnParams['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
         $balanceTrxnParams['check_number'] = CRM_Utils_Array::value('check_number', $params);
+        if (!empty($balanceTrxnParams['from_financial_account_id']) &&
+          ($statusId == array_search('Completed', $contributionStatuses) || $statusId == array_search('Partially paid', $contributionStatuses))
+        ) {
+          $balanceTrxnParams['is_payment'] = 1;
+        }
         if (!empty($params['payment_processor'])) {
           $balanceTrxnParams['payment_processor_id'] = $params['payment_processor'];
         }
@@ -3057,7 +3062,10 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
       if ($contributionStatus == 'Refunded') {
         $trxnParams['trxn_date'] = !empty($params['contribution']->cancel_date) ? $params['contribution']->cancel_date : date('YmdHis');
       }
-
+      //CRM-16259, set is_payment flag for non pending status
+      if (!in_array(CRM_Utils_Array::value('contribution_status_id', $params), $pendingStatus)) {
+        $trxnParams['is_payment'] = 1;
+      }
       if (!empty($params['payment_processor'])) {
         $trxnParams['payment_processor_id'] = $params['payment_processor'];
       }