From 86f01e6cd3eefc41ac2323fbd4359c3912c68460 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 3 Aug 2016 05:53:16 +0530 Subject: [PATCH] CRM-16189, more changes to the code ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- .../Form/Contribute/DeferredRevenue.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/CRM/Report/Form/Contribute/DeferredRevenue.php b/CRM/Report/Form/Contribute/DeferredRevenue.php index 6a45c04dc9..e5e6dc65ab 100644 --- a/CRM/Report/Form/Contribute/DeferredRevenue.php +++ b/CRM/Report/Form/Contribute/DeferredRevenue.php @@ -281,7 +281,7 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} ON {$this->_aliases[' } public function postProcess() { - $this->_noFields = FALSE; + $this->_noFields = TRUE; // get ready with post process params $this->beginPostProcess(); @@ -303,6 +303,16 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} ON {$this->_aliases[' $this->endPostProcess($rows); } + /** + * Build where clause. + */ + public function where() { + parent::where(); + $startDate = date('Y-m-01'); + $endDate = date('Y-m-t', strtotime(date('ymd') . '+11 month')); + $this->_where .= " AND {$this->_aliases['civicrm_financial_trxn_1']}.trxn_date BETWEEN '{$startDate}' AND '{$endDate}'"; + } + public function groupBy() { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_financial_account']}.id, {$this->_aliases['civicrm_financial_account_1']}.id, {$this->_aliases['civicrm_financial_item']}.id"; } @@ -333,6 +343,10 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} ON {$this->_aliases[' 'End Date' => 1, ); $dateFormat = Civi::settings()->get('dateformatFinancialBatch'); + for ($i = 0; $i < 12; $i++) { + //$columns[date('M, Y', strtotime("+1 month", date('Y-m-d')))] = 1; + $columns[date('M, Y', strtotime(date('Y-m-d') . "+{$i} month"))] = 1; + } while ($dao->fetch()) { $arraykey = $dao->civicrm_financial_account_id . '_' . $dao->civicrm_financial_account_1_id; if (empty($rows[$arraykey])) { @@ -354,14 +368,12 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} ON {$this->_aliases[' $trxnAmount = explode(',', $dao->civicrm_financial_trxn_1_total_amount); foreach ($trxnDate as $key => $date) { $keyDate = date('M, Y', strtotime($date)); + if (!array_key_exists($keyDate, $columns)) { + continue; + } $rows[$arraykey]['rows'][$dao->civicrm_financial_item_id][$keyDate] = CRM_Utils_Money::format($trxnAmount[$key]); - $dateColumn[date('Ymd', strtotime($date))] = 1; } } - ksort($dateColumn); - foreach ($dateColumn as $key => $ignore) { - $columns[date('M, Y', strtotime($key))] = 1; - } $this->_columnHeaders = $columns; } /** -- 2.25.1