Functional contract

SaaS billing

Organization plan subscriptions, usage credits, and Stripe PaymentIntents. Not clinic AR / patient invoices — see Billing and finance.

Shipped docs/functional/saas-billing.md

Pricing and renewals

Trial and testing credits

Plan upgrades and downgrades

Direction via Billing::PlanRank (price, then credits / position). Same plan is a no-op.

ChangeWhenBehavior
UpgradeImmediateProrated PaymentIntent (plan_change); credits adjust; plan switches now; billing day unchanged
DowngradeNext renewalpending_plan_id / pending_plan_scheduled_on; blocked if over target caps; applied by Billing::PendingPlanApplier before renew charge

Other lifecycle

UI

Full contract: docs/functional/saas-billing.md.