feat(billing): start demos on the core plan and apply tariff levels

New signups get the core module set with the 7-day demo. Superadmin can apply core, team, organization, or dedicated and the owner's environments take that level's access.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-10 14:08:14 +03:30
co-authored by Cursor
parent 5b26b9156d
commit 932dc3f1c1
8 changed files with 212 additions and 5 deletions
+84
View File
@@ -354,6 +354,90 @@ export interface SetStorageQuotaRequest {
/** سقف‌های آمادهٔ تعداد کاربر. بالاتر از ۲۰ توافقی و با عدد جدا ذخیره می‌شود. */
export const BILLING_USER_CAPS = [3, 10, 20] as const;
/** سطح امکانات اشتراک. دمو ۷ روزه از هسته شروع می‌شود. */
export type ProductPlanCode = "core" | "team" | "organization" | "dedicated";
export const PRODUCT_PLAN_CODES: ProductPlanCode[] = [
"core",
"team",
"organization",
"dedicated",
];
export const PRODUCT_PLAN_LABELS: Record<ProductPlanCode, string> = {
core: "هسته",
team: "تیم",
organization: "سازمان",
dedicated: "اختصاصی",
};
/** null یعنی سقف را عوض نکن؛ اختصاصی توافقی است. */
export const PRODUCT_PLAN_LIMITS: Record<
ProductPlanCode,
{ maxUsers: number | null; maxOrganizations: number | null }
> = {
core: { maxUsers: 3, maxOrganizations: 1 },
team: { maxUsers: 10, maxOrganizations: 3 },
organization: { maxUsers: 20, maxOrganizations: 5 },
dedicated: { maxUsers: null, maxOrganizations: null },
};
const PRODUCT_PLAN_CORE: OrgModuleKey[] = [
"customers",
"attachments",
"activities",
"notes",
"products",
"invoices",
"quotes",
"lead_forms",
"team_settings",
];
const PRODUCT_PLAN_TEAM: OrgModuleKey[] = [
"routines",
"conversations",
"pipeline",
"saved_views",
"leads",
"commissions",
"sales_forecast",
"reports",
"project_boards",
"sms_campaigns",
"message_automations",
"tickets",
"faq",
"cheques",
"treasury",
"workflow_automations",
"teams",
"gamification",
"custom_fields",
];
const PRODUCT_PLAN_ORGANIZATION: OrgModuleKey[] = [
"inventory",
"currencies",
"tahesab",
"workflow_automations_advanced",
"audit_logs",
"prior_data_archive",
"public_api",
"woocommerce",
"montify",
"voip",
"reservations",
"loyalty",
"behavior",
];
export function modulesForProductPlan(code: ProductPlanCode): OrgModuleKey[] {
if (code === "core") return [...PRODUCT_PLAN_CORE];
if (code === "team") return [...PRODUCT_PLAN_CORE, ...PRODUCT_PLAN_TEAM];
return [...PRODUCT_PLAN_CORE, ...PRODUCT_PLAN_TEAM, ...PRODUCT_PLAN_ORGANIZATION];
}
export interface OwnerSeatUsageDto {
usedUsers: number;
maxUsers: number | null;