Files
CRM_Montzar/docs/superpowers/plans/2026-09-20-billing-account-modules.md
T

1.7 KiB

BillingAccount + Modules Implementation Plan

For agentic workers: Execute task-by-task. Checkboxes track progress.

Goal: Owner-level BillingAccount (plans/expiry/max orgs), per-org enabledModules, CRM enforcement + remaining-days UI, /adm controls and polish.

Architecture: Shared module catalog; Prisma BillingAccount + Organization.enabledModules; billing checks on login/org-create; module guards on API + filtered nav; platform admin APIs/UI for plans and modules.

Tech Stack: NestJS, Prisma, Vue 3, @mento/shared, existing CRM CSS tokens.

Global Constraints

  • Manual activation only (no payment gateway).
  • Existing owners: trial 15 days; maxOrganizations >= current owned org count.
  • Expiry: block CRM login; header days remaining; warn ≤3 days.
  • Vue + CRM CSS only for /adm.

Task 1: Shared catalog + DTOs

  • Add ORG_MODULE_KEYS, labels, plan presets, billing DTOs to packages/shared/src/index.ts
  • Extend org/login DTOs with enabledModules + subscription summary

Task 2: Prisma

  • BillingAccount model; Organization.enabledModules String[]
  • Migration SQL + data backfill (trial 15d, full modules)

Task 3: Billing service + auth/org enforcement

  • BillingService resolve/require active for org; apply plan; ensure account
  • Hook login / switch org / create org
  • Module require helper for key controllers (or lightweight guard)

Task 4: Platform API + /adm UI

  • Endpoints: get/apply billing, patch org modules
  • Adm users: billing card; adm orgs: module checklist; light shell polish

Task 5: Web CRM

  • Filter nav hubs by modules
  • Header subscription chip + warn
  • Router guard for disabled modules