Add field to track when current subscription type started
This commit is contained in:
@@ -161,6 +161,7 @@ async function prepareSubscriptionValues (data) {
|
||||
plan.dateTerminated = moment().add({ months }).toDate();
|
||||
plan.dateCreated = today;
|
||||
}
|
||||
plan.dateCurrentTypeCreated = today;
|
||||
}
|
||||
|
||||
if (!plan.customerId) {
|
||||
@@ -177,6 +178,7 @@ async function prepareSubscriptionValues (data) {
|
||||
planId: block.key,
|
||||
customerId: data.customerId,
|
||||
dateUpdated: today,
|
||||
dateCurrentTypeCreated: today,
|
||||
paymentMethod: data.paymentMethod,
|
||||
extraMonths: Number(plan.extraMonths) + _dateDiff(today, plan.dateTerminated),
|
||||
dateTerminated: null,
|
||||
|
||||
@@ -13,6 +13,7 @@ export const schema = new mongoose.Schema({
|
||||
dateCreated: Date,
|
||||
dateTerminated: Date,
|
||||
dateUpdated: Date,
|
||||
dateCurrentTypeCreated: Date,
|
||||
extraMonths: { $type: Number, default: 0 },
|
||||
gemsBought: { $type: Number, default: 0 },
|
||||
mysteryItems: { $type: Array, default: () => [] },
|
||||
|
||||
Reference in New Issue
Block a user