mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
fix(plans): when gifting subscription, set plan.dateUpdated so it can
roll gemCapExtra next month. Fixes #4480
This commit is contained in:
5
migrations/20150107_plan_dateUpdated_null.js
Normal file
5
migrations/20150107_plan_dateUpdated_null.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
db.users.update(
|
||||||
|
{'purchased.plan.customerId':{$ne:null}, 'purchased.plan.dateUpdated':null},
|
||||||
|
{$set: {'purchased.plan.datedUpdated': new Date('12/01/2014')}},
|
||||||
|
{multi:true}
|
||||||
|
);
|
||||||
@@ -39,6 +39,7 @@ exports.createSubscription = function(data, cb) {
|
|||||||
p.extraMonths += months;
|
p.extraMonths += months;
|
||||||
} else {
|
} else {
|
||||||
p.dateTerminated = moment(p.dateTerminated).add({months: months}).toDate();
|
p.dateTerminated = moment(p.dateTerminated).add({months: months}).toDate();
|
||||||
|
if (!p.dateUpdated) p.dateUpdated = new Date();
|
||||||
}
|
}
|
||||||
if (!p.customerId) p.customerId = 'Gift'; // don't override existing customer, but all sub need a customerId
|
if (!p.customerId) p.customerId = 'Gift'; // don't override existing customer, but all sub need a customerId
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user