The instalment dates listed on the new membership screen can sometimes not match the contribution instalment dates after creation, this difference is noticeable when using a day above 28. In this PR we use the same logic used in calculating contribution dates to calculate the instalment dates for the new membership screen.
Before
The instalment dates on the new membership screen.
The new membership screen uses the inbuilt PHP DateTime function to add months to date, and this function behaves in some certain way as we've seen in the screen above, 2022-01-29 + 1month = 2022-03-01 and subsequent months use the day from the previous calculation.
Overview
The instalment dates listed on the new membership screen can sometimes not match the contribution instalment dates after creation, this difference is noticeable when using a day above 28. In this PR we use the same logic used in calculating contribution dates to calculate the instalment dates for the new membership screen.
Before
The instalment dates on the new membership screen.
The new membership screen uses the inbuilt PHP DateTime function to add months to date, and this function behaves in some certain way as we've seen in the screen above,
2022-01-29 + 1month = 2022-03-01
and subsequent months use the day from the previous calculation.The actual instalment dates after creation.
Whereas when creating the contributions, the instalment dates are calculated using the custom function
getSameDayNextMonth
https://github.com/compucorp/uk.co.compucorp.membershipextras/blob/326e69ed0468cb4f2b40ad6adc0b6630257e84d3/CRM/MembershipExtras/Service/InstalmentReceiveDateCalculator.php#L102 to add months to date, this function helps handle the scenario mentioned above such that2022-01-29 + 1month = 2022-02-28
and subsequent dates makes use of the day from the first calculation.After
New membership screen using the function
getSameDayNextMonth
to calculate instalment dates