update the membership dates as per contribution receive_date
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 8 Apr 2015 13:01:06 +0000 (18:31 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 8 Apr 2015 13:01:06 +0000 (18:31 +0530)
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/Contribution.php

index 7e1568ebfb371a43ffb697b05cf1b3464b9d04a7..de3c95d50293be0ffb37331b03fb44c9edc23ad5 100644 (file)
@@ -1632,7 +1632,9 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
             }
 
             // CRM-15735-to update the membership status as per the contribution receive date
+            $joinDate = NULL;
             if (!empty($params['receive_date'])) {
+              $joinDate = $params['receive_date'];
               $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($membership->start_date,
                 $membership->end_date,
                 $membership->join_date,
@@ -1651,7 +1653,7 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
               $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
             }
             else {
-              $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $numterms);
+              $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, $joinDate, NULL, NULL, $numterms);
             }
 
             //get the status for membership.
index 50a5ed5db3c2e0adc84adca64d99d2ade7bbc3f8..8364c3c2653ee032ef1c0d45b6f020a9b5d58200 100644 (file)
@@ -282,7 +282,7 @@ WHERE  contribution_id = {$id}
    *
    * @return null|string
    */
-  protected function updateRelatedComponent($contributionId, $statusId, $previousStatusId = NULL) {
+  protected function updateRelatedComponent($contributionId, $statusId, $previousStatusId = NULL, $receiveDate = NULL) {
     $statusMsg = NULL;
     if (!$contributionId || !$statusId) {
       return $statusMsg;
@@ -292,6 +292,7 @@ WHERE  contribution_id = {$id}
       'contribution_id' => $contributionId,
       'contribution_status_id' => $statusId,
       'previous_contribution_status_id' => $previousStatusId,
+      'receive_date' => $receiveDate,
     );
 
     $updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params);
index d49cb03b49742535ce41ff248c992080b41f6c2f..77e5c21ae3b1a37be0555cf6bc018069ea61c0c8 100644 (file)
@@ -1303,7 +1303,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
           $contribution->contribution_status_id,
           CRM_Utils_Array::value('contribution_status_id',
             $this->_values
-          )
+          ),
+          $contribution->receive_date
         );
       }