From 35874a670fb05d5d7716c694f41d3831d7aa91b3 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 8 Apr 2015 18:31:06 +0530 Subject: [PATCH] update the membership dates as per contribution receive_date --- CRM/Contribute/BAO/Contribution.php | 4 +++- CRM/Contribute/Form/AbstractEditPayment.php | 3 ++- CRM/Contribute/Form/Contribution.php | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 7e1568ebfb..de3c95d502 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -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. diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 50a5ed5db3..8364c3c265 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -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); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index d49cb03b49..77e5c21ae3 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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 ); } -- 2.25.1