Browse Source

Adds cancelled flag to subscriptions

main
Eric Amodio 2 years ago
parent
commit
ff34ce8ff6
2 changed files with 6 additions and 1 deletions
  1. +2
    -0
      src/plus/subscription/subscriptionService.ts
  2. +4
    -1
      src/subscription.ts

+ 2
- 0
src/plus/subscription/subscriptionService.ts View File

@ -645,6 +645,7 @@ export class SubscriptionService implements Disposable {
license.organizationId,
new Date(license.latestStartDate),
new Date(license.latestEndDate),
license.latestStatus === 'cancelled',
);
}
@ -676,6 +677,7 @@ export class SubscriptionService implements Disposable {
license.organizationId,
new Date(license.latestStartDate),
new Date(license.latestEndDate),
license.latestStatus === 'cancelled',
);
}

+ 4
- 1
src/subscription.ts View File

@ -28,6 +28,7 @@ export interface SubscriptionPlan {
readonly id: SubscriptionPlanId;
readonly name: string;
readonly bundle: boolean;
readonly cancelled: boolean;
readonly startedOn: string;
readonly expiresOn?: string | undefined;
readonly organizationId: string | undefined;
@ -112,11 +113,13 @@ export function getSubscriptionPlan(
organizationId: string | undefined,
startedOn?: Date,
expiresOn?: Date,
cancelled: boolean = false,
): SubscriptionPlan {
return {
id: id,
name: getSubscriptionPlanName(id),
bundle: bundle,
cancelled: cancelled,
organizationId: organizationId,
startedOn: (startedOn ?? new Date()).toISOString(),
expiresOn: expiresOn != null ? expiresOn.toISOString() : undefined,
@ -149,7 +152,7 @@ const plansPriority = new Map([
]);
export function getSubscriptionPlanPriority(id: SubscriptionPlanId | undefined): number {
return plansPriority.get(id)!;
return plansPriority.get(id) ?? -1;
}
export function getSubscriptionTimeRemaining(

Loading…
Cancel
Save