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;
}