From: Eileen McNaughton Date: Thu, 8 Jan 2015 12:01:36 +0000 (+1300) Subject: CRM-15798 adjust membership date calculation for multiyear membership X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6f1c82f549fb1f7a8907aaec4b3898e2de259177;p=civicrm-core.git CRM-15798 adjust membership date calculation for multiyear membership After refactoring the code to understand it & adding a test this is the upshot... we are dealing with annual memberships (even if they are in 5 year blocks rollover is still about month & day) so if the definition of whether they are in the rollover period is actually the same in multi-year as for a single year - if they are between the rollover & the cut off they get an extra part-year. Hence, when determining whether to give an extra part year we don't need to compare the rollover to the final end date (5 years on) but to the next year's end date - just like for an annual Note that one could argue, but I don't think anyone has, that if the 5 year period has started then the get the remainder of this 5 years + the next 5 years - which is what the existing code seems to be almost trying to do --- diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 06b2ff425e..e26b370969 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -464,7 +464,7 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { $endDateOfFirstYearMembershipPeriod = date('Y-m-d', mktime(0, 0, 0, $dateParts[1], $dateParts[2] - 1, - $dateParts[0] + ($numRenewTerms * $membershipTypeDetails['duration_interval']) + $dateParts[0] + 1 )); //we know the month and day of the rollover date but not the year (we're just