Skip to content

feat(billing): bill workspaces under a parent workspace#1320

Draft
vklimontovich wants to merge 1 commit into
newjitsufrom
feat/workspace-billing-parent
Draft

feat(billing): bill workspaces under a parent workspace#1320
vklimontovich wants to merge 1 commit into
newjitsufrom
feat/workspace-billing-parent

Conversation

@vklimontovich
Copy link
Copy Markdown
Contributor

What

A workspace can now bill under a parent workspace. The child inherits the parent's
plan, and the parent's billing page consolidates usage for the whole group.

  • Child workspace/settings/billing shows a card linking to the parent's billing
    page instead of its own billing UI. The child inherits the parent's plan (limits,
    feature gating, pastDue), and no Stripe customer is created for it.
  • Parent workspace/settings/billing sums events and active syncs across the
    parent and all its children (summed totals only, no per-child breakdown).
  • Standalone workspace — unchanged.

How

  • The parent→child relation lives in ee-api (newjitsuee schema) in a new
    WorkspaceBillingParent table, with all hierarchy/consolidation logic in
    lib/billing-hierarchy.ts.
  • getOrCreateCurrentSubscription returns the parent's subscription for a child,
    tagged with a billingParent marker.
  • Consolidated usage rides on the existing /api/billing/settings endpoint via an
    opt-in ?withUsage=true flag — no new endpoints. The app-wide BillingProvider
    fetch stays light; only the billing page requests usage.
  • Links are managed from a new Billing Parents page in the ee-api admin UI
    (/billing-parents), backed by /api/admin/billing-parents.
  • Constraints: only one level of nesting (a parent cannot itself have a parent), and
    free workspaces cannot be joined.

Notes / follow-ups

  • Requires prisma db push on the newjitsuee schema to create
    workspace_billing_parent.
  • Quota enforcement / throttling on consolidated group usage is intentionally out of
    scope — grouped workspaces are paid, so the only enforcement that matters
    (pastDue) is inherited by children automatically.
  • The "View detailed stat" drill-down (/settings/billing/details) still shows a
    single workspace, not the consolidated group.
  • ee-api has no test harness, so billing-hierarchy validation is not unit-tested.

Verification

  1. pnpm codegen, then pnpm --filter ee-api db:update-schema to create the table.
  2. pnpm ui:dev; in the ee-api admin Billing Parents page, link a paid child under
    a paid parent.
  3. Child /settings/billing shows the link card; parent /settings/billing shows
    summed usage. Self-link / two-level nesting / free-plan child are rejected.

A workspace can now bill under a parent. The child inherits the parent's
plan and its billing page links to the parent; the parent's billing page
sums events and syncs across the whole group.

The parent-child relation and consolidation logic live in ee-api
(newjitsuee schema). Links are managed from a new admin UI page. Only
one level of nesting is allowed and free workspaces cannot be joined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant