From 36aff7b7d587dfb5a099846d144218356ab298d0 Mon Sep 17 00:00:00 2001 From: Eileen Date: Mon, 2 May 2016 10:50:09 +0000 Subject: [PATCH] CRM-18488 also add next_scheduled_amount Note that the code previously would have been inaccurate in the rare situation where pledge payments had been edited to the point where the ids were not in date order. I have added a fix for that, although if it would be possible to go further & create a temp table for performance --- CRM/Report/Form/Pledge/Detail.php | 3 +-- CRM/Report/Form/Pledge/Pbnp.php | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index 0190fa10fa..7d4ba3b08c 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -54,8 +54,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { ); /** - */ - /** + * Class constructor. */ public function __construct() { $this->_pledgeStatuses = CRM_Contribute_PseudoConstant::contributionStatus(); diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index 9bc182e71e..e98b87b478 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -149,6 +149,10 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { 'type' => CRM_Utils_Type::T_DATE, 'required' => TRUE, ), + 'scheduled_amount' => array( + 'type' => CRM_Utils_Type::T_MONEY, + 'title' => 'Next Payment Amount', + ), ), 'filters' => array( 'scheduled_date' => array( @@ -270,7 +274,11 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { ON ({$this->_aliases['civicrm_pledge']}.contact_id = {$this->_aliases['civicrm_contact']}.id) AND {$this->_aliases['civicrm_pledge']}.status_id IN ( {$statusIds} ) - LEFT JOIN civicrm_pledge_payment {$this->_aliases['civicrm_pledge_payment']} + LEFT JOIN "; + + // Note that the derived query protects us from providing inaccurate data in the edge case where pledge + // payments have been edited such that they are not in id order. This might be better as a temp table. + $this->_from .= "(SELECT * FROM civicrm_pledge_payment ORDER BY scheduled_date) as {$this->_aliases['civicrm_pledge_payment']} ON ({$this->_aliases['civicrm_pledge']}.id = {$this->_aliases['civicrm_pledge_payment']}.pledge_id AND {$this->_aliases['civicrm_pledge_payment']}.status_id = {$pendingStatus} ) "; -- 2.25.1