Tighten Care free tier and bill Pro/Enterprise per branch.
Deploy Ladill Care / deploy (push) Successful in 29s
Deploy Ladill Care / deploy (push) Successful in 29s
Free keeps core records, appointments, and basic workflows; Pro unlocks lab, pharmacy, billing, and Queue. Both paid tiers bill per branch with unlimited branches. Enterprise adds multi-dept workflows, analytics, AI-assisted healthcare integration, and priority support (not Afia).
This commit is contained in:
+114
-35
@@ -59,12 +59,83 @@ class CareProTest extends TestCase
|
||||
->get(route('care.pro.index'))
|
||||
->assertOk()
|
||||
->assertSee('Choose your Care plan')
|
||||
->assertSee('GHS 199')
|
||||
->assertSee('GHS 499')
|
||||
->assertSee('1990')
|
||||
->assertSee('4990')
|
||||
->assertSee('/branch/mo')
|
||||
->assertSee('Unlimited branches')
|
||||
->assertSee('Core patient records')
|
||||
->assertSee('Queue integration')
|
||||
->assertSee('Custom multi-department workflow')
|
||||
->assertSee('AI-assisted healthcare integration')
|
||||
->assertSee('Upgrade to Pro')
|
||||
->assertSee('Enterprise');
|
||||
}
|
||||
|
||||
public function test_free_plan_cannot_enable_queue_integration(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->put(route('care.settings.update'), [
|
||||
'name' => 'Care Org',
|
||||
'timezone' => 'Africa/Accra',
|
||||
'facility_type' => 'clinic',
|
||||
'queue_integration_enabled' => '1',
|
||||
])
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('upsell');
|
||||
|
||||
$this->organization->refresh();
|
||||
$this->assertFalse((bool) data_get($this->organization->settings, 'queue_integration_enabled'));
|
||||
}
|
||||
|
||||
public function test_free_plan_is_blocked_from_lab_module(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.lab.queue.index'))
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('upsell');
|
||||
}
|
||||
|
||||
public function test_pro_plan_allows_unlimited_branches(): void
|
||||
{
|
||||
$this->organization->update([
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'pro',
|
||||
'plan_expires_at' => now()->addMonth()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$this->assertNull(app(\App\Services\Care\PlanService::class)->maxBranches($this->organization->fresh()));
|
||||
$this->assertTrue(app(\App\Services\Care\PlanService::class)->canAddBranch($this->organization->fresh(), 50));
|
||||
}
|
||||
|
||||
public function test_enterprise_plan_allows_unlimited_branches(): void
|
||||
{
|
||||
$this->organization->update([
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'enterprise',
|
||||
'plan_expires_at' => now()->addMonth()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$this->assertNull(app(\App\Services\Care\PlanService::class)->maxBranches($this->organization->fresh()));
|
||||
$this->assertTrue(app(\App\Services\Care\PlanService::class)->canAddBranch($this->organization->fresh(), 50));
|
||||
}
|
||||
|
||||
public function test_subscribe_enterprise_no_longer_requires_multiple_branches(): void
|
||||
{
|
||||
Http::fake([
|
||||
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
||||
'billing.test/debit' => Http::response(['ok' => true]),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.pro.subscribe-enterprise'))
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$this->assertSame('enterprise', $this->organization->fresh()->settings['plan']);
|
||||
}
|
||||
|
||||
public function test_sidebar_shows_upgrade_to_pro_on_dashboard(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
@@ -123,35 +194,6 @@ class CareProTest extends TestCase
|
||||
$this->assertSame('wallet_monthly', $settings['billing_method']);
|
||||
}
|
||||
|
||||
public function test_subscribe_enterprise_requires_multiple_branches(): void
|
||||
{
|
||||
Http::fake([
|
||||
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
||||
'billing.test/debit' => Http::response(['ok' => true]),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.pro.subscribe-enterprise'))
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('error');
|
||||
|
||||
Branch::create([
|
||||
'owner_ref' => $this->organization->owner_ref,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Second',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.pro.subscribe-enterprise'))
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('enterprise', $settings['plan']);
|
||||
$this->assertSame(2, $settings['enterprise_billed_branches']);
|
||||
}
|
||||
|
||||
public function test_subscribe_prepaid_redirects_to_paystack(): void
|
||||
{
|
||||
Http::fake([
|
||||
@@ -227,14 +269,16 @@ class CareProTest extends TestCase
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'enterprise',
|
||||
'auto_renew' => true,
|
||||
'enterprise_billed_branches' => 2,
|
||||
'plan_expires_at' => now()->subDay()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$perBranch = (int) config('care.plans.enterprise.price_minor_per_branch');
|
||||
$expected = $perBranch * 2;
|
||||
|
||||
Http::fake([
|
||||
'billing.test/debit' => function ($request) {
|
||||
$this->assertSame(99800, (int) $request['amount_minor']);
|
||||
'billing.test/debit' => function ($request) use ($expected) {
|
||||
$this->assertSame($expected, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
@@ -244,6 +288,41 @@ class CareProTest extends TestCase
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('enterprise', $settings['plan']);
|
||||
$this->assertSame(2, $settings['enterprise_billed_branches']);
|
||||
$this->assertSame(2, $settings['billed_branches']);
|
||||
}
|
||||
|
||||
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,
|
||||
'plan_expires_at' => now()->subDay()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$perBranch = (int) config('care.plans.pro.price_minor_per_branch');
|
||||
$expected = $perBranch * 2;
|
||||
|
||||
Http::fake([
|
||||
'billing.test/debit' => function ($request) use ($expected) {
|
||||
$this->assertSame($expected, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
]);
|
||||
|
||||
$this->artisan('care:pro-renew')->assertSuccessful();
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('pro', $settings['plan']);
|
||||
$this->assertSame(2, $settings['billed_branches']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user