$date = $membershipDetails->end_date;
}
$date = explode('-', $date);
- // We have to add 1 day first in case it's the end of the month, then subtract afterwards
+ $year = $date[0];
+ $month = $date[1];
+ $day = $date[2];
+
+ // $logStartDate is used for the membership log only, except if the membership is monthly
+ // then we add 1 day first in case it's the end of the month, then subtract afterwards
// eg. 2018-02-28 should renew to 2018-03-31, if we just added 1 month we'd get 2018-03-28
$logStartDate = date('Y-m-d', mktime(0, 0, 0,
(double) $date[1],
(double) $date[0]
));
- $date = explode('-', $logStartDate);
- $year = $date[0];
- $month = $date[1];
- $day = $date[2];
-
switch ($membershipTypeDetails['duration_unit']) {
case 'year':
//need to check if the upsell is from rolling to fixed and adjust accordingly
break;
case 'month':
+ $date = explode('-', $logStartDate);
+ $year = $date[0];
+ $month = $date[1];
+ $day = $date[2] - 1;
$month = $month + ($numRenewTerms * $membershipTypeDetails['duration_interval']);
break;
else {
$endDate = date('Y-m-d', mktime(0, 0, 0,
$month,
- $day - 1,
+ $day,
$year
));
}
/**
* Renew membership with change in membership type.
*
- * @fixme Note that this test fails when today is August 29 2019 (and maybe
- * other years?): Verify correct end date is calculated after membership
- * renewal Failed asserting that two strings are equal.
- * Expected-'2021-03-01' Actual+'2021-02-28'
* @throws \CRM_Core_Exception
*/
public function testRenewMembership(): void {