diff --git a/site/controllers/statement_entries_controller.php b/site/controllers/statement_entries_controller.php index c14333f..b931e75 100644 --- a/site/controllers/statement_entries_controller.php +++ b/site/controllers/statement_entries_controller.php @@ -47,7 +47,17 @@ class StatementEntriesController extends AppController { if (!empty($params['post']['custom']['statement_entry_id'])) { $link['ChargeEntry'] = array(); - $link['DisbursementEntry'] = array(); + // This query actually represents a union... + // Unpaid Charge/Surplus: ChargeID - NULL; DisbursementID - NULL + // Paid Charge/Refund: ChargeID - NULL; DisbursementID - !NULL + // Disbursement/Reversal: ChargeID - !NULL; DisbursementID - NULL + // : ChargeID - !NULL; DisbursementID - !NULL + // + // The query is really slow unless we add the `id` condition to the join. + // A cleaner query would be nice, but we must work within the Cake framework. + $link['DisbursementEntry'] = array('conditions' => + '`DisbursementEntry`.`id` = ' + . $params['post']['custom']['statement_entry_id']); } return array('link' => $link);