From 19723a17129964fb60c3ab7492e0fa7a3bab1e64 Mon Sep 17 00:00:00 2001 From: Alan Dixon Date: Tue, 25 Apr 2023 15:10:44 -0400 Subject: [PATCH] select the most recent membership payment in the inner join --- CRM/Report/Form/Member/Detail.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form/Member/Detail.php b/CRM/Report/Form/Member/Detail.php index 527f42725c..eb79610c47 100644 --- a/CRM/Report/Form/Member/Detail.php +++ b/CRM/Report/Form/Member/Detail.php @@ -296,7 +296,8 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { if ($this->isTableSelected('civicrm_contribution')) { $this->_from .= " LEFT JOIN civicrm_membership_payment cmp - ON {$this->_aliases['civicrm_membership']}.id = cmp.membership_id + ON ({$this->_aliases['civicrm_membership']}.id = cmp.membership_id + AND cmp.id = (SELECT MAX(id) FROM civicrm_membership_payment WHERE civicrm_membership_payment.membership_id = {$this->_aliases['civicrm_membership']}.id)) LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} ON cmp.contribution_id={$this->_aliases['civicrm_contribution']}.id\n"; } -- 2.25.1