Add branch count control to Queue plans page.
Deploy Ladill Queue / deploy (push) Successful in 33s

Match Care/Frontdesk: branches stepper next to billing period, live
totals, and checkout charges for the selected seat count.
This commit is contained in:
isaacclad
2026-07-16 09:36:36 +00:00
parent 8892316664
commit 8be3eaeb4b
4 changed files with 121 additions and 46 deletions
+23 -11
View File
@@ -67,16 +67,23 @@ class ProController extends Controller
->with('success', 'Your organization already has an active paid plan.');
}
$validated = $request->validate([
'branches' => ['required', 'integer', 'min:1', 'max:999'],
]);
$branches = $plans->resolveCheckoutBranches($organization, (int) $validated['branches']);
$amountMinor = $plans->priceForBranches('pro', $branches);
return $this->chargeMonthlyWallet(
$organization,
$billing,
$plans->proPriceMinor($organization),
$amountMinor,
'pro',
'queue_pro',
'queue-pro-'.$organization->id.'-'.now()->format('Y-m-d-His'),
'Ladill Queue Pro — monthly subscription',
'Ladill Queue Pro — '.$branches.' branch(es) monthly',
'Welcome to Queue Pro — active for one month.',
$plans->activeBranchCount($organization),
$branches,
);
}
@@ -97,16 +104,23 @@ class ProController extends Controller
->with('error', "Enterprise billing requires at least {$min} active branches. Add another branch or choose Pro for a single site.");
}
$validated = $request->validate([
'branches' => ['required', 'integer', 'min:1', 'max:999'],
]);
$branches = $plans->resolveCheckoutBranches($organization, (int) $validated['branches']);
$amountMinor = $plans->priceForBranches('enterprise', $branches);
return $this->chargeMonthlyWallet(
$organization,
$billing,
$plans->enterprisePriceMinor($organization),
$amountMinor,
'enterprise',
'queue_enterprise',
'queue-enterprise-'.$organization->id.'-'.now()->format('Y-m-d-His'),
'Ladill Queue Enterprise — monthly subscription',
'Ladill Queue Enterprise — '.$branches.' branch(es) monthly',
'Welcome to Queue Enterprise — active for one month.',
$plans->activeBranchCount($organization),
$branches,
);
}
@@ -116,6 +130,7 @@ class ProController extends Controller
$validated = $request->validate([
'plan' => ['required', 'in:pro,enterprise'],
'months' => ['required', 'integer', 'in:6,12,24'],
'branches' => ['required', 'integer', 'min:1', 'max:999'],
]);
$organization = $this->organization($request);
@@ -134,11 +149,8 @@ class ProController extends Controller
->with('error', "Enterprise billing requires at least {$min} active branches.");
}
$monthlyMinor = $plan === 'enterprise'
? $plans->enterprisePriceMinor($organization)
: $plans->proPriceMinor($organization);
$amountMinor = $monthlyMinor * $months;
$branches = $plans->activeBranchCount($organization);
$branches = $plans->resolveCheckoutBranches($organization, (int) $validated['branches']);
$amountMinor = $plans->priceForBranches($plan, $branches) * $months;
$metadata = [
'organization_id' => $organization->id,
+20 -5
View File
@@ -84,9 +84,7 @@ class PlanService
public function proPriceMinor(Organization $organization): int
{
$branches = max(1, $this->activeBranchCount($organization));
return $branches * $this->proPricePerBranchMinor();
return $this->priceForBranches('pro', $this->activeBranchCount($organization));
}
public function enterprisePricePerBranchMinor(): int
@@ -96,9 +94,26 @@ class PlanService
public function enterprisePriceMinor(Organization $organization): int
{
$branches = max(1, $this->activeBranchCount($organization));
return $this->priceForBranches('enterprise', $this->activeBranchCount($organization));
}
return $branches * $this->enterprisePricePerBranchMinor();
/** Fixed branch count × per-branch rate (checkout when the user picks seats). */
public function priceForBranches(string $plan, int $branches): int
{
$branches = max(1, $branches);
$rate = $plan === 'enterprise'
? $this->enterprisePricePerBranchMinor()
: $this->proPricePerBranchMinor();
return $branches * $rate;
}
public function resolveCheckoutBranches(Organization $organization, int $requested): int
{
$branches = max(1, min(999, $requested));
$active = max(1, $this->activeBranchCount($organization));
return max($branches, $active);
}
public function canSubscribeEnterprise(Organization $organization): bool