Skip to main content

Enterprise Billing

Enterprise Billing allows platform administrators to manually manage workspace plans, billing periods, and invoices — independently of Stripe subscriptions.

Overview

EW-FLOW supports two billing models that can coexist:

ModelManaged byBilling period sourceInvoice source
StripeSelf-serviceStripe subscription (current_period_start/end)Stripe webhooks
EnterprisePlatform adminenterprise_plan table (BillingPeriodStart/End)Manual invoices via admin UI

When a workspace is marked as Enterprise Managed, an EnterprisePlan record is created with a custom billing period, cycle length, auto-renew flag, and contact details. The admin can assign any plan tier and manage invoices directly.

Architecture

Data Model

Key Relationships

  • Workspace → EnterprisePlan: One-to-one. Created when admin enables enterprise. Deactivated (not deleted) when enterprise is removed.
  • Workspace → WorkspaceInvoice: One-to-many. Manual invoices created by admin.
  • Workspace → StripeSubscription → StripeInvoice: Stripe-managed billing chain. Coexists with enterprise — when a Stripe subscription is created, the enterprise plan is automatically deactivated.

Admin Workflow

Single-Form Management

The admin manages each workspace through a single dialog that combines all settings:

Invoice Management

Metrics & Cron Service

The BillingPeriodMetricsCronService runs every 5 minutes and computes workspace metrics using the correct billing period source.

Cron Execution Flow

Billing Period Resolution

The cron service determines which billing period to use for execution counters and limits:

Dashboard Display

The dashboard subscription header card renders based on billing source priority:

Metrics Hydration

When the dashboard loads, the StatsRepository ensures enterprise info is always available — even if the cron hasn't run yet:

Auto-Renewal Flow

Stripe and Enterprise Interaction

When a Stripe subscription is created for an enterprise workspace, the enterprise plan is automatically deactivated to prevent double billing:

File Reference

ComponentPathRole
Admin UIClient/Pages/AdminEnterprise.razorSingle-form workspace management
Admin APIServer/Controllers/AdminEnterpriseController.csCRUD endpoints for plans, invoices, settings
DashboardClient/Pages/Dashboard.razorSubscription header card rendering
Metrics APIServer/Controllers/Workspace/MetricsController.csBilling period metrics endpoint
Stats RepoServer/Repositories/Implementations/StatsRepository.csMetrics retrieval + enterprise hydration
Invoice RepoServer/Repositories/Implementations/InvoiceRepository.csAll-invoices query (Stripe + manual)
Cron ServiceServer/Services/Implementations/BillingPeriodMetricsCronService.csMetrics computation, auto-renew, archiving
Shared ModelsShared/Models/EnterpriseModels.csRequest/response DTOs
Metrics ModelShared/Models/BillingPeriodMetrics.csDashboard metrics model with EnterprisePlanInfo
EntityWorkflowEngineLibrary/Core/Models/EnterprisePlan.csEF Core entity
DB ContextWorkflowDatabase/WilsonCoreContext.csEnterprisePlan mapping
SQL MigrationWorkflowDatabase/Design/create_enterprise_plan.sqlTable DDL