Skip to content

Commit f4258ac

Browse files
committed
remove expired licenses filter & check actual license expiration
1 parent 0242ce0 commit f4258ac

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/plus/gk/checkin.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { SubscriptionPlanId } from '../../constants.subscription';
22
import type { Organization } from './account/organization';
33
import type { Subscription } from './account/subscription';
44
import {
5-
computeSubscriptionState,
65
getSubscriptionPlan,
76
getSubscriptionPlanPriority,
7+
isSubscriptionExpired,
88
SubscriptionPlanId,
9-
SubscriptionState,
109
} from './account/subscription';
1110

1211
export type GKLicenses = Partial<Record<GKLicenseType, GKLicense>>;
@@ -75,7 +74,6 @@ export function getSubscriptionFromCheckIn(
7574

7675
let effectiveLicenses = Object.entries(data.licenses.effectiveLicenses) as [GKLicenseType, GKLicense][];
7776
let paidLicenses = Object.entries(data.licenses.paidLicenses) as [GKLicenseType, GKLicense][];
78-
paidLicenses = paidLicenses.filter(license => license[1].latestStatus !== 'cancelled');
7977
if (paidLicenses.length > 1) {
8078
paidLicenses.sort(
8179
(a, b) =>
@@ -85,6 +83,7 @@ export function getSubscriptionFromCheckIn(
8583
licenseStatusPriority(a[1].latestStatus)),
8684
);
8785
}
86+
8887
if (effectiveLicenses.length > 1) {
8988
effectiveLicenses.sort(
9089
(a, b) =>
@@ -183,17 +182,10 @@ export function getSubscriptionFromCheckIn(
183182
);
184183
}
185184

186-
const isActualLicenseExpired =
187-
computeSubscriptionState({
188-
plan: {
189-
actual: actual,
190-
effective: actual,
191-
},
192-
account: account,
193-
}) === SubscriptionState.PaidExpired;
194185
if (
195186
effective == null ||
196-
(getSubscriptionPlanPriority(actual.id) >= getSubscriptionPlanPriority(effective.id) && !isActualLicenseExpired)
187+
(getSubscriptionPlanPriority(actual.id) >= getSubscriptionPlanPriority(effective.id) &&
188+
!isSubscriptionExpired(actual))
197189
) {
198190
effective = { ...actual };
199191
}

0 commit comments

Comments
 (0)