Updated plan updated date if user has cancelled (#9773)

* Updated plan updated date if user has cancelled

* Added test for plan with only date updated
This commit is contained in:
Keith Holliday
2018-01-08 12:50:15 -06:00
committed by GitHub
parent 587847f5e9
commit d3ee3ca53d
3 changed files with 21 additions and 4 deletions

View File

@@ -307,7 +307,7 @@ api.createSubscription = async function createSubscription (data) {
if (plan.customerId && !plan.dateTerminated) { // User has active plan
plan.extraMonths += months;
} else {
if (!plan.dateUpdated) plan.dateUpdated = today;
if (!recipient.isSubscribed() || !plan.dateUpdated) plan.dateUpdated = today;
if (moment(plan.dateTerminated).isAfter()) {
plan.dateTerminated = moment(plan.dateTerminated).add({months}).toDate();
} else {