CRM-20797, fixed sql to use is_payment = 1 to get payments
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 20 Jun 2017 19:08:56 +0000 (00:38 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Fri, 30 Jun 2017 12:24:22 +0000 (17:54 +0530)
----------------------------------------
* CRM-20797: Use is_payment to retrieve payments
  https://issues.civicrm.org/jira/browse/CRM-20797

CRM/Core/BAO/FinancialTrxn.php

index d09ac055180bce50eb42607fcfc115f250ca15c7..bfd11e3fc91e6ddba6492b614023019b9d7c4e76 100644 (file)
@@ -475,25 +475,6 @@ WHERE ceft.entity_id = %1";
       $statusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
       $refundStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
 
-      $filteredFinancialAccounts = array();
-      $filteredFinancialAccountRel = array(
-        'Accounts Receivable Account is',
-        'Expense Account is',
-      );
-      if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
-        $filteredFinancialAccountRel = array_merge($filteredFinancialAccountRel, array(
-          'Deferred Revenue Account is',
-          'Income Account is',
-        ));
-      }
-
-      foreach ($filteredFinancialAccountRel as $financialAccountRel) {
-        $financialAccount = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($financialTypeId, $financialAccountRel);
-        if ($financialAccount) {
-          $filteredFinancialAccounts[] = $financialAccount;
-        }
-      }
-
       if (empty($lineItemTotal)) {
         $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($contributionId);
       }
@@ -501,7 +482,7 @@ WHERE ceft.entity_id = %1";
 SELECT SUM(ft.total_amount)
 FROM civicrm_financial_trxn ft
   INNER JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution' AND eft.entity_id = {$contributionId})
-WHERE ft.to_financial_account_id NOT IN ( " . implode(', ', $filteredFinancialAccounts) . " )
+WHERE ft.is_payment = 1
   AND ft.status_id IN ({$statusId}, {$refundStatusId})
 ";