From b880a5ce388c55c1d29df0507e2a5dfff605d144 Mon Sep 17 00:00:00 2001 From: Edsel Date: Mon, 1 Jun 2015 17:36:52 +0530 Subject: [PATCH] ICM-14 Fixed current YTD on contributions tab --- CRM/Contribute/BAO/Contribution.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index c4eed28a11..7f323407ed 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -1197,7 +1197,7 @@ WHERE civicrm_contribution.contact_id = civicrm_contact.id $additionalWhere = " AND b.financial_type_id IN (0)"; $liWhere = " AND i.financial_type_id IN (0)"; if (!empty($financialTypes)) { - $additionalWhere = " AND b.financial_type_id IN (" . implode(',' , array_keys($financialTypes)) . ")"; + $additionalWhere = " AND b.financial_type_id IN (" . implode(',' , array_keys($financialTypes)) . ") AND i.id IS NULL"; $liWhere = " AND i.financial_type_id NOT IN (" . implode(',' , array_keys($financialTypes)) . ")"; } $query = " @@ -1206,11 +1206,13 @@ WHERE civicrm_contribution.contact_id = civicrm_contact.id avg(total_amount) as average, currency FROM civicrm_contribution b + LEFT JOIN civicrm_line_item i ON i.contribution_id = b.id AND i.entity_table = 'civicrm_contribution' $liWhere WHERE b.contact_id IN ( $contactIDs ) AND b.contribution_status_id = 1 AND b.is_test = 0 AND b.receive_date >= $startDate AND b.receive_date < $endDate + $additionalWhere GROUP BY currency "; $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); -- 2.25.1