There was a misunderstanding that the trigger for autorenewal should be the next scheduled contribution date. There is a risk that this date may be before or after the end date of the membership (specially in Direct debit payment plans).
As such we changed the "trigger" for the autorenwal job to be the end date of the membership (taking into account the payment plan setting Days to renew in advance), or the minimum membership end date if there are more than one membership in the payment plan with different end dates as it used to be the case before.
The installments receive dates is still being calculated based on the next scheduled contribution date,
Before
The next scheduled contribution date is what we use to trigger the autorenewal.
I also updated the migrating upgrader that updates the next scheduled contribution date for all payment plans, so it now uses the max contribution receive date plus:
+1 year for annual payment plans
+1 month for monthly payment plans
+3 months for quarterly payment plans
minimum membership end date + 1 day for other manual payment plans. (I do that because having non annual, monthly or quarterly payment plans is no longer supported in v5, and it is hard to know what the next contribution date should be for these non standard payment plans, so the safest option I found is just to set it to the minimum membership end date among all the memberships attached to it, plus 1 day so equals the new membership start date if it get renewed).
Overview
There was a misunderstanding that the trigger for autorenewal should be the next scheduled contribution date. There is a risk that this date may be before or after the end date of the membership (specially in Direct debit payment plans).
As such we changed the "trigger" for the autorenwal job to be the end date of the membership (taking into account the payment plan setting Days to renew in advance), or the minimum membership end date if there are more than one membership in the payment plan with different end dates as it used to be the case before.
The installments receive dates is still being calculated based on the next scheduled contribution date,
Before
The next scheduled contribution date is what we use to trigger the autorenewal.
After
The membership end date (or the minimum membership end date if there are more that one) is what triggers that autorenewal. Which meant reverting most of the work I did here: https://github.com/compucorp/uk.co.compucorp.membershipextras/pull/393.
Other notes
I also updated the migrating upgrader that updates the next scheduled contribution date for all payment plans, so it now uses the max contribution receive date plus: