From fdabdc54a329d2d9fe05f96d4757563709bd2434 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Mon, 2 Nov 2026 19:55:51 +0330 Subject: [PATCH] feat(billing): default the 7-day demo to 3 users Applying or creating a trial plan sets the owner seat cap to 3, and existing demos without a cap get the same default. Co-authored-by: Cursor --- .../20261102200000_trial_default_max_users/migration.sql | 4 ++++ apps/api/src/billing/billing.service.ts | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 apps/api/prisma/migrations/20261102200000_trial_default_max_users/migration.sql diff --git a/apps/api/prisma/migrations/20261102200000_trial_default_max_users/migration.sql b/apps/api/prisma/migrations/20261102200000_trial_default_max_users/migration.sql new file mode 100644 index 0000000..8b86d9c --- /dev/null +++ b/apps/api/prisma/migrations/20261102200000_trial_default_max_users/migration.sql @@ -0,0 +1,4 @@ +-- دموی ۷ روزه که هنوز سقف کاربر ندارد، پیش‌فرض ۳ کاربر می‌گیرد +UPDATE "BillingAccount" +SET "maxUsers" = 3 +WHERE "planCode" = 'trial' AND "maxUsers" IS NULL; diff --git a/apps/api/src/billing/billing.service.ts b/apps/api/src/billing/billing.service.ts index 762cb69..8402d20 100644 --- a/apps/api/src/billing/billing.service.ts +++ b/apps/api/src/billing/billing.service.ts @@ -159,6 +159,7 @@ export class BillingService { startsAt: now, expiresAt, maxOrganizations: Math.max(1, opts?.maxOrganizations ?? 1), + maxUsers: 3, }, }); } @@ -301,6 +302,7 @@ export class BillingService { expiresAt, maxOrganizations, expiryNotifiedAt, + ...(planCode === 'trial' ? { maxUsers: 3 } : {}), ...(dto.notes !== undefined ? { notes: dto.notes } : {}), }, }) @@ -314,6 +316,7 @@ export class BillingService { maxOrganizations, notes: dto.notes ?? null, expiryNotifiedAt, + ...(planCode === 'trial' ? { maxUsers: 3 } : {}), }, }); if (status === 'expired' && !expiryNotifiedAt) {