Bill Queue Pro per active branch like Enterprise.
Deploy Ladill Queue / deploy (push) Successful in 33s
Deploy Ladill Queue / deploy (push) Successful in 33s
Show /branch/mo pricing with live branch totals on the plans page, charge subscribe/prepaid/renewals by branch count, and store pro_billed_branches.
This commit is contained in:
@@ -44,12 +44,16 @@ class QmsProTest extends TestCase
|
||||
|
||||
public function test_pro_page_renders_three_tier_pricing(): void
|
||||
{
|
||||
$proPerBranch = number_format((int) config('qms.plans.pro.price_minor_per_branch') / 100, 0);
|
||||
$enterprisePerBranch = number_format((int) config('qms.plans.enterprise.price_minor_per_branch') / 100, 0);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('qms.pro.index'))
|
||||
->assertOk()
|
||||
->assertSee('Choose your Queue plan')
|
||||
->assertSee('GHS 99')
|
||||
->assertSee('GHS 299')
|
||||
->assertSee('GHS '.$proPerBranch)
|
||||
->assertSee('GHS '.$enterprisePerBranch)
|
||||
->assertSee('/branch/mo')
|
||||
->assertSee('Upgrade to Pro')
|
||||
->assertSee('Enterprise');
|
||||
}
|
||||
@@ -109,7 +113,9 @@ class QmsProTest extends TestCase
|
||||
->assertRedirect(route('qms.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$this->assertSame('pro', $this->organization->fresh()->settings['plan']);
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('pro', $settings['plan']);
|
||||
$this->assertSame(1, $settings['pro_billed_branches']);
|
||||
}
|
||||
|
||||
public function test_subscribe_enterprise_requires_multiple_branches(): void
|
||||
@@ -147,21 +153,64 @@ class QmsProTest extends TestCase
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'pro',
|
||||
'auto_renew' => true,
|
||||
'pro_billed_branches' => 1,
|
||||
'plan_expires_at' => now()->subDay()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$expected = (int) config('qms.plans.pro.price_minor_per_branch');
|
||||
|
||||
Http::fake([
|
||||
'billing.test/debit' => Http::response(['ok' => true]),
|
||||
'billing.test/debit' => function ($request) use ($expected) {
|
||||
$this->assertSame($expected, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
]);
|
||||
|
||||
$this->artisan('qms:pro-renew')->assertSuccessful();
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('pro', $settings['plan']);
|
||||
$this->assertSame(1, $settings['pro_billed_branches']);
|
||||
$this->assertTrue(now()->parse($settings['plan_expires_at'])->isFuture());
|
||||
}
|
||||
|
||||
public function test_pro_renew_charges_per_active_branch(): void
|
||||
{
|
||||
Branch::create([
|
||||
'owner_ref' => $this->organization->owner_ref,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Second',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->organization->update([
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'pro',
|
||||
'auto_renew' => true,
|
||||
'pro_billed_branches' => 1,
|
||||
'plan_expires_at' => now()->subDay()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$expected = 2 * (int) config('qms.plans.pro.price_minor_per_branch');
|
||||
|
||||
Http::fake([
|
||||
'billing.test/debit' => function ($request) use ($expected) {
|
||||
$this->assertSame($expected, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
]);
|
||||
|
||||
$this->artisan('qms:pro-renew')->assertSuccessful();
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('pro', $settings['plan']);
|
||||
$this->assertSame(2, $settings['pro_billed_branches']);
|
||||
}
|
||||
|
||||
public function test_enterprise_renew_charges_per_active_branch(): void
|
||||
{
|
||||
Branch::create([
|
||||
@@ -180,9 +229,11 @@ class QmsProTest extends TestCase
|
||||
]),
|
||||
]);
|
||||
|
||||
$expected = 2 * (int) config('qms.plans.enterprise.price_minor_per_branch');
|
||||
|
||||
Http::fake([
|
||||
'billing.test/debit' => function ($request) {
|
||||
$this->assertSame(59800, (int) $request['amount_minor']);
|
||||
'billing.test/debit' => function ($request) use ($expected) {
|
||||
$this->assertSame($expected, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user