Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Only enforce min seats for orgs (#10572)

Joe Au-Yeungc7d8d435f16b
diff --git a/packages/features/ee/teams/lib/payments.ts b/packages/features/ee/teams/lib/payments.ts
index 048964b9ff3..6171f159ae3 100644
--- a/packages/features/ee/teams/lib/payments.ts
+++ b/packages/features/ee/teams/lib/payments.ts
@@ -3,6 +3,7 @@ import { z } from "zod";
import { getStripeCustomerIdFromUserId } from "@calcom/app-store/stripepayment/lib/customer";
import stripe from "@calcom/app-store/stripepayment/lib/server";
import { WEBAPP_URL } from "@calcom/lib/constants";
+import { ORGANIZATION_MIN_SEATS } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
@@ -74,7 +75,7 @@ export const purchaseTeamSubscription = async (input: {
const getTeamWithPaymentMetadata = async (teamId: number) => {
const team = await prisma.team.findUniqueOrThrow({
where: { id: teamId },
- select: { metadata: true, members: true },
+ select: { metadata: true, members: true, _count: { select: { orgUsers: true } } },
});
const metadata = teamPaymentMetadataSchema.parse(team.metadata);
return { ...team, metadata };
@@ -109,8 +110,10 @@ export const updateQuantitySubscriptionFromStripe = async (teamId: number) => {
)?.quantity;
if (!subscriptionQuantity) throw new Error("Subscription not found");
- if (membershipCount < subscriptionQuantity) {
- console.info(`Team ${teamId} has less members than seats, skipping updating subscription.`);
+ if (!!team._count.orgUsers && membershipCount < ORGANIZATION_MIN_SEATS) {
+ console.info(
+ `Org ${teamId} has less members than the min ${ORGANIZATION_MIN_SEATS}, skipping updating subscription.`
+ );
return;
}
diff --git a/packages/lib/constants.ts b/packages/lib/constants.ts
index d7f436b276e..336b6d9761a 100644
--- a/packages/lib/constants.ts
+++ b/packages/lib/constants.ts
@@ -90,3 +90,5 @@ export const MINUTES_TO_BOOK = process.env.NEXT_PUBLIC_MINUTES_TO_BOOK || "5";
// Needed for orgs
export const ALLOWED_HOSTNAMES = JSON.parse(`[${process.env.ALLOWED_HOSTNAMES || ""}]`) as string[];
export const RESERVED_SUBDOMAINS = JSON.parse(`[${process.env.RESERVED_SUBDOMAINS || ""}]`) as string[];
+
+export const ORGANIZATION_MIN_SEATS = 30;