Skip to content

feat(billing): bill admin-created companies, add managed_by_aixle - #449

Merged
artempartos merged 1 commit into
developfrom
artempartos/managed-by-aixle
Oct 8, 2026
Merged

artempartos merged 1 commit into
developfrom
artempartos/managed-by-aixle

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Why

On staging, the company Tuesday was created from the admin and its Billing tab showed Active with "Current period: — – —" and a Cancel subscription button that refuses. There was no way to add a card.

The admin create form never set billing_state, so the company kept the column default active, which on the hosted product means "somebody is paying". It had no Stripe customer, so:

  • the Billing tab had nothing to show and offered no Checkout;
  • the meter counted its capacity as billable and then dropped it for want of a customer. That is 70 worker-hours since 2026-10-05, nowhere invoiced;
  • no allowance applied, because the company was not trialing.

What

A company created from the admin pays by default (hosted product only). It starts trialing and needs a worker limit, like a self-serve signup. Creating one without a limit is refused, because a company with no limit is metered at nothing.

New flag companies.managed_by_aixle, for a company we carry (ours, a partner's, a pilot):

  • never billed: excluded from Company.billing_billable, so neither the meter nor the subscription sync sends anything for it;
  • never trialing or blocked: the model keeps it active, so the trial job and a payment-failed webhook cannot stop it;
  • no Billing tab (can_manage_billing is false), and every billing action, Checkout included, redirects with "managed by Aixle";
  • starts with 2 workers (Company::MANAGED_SESSION_LIMIT) when created without a limit. Its own admins see the number read-only ("contact us to change this"), and only a platform administrator can change it, from the admin.

The admin shows the flag on the new, edit, show and index pages, with a filter.

Migration backfill (hosted product only): every company with billing_state = 'active' and no stripe_customer_id is marked managed. That is what they already were in effect, since nobody bills them. Limits are not touched; Dualboot stays unbounded. Self-hosted installations (DEPLOYMENT_MODE=self_hosted) get the column without the backfill, so their company admins keep the limit.

This reverses #358's rule

#358 put only self-serve signups on the free allowance. Its concern was an operator's customer stopping after 100 worker-hours because a column default said so. Here the trial is chosen explicitly by the admin's create action, next to a visible Managed by Aixle checkbox, and the column default stays active. The docs (docs/product/self-serve-signup.md, docs/user-guide/session-queues.md) and the onboarding form's comments now say so.

After deploy

  • Prod (checked read-only 2026-10-09): all three companies — Dualboot Partners, Acme, Microsoft-Dualboot — are active with no Stripe customer and no limit. The backfill marks all three managed; their billing does not change (nothing bills them today), they stay unbounded, and their Billing tab disappears. From now on, a company created from the admin starts on the allowance and needs a card after 100 worker-hours. REGISTRATION_ENABLED does not gate this.
  • Staging: the backfill marks Tuesday managed, along with Dualboot, ATC, Demo and Client Co. To make Tuesday a paying customer instead, untick the flag and set its billing state to trialing. It has already spent 70 of its 100 hours.

Known edge, not handled: marking a company with a live Stripe subscription as managed stops the meter sending its minutes, but the subscription itself keeps running until it is cancelled in Stripe.

Verification

CI is the verification for the full suite. Locally: the new and touched test files, the schema parity test, rubocop and brakeman.

🤖 Generated with Claude Code

A company created from the admin kept the column default `active`, which
in the hosted product means somebody is paying. With no Stripe customer
behind it, its Billing tab showed an empty period and no way to add a
card, and the meter dropped its minutes (staging's Tuesday: 70
worker-hours, invoiced nowhere).

In saas the admin's create action now starts a company `trialing` and
requires a worker limit, like a self-serve signup. That reverses #358's
"allowance for self-serve only" rule: the trial is chosen by the path,
next to a visible Managed by Aixle checkbox, and the column default
stays `active`.

`managed_by_aixle` marks a company we carry. It is never billable, stays
`active`, has no Billing tab or Checkout, starts with two workers, and
only a platform administrator can change its limit. The migration marks
every saas company that is `active` with no Stripe customer, which is
what they already were in effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit f796952 into develop Oct 8, 2026
8 checks passed
@artempartos artempartos mentioned this pull request Oct 8, 2026
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