Repository navigation
feat(billing): bill admin-created companies, add managed_by_aixle - #449
Merged
Merged
Conversation
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]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 defaultactive, which on the hosted product means "somebody is paying". It had no Stripe customer, so:trialing.What
A company created from the admin pays by default (hosted product only). It starts
trialingand 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):Company.billing_billable, so neither the meter nor the subscription sync sends anything for it;trialingorblocked: the model keeps itactive, so the trial job and a payment-failed webhook cannot stop it;can_manage_billingis false), and every billing action, Checkout included, redirects with "managed by Aixle";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 nostripe_customer_idis 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
activewith 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_ENABLEDdoes not gate this.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