From 1577b3be25bf220bdb08a4b3ecaf3248f5c3052e Mon Sep 17 00:00:00 2001 From: Andrew West Date: Wed, 27 May 2020 16:07:06 +0100 Subject: [PATCH] Remove summary row from charts, when rollup used Issue: https://lab.civicrm.org/dev/report/-/issues/40 --- CRM/Report/Form/Contribute/Summary.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 79465208aa..29dd59842e 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -764,9 +764,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { /** * Build chart. * - * @param array $rows + * @param array $original_rows */ - public function buildChart(&$rows) { + public function buildChart(&$original_rows) { $graphRows = []; if (!empty($this->_params['charts'])) { @@ -775,6 +775,14 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $contrib = !empty($this->_params['fields']['total_amount']); $softContrib = !empty($this->_params['fields']['soft_amount']); + // Make a copy so that we don't affect what gets passed later to hooks etc. + $rows = $original_rows; + if ($this->_rollup) { + // Remove the total row otherwise it overwrites the real last month's data since it has the + // same date. + array_pop($rows); + } + foreach ($rows as $key => $row) { if ($row['civicrm_contribution_receive_date_subtotal']) { $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start']; -- 2.25.1