feat: Cover active but cancelled subscriptions
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import Base from './base';
|
import Base from './base';
|
||||||
import User from './user';
|
import User from './user';
|
||||||
import UsageData from './usage-data.ee';
|
import UsageData from './usage-data.ee';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
import { getPlanById } from '../helpers/billing/plans.ee';
|
import { getPlanById } from '../helpers/billing/plans.ee';
|
||||||
|
|
||||||
class Subscription extends Base {
|
class Subscription extends Base {
|
||||||
@@ -79,8 +80,20 @@ class Subscription extends Base {
|
|||||||
return getPlanById(this.paddlePlanId);
|
return getPlanById(this.paddlePlanId);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isActive() {
|
get isCancelledAndValid() {
|
||||||
return this.status === 'active' || this.status === 'past_due';
|
return (
|
||||||
|
this.status === 'deleted' &&
|
||||||
|
Number(this.cancellationEffectiveDate) >
|
||||||
|
DateTime.now().startOf('day').toMillis()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get isValid() {
|
||||||
|
if (this.status === 'active') return true;
|
||||||
|
if (this.status === 'past_due') return true;
|
||||||
|
if (this.isCancelledAndValid) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ class User extends Base {
|
|||||||
|
|
||||||
const subscription = await this.$relatedQuery('currentSubscription');
|
const subscription = await this.$relatedQuery('currentSubscription');
|
||||||
|
|
||||||
return subscription?.isActive;
|
return subscription?.isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
async withinLimits() {
|
async withinLimits() {
|
||||||
|
Reference in New Issue
Block a user