fix conflict between cancelled vs. next_payment dates for pending-cancel #283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#278 introduced
cancelled_date
as an importable column, and also fixed some behavior which was preventingend_date
from being properly applied to imported subscriptions. However, it also introduced a potential conflict betweencancelled_date
andnext_payment
dates for imported subscriptions with apending-cancel
status.Some preexisting logic in
master
forces anext_payment
date forpending-cancel
subscriptions, which becomes the end date for those subscriptions after being imported. However, if acancelled_date
is also set for these subscriptions, importing will fail with an error aspending-cancel
subscriptions can't have acancelled_date
that occurs beforenext_payment
.This PR proposes a fix to not force
next_payment
for these subscriptions. However,pending-cancel
subscriptions do need to ultimately have anend_date
, otherwise they'll essentially continue to be active indefinitely. So the proposed change checkspending-cancel
subs for a futurenext_payment
date, and if it exists, moves it to theend_date
instead and clearsnext_payment
to avoid the import error. In local testing this resulted in importedpending-cancel
subscriptions with the same date behavior/data schema as subscriptions that were manually moved topending-cancel
status via admin or subscriber action.If the subscription to be imported lacks both an
end_date
and anext_payment
date, or both are in the past, the importer will continue to throw an error as it did before in this scenario.To test:
master
, import a subscription that has both acancelled_date
and anend_date
. Here's some sample data you could use to import (replace<product ID>
with a valid product ID on your test site):end_date
value to thenext_payment_date
column instead. Import and confirm that it successfully imports with the same results as in step 4.end_date
and a differentnext_payment_date
value. Import and confirm that it successfully imports with the end date intact, but discards the next payment date.