fix(subscriptions): gift termination date (#7948)

This commit is contained in:
Sabe Jones
2016-08-31 17:16:40 -05:00
committed by GitHub
parent cb1417ea58
commit e65f27fb69
2 changed files with 16 additions and 3 deletions
+5 -1
View File
@@ -34,8 +34,12 @@ api.createSubscription = async function createSubscription (data) {
if (plan.customerId && !plan.dateTerminated) { // User has active plan
plan.extraMonths += months;
} else {
plan.dateTerminated = moment(plan.dateTerminated).add({months}).toDate();
if (!plan.dateUpdated) plan.dateUpdated = new Date();
if (moment(plan.dateTerminated).isAfter()) {
plan.dateTerminated = moment(plan.dateTerminated).add({months}).toDate();
} else {
plan.dateTerminated = moment().add({months}).toDate();
}
}
if (!plan.customerId) plan.customerId = 'Gift'; // don't override existing customer, but all sub need a customerId