From 0b28f6df55f43792b8e4234f56473c86a921259d Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 7 Jan 2015 14:58:58 -0700 Subject: [PATCH] fix(plans): when gifting subscription, set plan.dateUpdated so it can roll gemCapExtra next month. Fixes #4480 --- migrations/20150107_plan_dateUpdated_null.js | 5 +++++ src/controllers/payments/index.js | 1 + 2 files changed, 6 insertions(+) create mode 100644 migrations/20150107_plan_dateUpdated_null.js diff --git a/migrations/20150107_plan_dateUpdated_null.js b/migrations/20150107_plan_dateUpdated_null.js new file mode 100644 index 0000000000..ae231a0414 --- /dev/null +++ b/migrations/20150107_plan_dateUpdated_null.js @@ -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} +); \ No newline at end of file diff --git a/src/controllers/payments/index.js b/src/controllers/payments/index.js index fea3c73025..c2f83959de 100644 --- a/src/controllers/payments/index.js +++ b/src/controllers/payments/index.js @@ -39,6 +39,7 @@ exports.createSubscription = function(data, cb) { p.extraMonths += months; } else { 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 } else {