Fix subcriptions remaining time disappearing after cancelling (#10761)

* add hasCancelled method for group/user, prevent cancelling a subscription twice

* wip

* paypal: do not cancel a subscription twice

* make sure hasCancelled and hasNotCancelled return a boolean result
This commit is contained in:
Matteo Pagliazzi
2018-10-18 12:14:07 +02:00
committed by GitHub
parent 061d990e39
commit 1f44444a50
5 changed files with 86 additions and 9 deletions

View File

@@ -31,7 +31,12 @@ schema.methods.isSubscribed = function isSubscribed () {
schema.methods.hasNotCancelled = function hasNotCancelled () {
let plan = this.purchased.plan;
return this.isSubscribed() && !plan.dateTerminated;
return Boolean(this.isSubscribed() && !plan.dateTerminated);
};
schema.methods.hasCancelled = function hasCancelled () {
let plan = this.purchased.plan;
return Boolean(this.isSubscribed() && plan.dateTerminated);
};
// Get an array of groups ids the user is member of