# מסלול החשבון ומכסות

> תיעוד מקור. מקור: docs/account-plans.md · 6a466bf.
> בגרסה הציבורית הושמטו מזהים תפעוליים ופרטי חשבון אישיים. קובץ המקור נשמר במאגר.

The canonical catalog is `lib/commercial-system/plans.json`. Account identity is stored in `ev1_tenants.plan_code`; the legacy `kind` remains compatible with profile and RLS policies.

| Account    | Vehicle capacity | Ownership                   | Interface                                           |
| ---------- | ---------------- | --------------------------- | --------------------------------------------------- |
| Personal   | 1                | One owner login             | Personal vehicle and charging history               |
| Family     | 3                | One owner login             | Family garage and combined expenses                 |
| Business   | 10               | Existing organization roles | Fleet, drivers, cost centers, policy and analytics  |
| Enterprise | No vehicle cap   | Existing organization roles | Organization overview and full fleet administration |

Active and suspended vehicles occupy capacity. Retired vehicles remain in history and do not occupy capacity. There is no extra family member login or password-sharing requirement. Family is one owner's account with three vehicles.

The company website links to `https://product.linknodesenergy.com/platform?plan=<code>`. The selected plan survives Clerk sign-in/sign-up redirects. Existing accounts retain their stored plan. Their owner can change it in Settings; another account cannot be used to alter the first account's selection. The map is shared across plans and carries the selected workspace through driver navigation.

## Enforcement

Migration `20261108194554_account_plans_and_vehicle_limits.sql` adds the account discriminator, kind consistency constraint, owner-only provisioning/plan RPCs and capacity triggers. Every vehicle insert or update and membership/invitation mutation locks its tenant row; plan changes lock that same row. Counts run outside row-level filtering, with ordinary RLS still enforcing write authorization. A simultaneous second insertion cannot overrun the limit. Direct authenticated UPDATE of plan_code and anonymous RPC access are denied.

Downgrades are rejected while excess non-retired vehicles, additional active members or live invitations remain. No records or history are deleted by changing a plan. Optimistic expected_plan checking prevents a stale settings page from overwriting another plan change. Provision retries return the original same-plan account; conflicting plan selections require an explicit owner change.

These account experiences are independent of paid subscription entitlement. Prices, commission rates and payment providers are unconfigured; changing the account plan neither activates a paid subscription nor authorizes charging. Future commercial activation must derive eligibility from approved agreements and payment state. Enterprise's lack of a vehicle cap does not remove infrastructure limits, membership permissions or tenant isolation.

## Verification, 2026-11-08

- 167 unit tests, TypeScript, ESLint and Next production build passed.
- Local PostgreSQL integration: 42 assertions plus a real two-transaction capacity race, covering all plans, idempotency, edit-at-capacity, suspension, retirement/reactivation, downgrade rejection, owner checks, cross-account access and grants. Fixtures were rolled back or cleaned up locally.
- 17 product browser checks (four plan dashboards/onboarding, owner plan change and existing fleet flows) and 4 website browser checks passed after updating obsolete labels. Layout checked at 1440, 390 and 320 pixels and in dark mode.
- Production additive migration applied. Existing Personal account preserved. Anonymous plan RPC and direct authenticated plan-column updates remain denied. Security advisor reported no new findings; the six pre-existing INFO notices are intentionally policy-free private service tables.
- No real customer vehicles, user accounts, memberships or payment data were created for QA.

Run `node scripts/test-account-plans.mjs` only against the isolated local test database (the script rejects non-local destinations). Browser fixtures are explicitly labeled demos.

## Production release

Application source: `8db2d698d664614c6f73f513270c655b043f41c9` ([successful CI](https://github.com/DigitalOps-Inc/LinkNodesEnergy/actions/runs/42528492611)).

- Product deployment `[operational-id-redacted]`: READY at <https://product.linknodesenergy.com>.
- Website deployment `[operational-id-redacted]`: READY at <https://linknodesenergy.com> and www alias.
- Live product: all four signed-out onboarding links select the correct plan; five dashboard/navigation/capacity browser checks pass using isolated local demo storage. The public catalog returns 1/3/10/null.
- Live website: plan links, interval presentation and mobile layouts pass. Sitemap includes the plans page; product APIs and account pages return 404 on the website surface. HTTP checks use the execution environment's configured proxy.
- Vercel's Git integration could not locate the private repository, so both deployments used the exact committed GitHub source file set with existing uploaded asset digests. Automatic Git deployment still needs repository access in Vercel; this did not block the release.
- The mobile browser assertion now waits for streamed page content before measuring layout. No production accounts were created or changed during browser verification.
