Skip to content

Commit

Permalink
[server] Ignore old FREE/FREE_50 when evaluating BillingMode
Browse files Browse the repository at this point in the history
  • Loading branch information
geropl authored and roboquat committed Feb 8, 2023
1 parent d2fa18a commit 23ee852
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions components/server/ee/src/billing/billing-mode.spec.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,18 @@ class BillingModeSpec {
},
},
// user: usage-based
{
name: "user: stripe free, chargebee FREE (old)",
subject: user(),
config: {
enablePayment: true,
usageBasedPricingEnabled: true,
subscriptions: [subscription(Plans.FREE)],
},
expectation: {
mode: "usage-based",
},
},
{
name: "user: stripe free, chargebee paid personal (inactive) + team seat (inactive)",
subject: user(),
Expand Down
6 changes: 5 additions & 1 deletion components/server/ee/src/billing/billing-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ export class BillingModesImpl implements BillingModes {
const cbSubscriptions = await this.subscriptionSvc.getActivePaidSubscription(user.id, now);
const cbTeamSubscriptions = cbSubscriptions.filter((s) => isOldTeamSubscription(s));
const cbPersonalSubscriptions = cbSubscriptions.filter(
(s) => isPersonalSubscription(s) && s.planId !== Plans.FREE_OPEN_SOURCE.chargebeeId,
(s) =>
isPersonalSubscription(s) &&
![Plans.FREE_OPEN_SOURCE.chargebeeId, Plans.FREE.chargebeeId, Plans.FREE_50.chargebeeId].includes(
s.planId!,
),
);
const cbOwnedTeamSubscriptions = (
await this.teamSubscriptionDb.findTeamSubscriptions({ userId: user.id })
Expand Down

0 comments on commit 23ee852

Please sign in to comment.