From e136edcf8faa5030464f1191589cd1b40a715d8e Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Thu, 3 Dec 2015 16:19:25 +1300 Subject: [PATCH] CRM-17653 fix membership renewal to record contribution_recur_id on contribution --- CRM/Member/BAO/Membership.php | 1 + CRM/Member/Form/MembershipRenewal.php | 5 ++++- tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 65bda4dde2..e1e7b3ada1 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -2384,6 +2384,7 @@ WHERE civicrm_membership.is_test = 0"; 'membership_id', 'tax_amount', 'skipLineItem', + 'contribution_recur_id', ); foreach ($recordContribution as $f) { $contributionParams[$f] = CRM_Utils_Array::value($f, $params); diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 45f27a228c..12120b3bc2 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -641,7 +641,10 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { // not a great pattern & ideally it would not receive as a reference. We assign our params as a // temporary variable to avoid e-notice & to make it clear to future refactorer that // this function is NOT reliant on that var being set - $temporaryParams = array_merge($this->_params, array('membership_id' => $renewMembership->id)); + $temporaryParams = array_merge($this->_params, array( + 'membership_id' => $renewMembership->id, + 'contribution_recur_id' => $contributionRecurID, + )); CRM_Member_BAO_Membership::recordMembershipContribution($temporaryParams); } diff --git a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php index baeda99bfd..006a3008ab 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php @@ -279,6 +279,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Credit Card'), $contribution['payment_instrument_id']); + $this->assertEquals($contributionRecur['id'], $contribution['contribution_recur_id']); $this->callAPISuccessGetCount('LineItem', array( 'entity_id' => $membership['id'], -- 2.25.1