CRM-13170, fixed the query to respect batch criteria
authorkurund <kurund@civicrm.org>
Sat, 10 Aug 2013 12:18:53 +0000 (17:48 +0530)
committerkurund <kurund@civicrm.org>
Sat, 10 Aug 2013 12:18:53 +0000 (17:48 +0530)
----------------------------------------
* CRM-13170: Search Contribution by Batch no longer works since change to DB
  http://issues.civicrm.org/jira/browse/CRM-13170

CRM/Contribute/BAO/Query.php

index cde8746fae1d0c71e3284bbc821ce04a75cefb94..10c7b8506092bae08c74ad08428d148b1ba1d0ef 100644 (file)
@@ -678,8 +678,16 @@ class CRM_Contribute_BAO_Query {
         break;
 
       case 'contribution_batch':
-        $from .= " $side JOIN civicrm_entity_batch ON ( civicrm_entity_batch.entity_table = 'civicrm_contribution' AND
-          civicrm_contribution.id = civicrm_entity_batch.entity_id )";
+        $from .= " $side JOIN civicrm_entity_financial_trxn ON (
+        civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution'
+        AND civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id )";
+
+        $from .= " $side JOIN civicrm_financial_trxn ON (
+        civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id )";
+
+        $from .= " $side JOIN civicrm_entity_batch ON ( civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
+        AND civicrm_financial_trxn.id = civicrm_entity_batch.entity_id )";
+
         $from .= " $side JOIN civicrm_batch ON civicrm_entity_batch.batch_id = civicrm_batch.id";
         break;
     }