CRM-17092 fix for recurring contribution id not set on membership
authoreileenmcnaugton <eileen@fuzion.co.nz>
Wed, 26 Aug 2015 23:53:41 +0000 (11:53 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Wed, 26 Aug 2015 23:53:41 +0000 (11:53 +1200)
CRM/Member/BAO/Membership.php
CRM/Member/Form.php
CRM/Member/Form/MembershipRenewal.php

index c6f8545be549dcf0dd0a69cab7a759be4bdc4c66..8fd061802b9e759677aa0660edb72eb807629e3c 100644 (file)
@@ -1853,7 +1853,7 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
         }
         CRM_Member_BAO_MembershipLog::add($logParams);
 
-        if (!empty($contributionRecurID)) {
+        if ($contributionRecurID) {
           CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $membership->id,
             'contribution_recur_id', $contributionRecurID
           );
@@ -1983,12 +1983,14 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
       if (!empty($membershipSource)) {
         $memParams['source'] = $membershipSource;
       }
-      $memParams['contribution_recur_id'] = $contributionRecurID;
-
       $memParams['is_test'] = $is_test;
       $memParams['is_pay_later'] = $isPayLater;
     }
-
+    // Putting this in an IF is precautionary as it seems likely that it would be ignored if empty, but
+    // perhaps shouldn't be?
+    if ($contributionRecurID) {
+      $memParams['contribution_recur_id'] = $contributionRecurID;
+    }
     //CRM-4555
     //if we decided status here and want to skip status
     //calculation in create( ); then need to pass 'skipStatusCal'.
index 8d7a2e1f33d5278ae90f1215399dcb9bf7e69be4..ca06acb5c566bc2d9bf5e191e56a872e83635f94 100644 (file)
@@ -348,15 +348,14 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
       'return' => $mapping,
     ));
 
+    $returnParams = array('is_recur' => TRUE);
     foreach ($mapping as $recurringFieldName => $membershipTypeFieldName) {
       $contributionRecurParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName];
+      $returnParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName];
     }
 
     $contributionRecur = civicrm_api3('ContributionRecur', 'create', $contributionRecurParams);
-    $returnParams = array(
-      'contributionRecurID' => $contributionRecur['id'],
-      'is_recur' => TRUE,
-    );
+    $returnParams['contributionRecurID'] = $contributionRecur['id'];
     return $returnParams;
   }
 
index e7a0f00af212a49df2ff1e619dfc695fd3141902..b9020c78c20daa53f6ef30a48c3dcf95f2a1eef6 100644 (file)
@@ -506,7 +506,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     if (empty($this->_params['financial_type_id'])) {
       $this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
     }
-
+    $contributionRecurID = NULL;
     $this->assign('membershipID', $this->_id);
     $this->assign('contactID', $this->_contactID);
     $this->assign('module', 'Membership');
@@ -543,6 +543,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
       if (!empty($this->_params['auto_renew'])) {
         $contributionRecurParams = $this->processRecurringContribution($paymentParams);
+        $contributionRecurID = $contributionRecurParams['contributionRecurID'];
         $paymentParams = array_merge($paymentParams, $contributionRecurParams);
       }