Limit Pro to 3 branches and leave Business unlimited.
Deploy Ladill POS / deploy (push) Successful in 2m15s

Enforce plan location caps in SubscriptionService, surface upgrade
copy on plans and branch settings, and cover the limits in tests.
This commit is contained in:
isaacclad
2026-07-15 15:24:51 +00:00
parent e2b608a506
commit 5e31bdf629
7 changed files with 142 additions and 7 deletions
+66
View File
@@ -47,6 +47,20 @@ class PosMultiBranchTest extends TestCase
]);
}
private function activateBusiness(User $user): void
{
ProSubscription::create([
'user_id' => $user->id,
'plan' => ProSubscription::PLAN_ENTERPRISE,
'status' => ProSubscription::STATUS_ACTIVE,
'price_minor' => 24900,
'currency' => 'GHS',
'auto_renew' => true,
'started_at' => now(),
'current_period_end' => now()->addMonth(),
]);
}
protected function setUp(): void
{
parent::setUp();
@@ -104,6 +118,58 @@ class PosMultiBranchTest extends TestCase
$this->assertSame(2, PosLocation::owned($owner->public_id)->count());
}
public function test_pro_account_cannot_add_fourth_branch(): void
{
$owner = $this->owner();
$this->activatePro($owner);
foreach (['Main', 'Mall', 'Airport'] as $i => $name) {
PosLocation::create([
'owner_ref' => $owner->public_id,
'name' => $name,
'currency' => 'GHS',
'is_default' => $i === 0,
]);
}
$this->assertSame(3, PosLocation::owned($owner->public_id)->count());
$this->actingAs($owner)
->post(route('pos.branches.store'), [
'name' => 'Fourth branch',
'currency' => 'GHS',
'service_style' => 'retail',
])
->assertRedirect(route('pos.pro.index'));
$this->assertSame(3, PosLocation::owned($owner->public_id)->count());
}
public function test_business_account_can_add_beyond_three_branches(): void
{
$owner = $this->owner();
$this->activateBusiness($owner);
foreach (['Main', 'Mall', 'Airport'] as $i => $name) {
PosLocation::create([
'owner_ref' => $owner->public_id,
'name' => $name,
'currency' => 'GHS',
'is_default' => $i === 0,
]);
}
$this->actingAs($owner)
->post(route('pos.branches.store'), [
'name' => 'Fourth branch',
'currency' => 'GHS',
'service_style' => 'retail',
])
->assertRedirect(route('pos.settings').'#branches');
$this->assertSame(4, PosLocation::owned($owner->public_id)->count());
}
public function test_cashier_is_limited_to_assigned_branch_sales(): void
{
$owner = $this->owner();