CRM-17653 fix membership renewal to record contribution_recur_id on contribution
authoreileenmcnaugton <eileen@fuzion.co.nz>
Thu, 3 Dec 2015 03:19:25 +0000 (16:19 +1300)
committereileenmcnaugton <eileen@fuzion.co.nz>
Thu, 3 Dec 2015 10:15:21 +0000 (23:15 +1300)
CRM/Member/BAO/Membership.php
CRM/Member/Form/MembershipRenewal.php
tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php

index 65bda4dde24b5470cfd313ae72d5cee11cd64f41..e1e7b3ada1b83fae921539dbdd92fb1ad61db9f7 100644 (file)
@@ -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);
index 45f27a228cc8af97fddd4c08ca07042982f78416..12120b3bc285c8740a1b7780df5c22e7a8e3723d 100644 (file)
@@ -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);
     }
 
index baeda99bfd7ab1dc73f9685ab5595e2360911556..006a3008ab2694a7d142f51b6684aac6edee8344 100644 (file)
@@ -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'],