From: Brian Shaughnessy Date: Fri, 30 Oct 2015 19:42:08 +0000 (-0400) Subject: CRM-17467 contrib detail report - batch records X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4853b1a2db743f0f7be2972cd9c8bf15b36ef0c0;p=civicrm-core.git CRM-17467 contrib detail report - batch records --- 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"; } }