From 54d8de6b4b8a3111cc4d9de439cac11647c1230c Mon Sep 17 00:00:00 2001 From: Edsel Date: Thu, 23 Apr 2015 18:38:32 +0530 Subject: [PATCH] CIVI-28 Bug fixes --- CRM/Contribute/BAO/Contribution.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 743705f724..21aab16aa9 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -792,15 +792,24 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { if ($endDate) { $where[] = "receive_date <= '" . CRM_Utils_Type::escape($endDate, 'Timestamp') . "'"; } + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes); + if ($financialTypes) { + $where[] = "c.financial_type_id IN (" . implode(',' , array_keys($financialTypes)) . ")"; + $where[] = "i.financial_type_id IN (" . implode(',' , array_keys($financialTypes)) . ")"; + } + else { + $where[] = "c.financial_type_id IN (0)"; + } $whereCond = implode(' AND ', $where); $query = " SELECT sum( total_amount ) as total_amount, - count( civicrm_contribution.id ) as total_count, + count( c.id ) as total_count, currency - FROM civicrm_contribution -INNER JOIN civicrm_contact contact ON ( contact.id = civicrm_contribution.contact_id ) + FROM civicrm_contribution c +INNER JOIN civicrm_contact contact ON ( contact.id = c.contact_id ) +LEFT JOIN civicrm_line_item i ON ( i.contribution_id = c.id AND i.entity_table = 'civicrm_contribution' ) WHERE $whereCond AND ( is_test = 0 OR is_test IS NULL ) AND contact.is_deleted = 0 -- 2.25.1