Harden per-branch billing with seat caps and mid-cycle expansion.
Deploy Ladill Frontdesk / deploy (push) Successful in 55s

Enforce billed_branches when adding or reactivating branches, charge
wallet for extra seats mid-cycle, fix Settings for Enterprise, and
cover multi-branch checkout and renewal amounts in tests.
This commit is contained in:
isaacclad
2026-07-16 08:08:10 +00:00
parent bdbf572f19
commit 59433f2b7b
8 changed files with 449 additions and 24 deletions
@@ -43,13 +43,14 @@ class BranchController extends Controller
{
$this->authorizeAbility($request, 'admin.branches.manage');
$organization = $this->organization($request);
$plans = app(\App\Services\Frontdesk\PlanService::class);
$currentCount = Branch::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
->count();
if (! app(\App\Services\Frontdesk\PlanService::class)->canAddBranch($organization, $currentCount)) {
return back()->withInput()->with('error', 'Your plan allows one branch. Upgrade to Frontdesk Pro for unlimited branches.');
if (! $plans->canAddBranch($organization, $currentCount)) {
return back()->withInput()->with('error', $plans->branchLimitMessage($organization));
}
$validated = $request->validate([
@@ -90,6 +91,15 @@ class BranchController extends Controller
'is_active' => ['boolean'],
]);
$activating = $request->boolean('is_active') && ! $branch->is_active;
if ($activating) {
$plans = app(\App\Services\Frontdesk\PlanService::class);
$organization = $this->organization($request);
if (! $plans->canActivateBranch($organization)) {
return back()->withInput()->with('error', $plans->branchLimitMessage($organization));
}
}
$branch->update([
...$validated,
'is_active' => $request->boolean('is_active'),