From 4853b1a2db743f0f7be2972cd9c8bf15b36ef0c0 Mon Sep 17 00:00:00 2001 From: Brian Shaughnessy Date: Fri, 30 Oct 2015 15:42:08 -0400 Subject: [PATCH] CRM-17467 contrib detail report - batch records --- CRM/Report/Form/Contribute/Detail.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 0f31dd786b..2659c804d4 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -484,13 +484,17 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { !empty($this->_params['bid_value'])) ) { $this->_from .= " - LEFT JOIN civicrm_entity_financial_trxn tx ON (tx.entity_id = {$this->_aliases['civicrm_contribution']}.id AND - tx.entity_table = 'civicrm_contribution') - LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_entity_batch']} - ON ({$this->_aliases['civicrm_entity_batch']}.entity_id = tx.financial_trxn_id AND - {$this->_aliases['civicrm_entity_batch']}.entity_table = 'civicrm_financial_trxn') - LEFT JOIN civicrm_batch {$this->_aliases['civicrm_batch']} - ON {$this->_aliases['civicrm_batch']}.id = {$this->_aliases['civicrm_entity_batch']}.batch_id"; + LEFT JOIN ( + SELECT entity_id, financial_trxn_id + FROM civicrm_entity_financial_trxn + WHERE entity_table = 'civicrm_contribution' + GROUP BY entity_id + ) tx ON tx.entity_id = {$this->_aliases['civicrm_contribution']}.id + LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_entity_batch']} + ON ({$this->_aliases['civicrm_entity_batch']}.entity_id = tx.financial_trxn_id + AND {$this->_aliases['civicrm_entity_batch']}.entity_table = 'civicrm_financial_trxn') + LEFT JOIN civicrm_batch {$this->_aliases['civicrm_batch']} + ON {$this->_aliases['civicrm_batch']}.id = {$this->_aliases['civicrm_entity_batch']}.batch_id"; } } -- 2.25.1