Tighten Care free tier and bill Pro/Enterprise per branch.
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:
isaacclad
2026-07-15 14:14:35 +00:00
parent 78be5c803d
commit f9aa4a679f
19 changed files with 414 additions and 193 deletions
@@ -52,8 +52,11 @@ class BranchController extends Controller
->where('organization_id', $organization->id)
->count();
if (! app(PlanService::class)->canAddBranch($organization, $currentCount)) {
return back()->withInput()->with('error', 'Your plan allows one branch. Upgrade to Care Pro for unlimited branches.');
$plans = app(PlanService::class);
if (! $plans->canAddBranch($organization, $currentCount)) {
return redirect()
->route('care.pro.index')
->with('upsell', $plans->branchLimitMessage($organization));
}
$validated = $request->validate([
+35 -34
View File
@@ -26,8 +26,9 @@ class ProController extends Controller
? Carbon::parse($settings['plan_expires_at'])
: null;
$planKey = $plans->planKey($organization);
$branchCount = $plans->activeBranchCount($organization);
$enterprisePrice = $plans->enterprisePriceMinor($organization);
$branchCount = max(1, $plans->activeBranchCount($organization));
$proTotal = $plans->proPriceTotalMinor($organization);
$enterpriseTotal = $plans->enterprisePriceMinor($organization);
return view('care.pro.index', [
'organization' => $organization,
@@ -36,16 +37,17 @@ class ProController extends Controller
'isEnterprise' => $planKey === 'enterprise',
'hasPaidPlan' => $plans->hasPaidPlan($organization),
'canManage' => $canManage,
'proPriceMinor' => $plans->proPriceMinor(),
'proPricePerBranchMinor' => $plans->proPricePerBranchMinor(),
'proPriceMinor' => $proTotal,
'enterprisePricePerBranchMinor' => $plans->enterprisePricePerBranchMinor(),
'enterprisePriceMinor' => $enterprisePrice,
'enterprisePriceMinor' => $enterpriseTotal,
'branchCount' => $branchCount,
'canSubscribeEnterprise' => $plans->canSubscribeEnterprise($organization),
'enterpriseMinBranches' => (int) config('care.enterprise.min_branches', 2),
'enterpriseMinBranches' => (int) config('care.enterprise.min_branches', 1),
'prepaidMonths' => (array) config('care.prepaid_months', [6, 12, 24]),
'currency' => (string) config('billing.currency', 'GHS'),
'planExpiresAt' => $expiresAt,
'enterpriseBilledBranches' => (int) ($settings['enterprise_billed_branches'] ?? $branchCount),
'billedBranches' => (int) ($settings['billed_branches'] ?? $branchCount),
'salesUrl' => ladill_platform_url('contact-sales'),
]);
}
@@ -60,15 +62,18 @@ class ProController extends Controller
->with('success', 'Your organization already has an active paid plan.');
}
$branches = max(1, $plans->activeBranchCount($organization));
return $this->chargeMonthlyWallet(
$organization,
$billing,
$plans->proPriceMinor(),
$plans->proPriceTotalMinor($organization),
'pro',
'care_pro',
'care-pro-'.$organization->id.'-'.now()->format('Y-m-d-His'),
'Ladill Care Pro — monthly subscription',
'Ladill Care Pro — '.$branches.' branch(es) monthly',
'Welcome to Care Pro — active for one month.',
$branches,
);
}
@@ -83,12 +88,14 @@ class ProController extends Controller
}
if (! $plans->canSubscribeEnterprise($organization)) {
$min = (int) config('care.enterprise.min_branches', 2);
$min = (int) config('care.enterprise.min_branches', 1);
return redirect()->route('care.pro.index')
->with('error', "Enterprise billing requires at least {$min} active branches. Add another branch or choose Pro for a single site.");
->with('error', "Enterprise requires at least {$min} active branch. Contact sales for custom multi-site onboarding.");
}
$branches = max(1, $plans->activeBranchCount($organization));
return $this->chargeMonthlyWallet(
$organization,
$billing,
@@ -96,9 +103,9 @@ class ProController extends Controller
'enterprise',
'care_enterprise',
'care-enterprise-'.$organization->id.'-'.now()->format('Y-m-d-His'),
'Ladill Care Enterprise — monthly subscription',
'Ladill Care Enterprise — '.$branches.' branch(es) monthly',
'Welcome to Care Enterprise — active for one month.',
$plans->activeBranchCount($organization),
$branches,
);
}
@@ -120,17 +127,15 @@ class ProController extends Controller
$months = (int) $validated['months'];
if ($plan === 'enterprise' && ! $plans->canSubscribeEnterprise($organization)) {
$min = (int) config('care.enterprise.min_branches', 2);
$min = (int) config('care.enterprise.min_branches', 1);
return redirect()->route('care.pro.index')
->with('error', "Enterprise billing requires at least {$min} active branches.");
->with('error', "Enterprise requires at least {$min} active branch.");
}
$monthlyMinor = $plan === 'enterprise'
? $plans->enterprisePriceMinor($organization)
: $plans->proPriceMinor();
$branches = max(1, $plans->activeBranchCount($organization));
$monthlyMinor = $plans->monthlyPriceMinor($organization, $plan);
$amountMinor = $monthlyMinor * $months;
$branches = $plan === 'enterprise' ? $plans->activeBranchCount($organization) : null;
try {
$checkout = $billing->initiatePlanCheckout(
@@ -139,10 +144,10 @@ class ProController extends Controller
$months,
$amountMinor,
route('care.pro.paystack.callback'),
array_filter([
[
'organization_id' => $organization->id,
'enterprise_billed_branches' => $branches,
], static fn ($v) => $v !== null),
'billed_branches' => $branches,
],
);
} catch (\Throwable) {
return redirect()->route('care.pro.index')
@@ -191,9 +196,9 @@ class ProController extends Controller
$plan = (string) ($result['plan'] ?? 'pro');
$months = (int) ($result['months'] ?? 0);
$branches = isset($metadata['enterprise_billed_branches'])
? (int) $metadata['enterprise_billed_branches']
: null;
$branches = isset($metadata['billed_branches'])
? (int) $metadata['billed_branches']
: max(1, $plans->activeBranchCount($organization));
$this->activatePrepaidPlan($organization, $plan, $months, $branches);
@@ -212,7 +217,7 @@ class ProController extends Controller
string $reference,
string $description,
string $successMessage,
?int $enterpriseBranches = null,
int $billedBranches,
): RedirectResponse {
try {
if (! $billing->canAfford($organization->owner_ref, $priceMinor)) {
@@ -241,13 +246,11 @@ class ProController extends Controller
$settings['plan'] = $plan;
$settings['auto_renew'] = true;
$settings['billing_method'] = 'wallet_monthly';
$settings['billed_branches'] = $billedBranches;
$settings['plan_expires_at'] = now()
->addDays((int) config('care.pro.period_days', 30))
->toIso8601String();
if ($enterpriseBranches !== null) {
$settings['enterprise_billed_branches'] = $enterpriseBranches;
}
unset($settings['plan_renewal_error']);
unset($settings['plan_renewal_error'], $settings['enterprise_billed_branches']);
$organization->update(['settings' => $settings]);
return redirect()->route('care.pro.index')->with('success', $successMessage);
@@ -257,17 +260,15 @@ class ProController extends Controller
Organization $organization,
string $plan,
int $months,
?int $enterpriseBranches = null,
int $billedBranches,
): void {
$settings = $organization->settings ?? [];
$settings['plan'] = $plan;
$settings['auto_renew'] = false;
$settings['billing_method'] = 'paystack_prepaid';
$settings['billed_branches'] = $billedBranches;
$settings['plan_expires_at'] = now()->addMonths($months)->toIso8601String();
if ($enterpriseBranches !== null) {
$settings['enterprise_billed_branches'] = $enterpriseBranches;
}
unset($settings['plan_renewal_error']);
unset($settings['plan_renewal_error'], $settings['enterprise_billed_branches']);
$organization->update(['settings' => $settings]);
}
}
@@ -8,6 +8,7 @@ use App\Models\Branch;
use App\Services\Care\AppointmentPatientNotifier;
use App\Services\Care\AuditLogger;
use App\Services\Care\CarePermissions;
use App\Services\Care\PlanService;
use App\Services\Messaging\MessagingCredentialsService;
use App\Services\Queue\QueueClient;
use App\Support\OrganizationBranding;
@@ -30,10 +31,13 @@ class SettingsController extends Controller
->where('organization_id', $organization->id)
->count();
$plans = app(PlanService::class);
return view('care.settings.edit', [
'organization' => $organization,
'canManage' => $canManage,
'branchCount' => $branchCount,
'canUseQueueIntegration' => $plans->canUseQueueIntegration($organization),
'messagingSmsReady' => $credential->hasValidSms(),
'messagingEmailReady' => $credential->hasValidBird(),
'facilityTypes' => [
@@ -50,6 +54,7 @@ class SettingsController extends Controller
$this->authorizeAbility($request, 'settings.manage');
$organization = $this->organization($request);
$owner = $this->ownerRef($request);
$plans = app(PlanService::class);
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
@@ -68,7 +73,16 @@ class SettingsController extends Controller
$settings['onboarded'] = true;
$settings['facility_type'] = $validated['facility_type'];
// Queue integration is Pro/Enterprise only — free plans cannot enable it.
$wantsQueue = $request->boolean('queue_integration_enabled');
if ($wantsQueue && ! $plans->canUseQueueIntegration($organization)) {
return redirect()
->route('care.pro.index')
->with('upsell', 'Ladill Queue integration is part of Care Pro. Upgrade to connect service queues and counters.');
}
if (! $plans->canUseQueueIntegration($organization)) {
$wantsQueue = false;
}
$settings['queue_integration_enabled'] = $wantsQueue;
$settings[AppointmentPatientNotifier::SETTING_BOOKED_SMS] = $request->boolean('notify_appointment_booked_sms');
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Http\Middleware;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\PlanService;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Blocks free-plan accounts from Pro modules (lab, pharmacy, billing, Queue integration).
*/
class EnsurePaidPlan
{
public function __construct(
protected OrganizationResolver $organizations,
protected PlanService $plans,
) {}
public function handle(Request $request, Closure $next): Response
{
$user = $request->user();
if (! $user) {
return $next($request);
}
$organization = $this->organizations->resolveForUser($user);
if (! $organization || $this->plans->hasPaidPlan($organization)) {
return $next($request);
}
if ($request->expectsJson() || $request->ajax()) {
return response()->json([
'message' => 'This feature requires Care Pro or Enterprise.',
'upgrade_url' => route('care.pro.index'),
], 402);
}
return redirect()
->route('care.pro.index')
->with('upsell', 'Lab, pharmacy, billing, and Queue integration are part of Care Pro. Upgrade to unlock them.');
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ class AppServiceProvider extends ServiceProvider
{
Event::listen(ServiceEventOccurred::class, PlatformServiceEventListener::class);
View::composer('partials.sidebar', function ($view) {
View::composer(['partials.sidebar', 'partials.topbar-desktop-widgets', 'partials.afia', 'components.app-layout'], function ($view) {
/** @var User|null $user */
$user = auth()->user();
$planKey = 'free';
+59 -6
View File
@@ -42,6 +42,17 @@ class PlanService
return in_array($this->planKey($organization), ['pro', 'enterprise'], true);
}
/** Lab, pharmacy, billing, and Ladill Queue integration require Pro or Enterprise. */
public function canUseProModules(Organization $organization): bool
{
return $this->hasPaidPlan($organization);
}
public function canUseQueueIntegration(Organization $organization): bool
{
return $this->hasPaidPlan($organization);
}
public function activeBranchCount(Organization $organization): int
{
return Branch::query()
@@ -53,8 +64,9 @@ class PlanService
public function maxBranches(Organization $organization): ?int
{
$plan = config('care.plans.'.$this->planKey($organization));
$max = $plan['max_branches'] ?? null;
return $plan['max_branches'] ?? null;
return $max === null ? null : (int) $max;
}
public function canAddBranch(Organization $organization, int $currentCount): bool
@@ -64,25 +76,66 @@ class PlanService
return $max === null || $currentCount < $max;
}
public function branchLimitMessage(Organization $organization): string
{
$max = $this->maxBranches($organization);
$key = $this->planKey($organization);
if ($key === 'free') {
return 'Your Free plan allows 1 branch. Upgrade to Care Pro for unlimited branches (billed per branch).';
}
if ($key === 'pro' && $max !== null) {
return "Your Pro plan allows up to {$max} branches (billed per branch).";
}
return 'Branch limit reached for your current plan.';
}
public function proPricePerBranchMinor(): int
{
return (int) config(
'care.plans.pro.price_minor_per_branch',
config('care.plans.pro.price_minor', 199000),
);
}
/** @deprecated Prefer proPricePerBranchMinor() — Pro is billed per branch. */
public function proPriceMinor(): int
{
return (int) config('care.plans.pro.price_minor', 19900);
return $this->proPricePerBranchMinor();
}
public function enterprisePricePerBranchMinor(): int
{
return (int) config('care.plans.enterprise.price_minor_per_branch', 49900);
return (int) config(
'care.plans.enterprise.price_minor_per_branch',
config('care.plans.enterprise.price_minor', 499000),
);
}
/** Total monthly amount for Pro = active branches × per-branch rate (min 1). */
public function proPriceTotalMinor(Organization $organization): int
{
return max(1, $this->activeBranchCount($organization)) * $this->proPricePerBranchMinor();
}
/** Total monthly amount for Enterprise = active branches × per-branch rate (min 1). */
public function enterprisePriceMinor(Organization $organization): int
{
$branches = max(1, $this->activeBranchCount($organization));
return max(1, $this->activeBranchCount($organization)) * $this->enterprisePricePerBranchMinor();
}
return $branches * $this->enterprisePricePerBranchMinor();
public function monthlyPriceMinor(Organization $organization, string $plan): int
{
return $plan === 'enterprise'
? $this->enterprisePriceMinor($organization)
: $this->proPriceTotalMinor($organization);
}
public function canSubscribeEnterprise(Organization $organization): bool
{
return $this->activeBranchCount($organization) >= (int) config('care.enterprise.min_branches', 2);
// Enterprise is a feature tier (not branch-gated). min_branches defaults to 1.
return $this->activeBranchCount($organization) >= (int) config('care.enterprise.min_branches', 1);
}
}
+7 -10
View File
@@ -50,9 +50,8 @@ class ProRenewalService
$settings = $organization->settings ?? [];
$plan = (string) ($settings['plan'] ?? 'free');
$isEnterprise = $plan === 'enterprise';
$price = $isEnterprise
? $this->plans->enterprisePriceMinor($organization)
: $this->plans->proPriceMinor();
$branches = max(1, $this->plans->activeBranchCount($organization));
$price = $this->plans->monthlyPriceMinor($organization, $plan);
$reference = ($isEnterprise ? 'care-enterprise-' : 'care-pro-')
.$organization->id.'-'.now()->format('YmdHis');
@@ -63,8 +62,8 @@ class ProRenewalService
$isEnterprise ? 'care_enterprise_renewal' : 'care_pro_renewal',
$reference,
$isEnterprise
? 'Ladill Care Enterprise — monthly renewal'
: 'Ladill Care Pro — monthly renewal',
? 'Ladill Care Enterprise — '.$branches.' branch(es) monthly renewal'
: 'Ladill Care Pro — '.$branches.' branch(es) monthly renewal',
);
} catch (\Throwable) {
$charged = false;
@@ -73,13 +72,11 @@ class ProRenewalService
if ($charged) {
$settings['plan'] = $plan;
$settings['auto_renew'] = true;
$settings['billed_branches'] = $branches;
$settings['plan_expires_at'] = now()
->addDays((int) config('care.pro.period_days', 30))
->toIso8601String();
if ($isEnterprise) {
$settings['enterprise_billed_branches'] = $this->plans->activeBranchCount($organization);
}
unset($settings['plan_renewal_error']);
unset($settings['plan_renewal_error'], $settings['enterprise_billed_branches']);
$organization->update(['settings' => $settings]);
return;
@@ -89,7 +86,7 @@ class ProRenewalService
$graceEnd = $expires->copy()->addDays((int) config('care.pro.grace_days', 3));
if ($graceEnd->isPast()) {
$settings['plan'] = 'free';
unset($settings['plan_expires_at'], $settings['enterprise_billed_branches']);
unset($settings['plan_expires_at'], $settings['billed_branches'], $settings['enterprise_billed_branches']);
$settings['plan_renewal_error'] = 'Suspended after failed renewal.';
} else {
$settings['plan_renewal_error'] = 'Renewal failed — top up your wallet.';
+1
View File
@@ -32,6 +32,7 @@ return Application::configure(basePath: dirname(__DIR__))
'platform.session' => EnsurePlatformSession::class,
'care.setup' => \App\Http\Middleware\EnsureOrganizationSetup::class,
'care.ability' => \App\Http\Middleware\EnsureCareAbility::class,
'care.paid' => \App\Http\Middleware\EnsurePaidPlan::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
+9 -4
View File
@@ -215,21 +215,26 @@ return [
'label' => 'Free',
'price_minor' => 0,
'max_branches' => 1,
// Free: core patient records, appointments & consults, basic workflows only.
],
'pro' => [
'label' => 'Pro',
'price_minor' => (int) env('CARE_PRO_PRICE_MINOR', 199000),
// Billed per active branch / month (unlimited branches).
'price_minor_per_branch' => (int) env('CARE_PRO_PRICE_PER_BRANCH_MINOR', env('CARE_PRO_PRICE_MINOR', 199000)),
'max_branches' => null,
],
'enterprise' => [
'label' => 'Enterprise',
'price_minor_per_branch' => (int) env('CARE_ENTERPRISE_PRICE_PER_BRANCH_MINOR', 499000),
// Billed per active branch / month (unlimited branches).
// Differentiator: multi-dept custom workflows, priority support, analytics, AI.
'price_minor_per_branch' => (int) env('CARE_ENTERPRISE_PRICE_PER_BRANCH_MINOR', env('CARE_ENTERPRISE_PRICE_MINOR', 499000)),
'max_branches' => null,
],
],
'enterprise' => [
'min_branches' => (int) env('CARE_ENTERPRISE_MIN_BRANCHES', 2),
// Feature tier (not branch-gated); kept for config compatibility.
'min_branches' => (int) env('CARE_ENTERPRISE_MIN_BRANCHES', 1),
],
'prepaid_months' => [6, 12, 24],
@@ -246,7 +251,7 @@ return [
'upgrade_banner' => [
'title' => 'Unlock Care Pro or Enterprise',
'description' => 'Unlimited branches, lab & pharmacy modules, encounter billing — from GHS 1990/mo.',
'description' => 'Pro from GHS 1990/branch/mo — lab, pharmacy, billing, and Queue. Enterprise adds custom multi-dept workflows, analytics, priority support, and AI-assisted healthcare integration.',
'route' => 'care.pro.index',
],
+28 -18
View File
@@ -1,6 +1,7 @@
<x-app-layout title="Plans" heading="Care plans">
@php
$proPrice = number_format($proPriceMinor / 100, 0);
$proPerBranch = number_format($proPricePerBranchMinor / 100, 0);
$proTotal = number_format($proPriceMinor / 100, 0);
$enterprisePerBranch = number_format($enterprisePricePerBranchMinor / 100, 0);
$enterpriseTotal = number_format($enterprisePriceMinor / 100, 0);
@endphp
@@ -50,13 +51,22 @@
{{-- Pro --}}
<div class="flex flex-col rounded-2xl border border-slate-200 bg-white p-6 {{ $planKey === 'pro' ? 'ring-2 ring-indigo-500' : '' }}">
<p class="text-xs font-semibold uppercase tracking-wide text-indigo-600">Pro</p>
<x-plan-tier-price :currency="$currency" :monthly-minor="$proPriceMinor" />
<p class="mt-1 text-sm text-slate-500" x-show="billing === 'monthly'">Unlimited branches</p>
<x-plan-tier-price
:currency="$currency"
:monthly-minor="$proPricePerBranchMinor"
:monthly-display="$proPerBranch"
monthly-suffix="/branch/mo"
/>
<p class="mt-1 text-sm text-slate-500" x-show="billing === 'monthly'">
Unlimited branches · {{ $branchCount }} active = {{ $currency }} {{ $proTotal }}/mo
</p>
<ul class="mt-5 flex-1 space-y-2 text-sm text-slate-700">
<li>Everything in Free</li>
<li>Full clinical workflows</li>
<li>Laboratory & pharmacy</li>
<li>Encounter billing</li>
<li>Queue integration</li>
<li>Ladill Queue integration</li>
<li>Unlimited branches (billed per branch)</li>
</ul>
<div class="mt-6">
@if ($planKey === 'pro')
@@ -65,19 +75,23 @@
@if ($planExpiresAt)
until <strong>{{ $planExpiresAt->format('d M Y') }}</strong>
@endif
@if ($billedBranches > 0)
· billed for {{ $billedBranches }} {{ str('branch')->plural($billedBranches) }}
@endif
.
</p>
@elseif ($canManage)
<form x-show="billing === 'monthly'" method="post" action="{{ route('care.pro.subscribe') }}">
@csrf
<button class="btn-primary w-full">Upgrade to Pro monthly wallet</button>
<button class="btn-primary w-full">Upgrade to Pro {{ $currency }} {{ $proTotal }}/mo wallet</button>
</form>
<template x-for="months in @js($prepaidMonths)" :key="months">
<form x-show="billing == months" method="post" action="{{ route('care.pro.subscribe-prepaid') }}">
@csrf
<input type="hidden" name="plan" value="pro">
<input type="hidden" name="months" :value="months">
<button type="submit" class="btn-primary w-full" x-text="'Pay ' + months + ' months via Paystack'"></button>
<button type="submit" class="btn-primary w-full"
x-text="'Pay ' + months + ' months via Paystack — {{ $currency }} ' + ({{ $proPriceMinor }} * months / 100).toLocaleString()"></button>
</form>
</template>
@else
@@ -92,23 +106,19 @@
<x-plan-tier-price
:currency="$currency"
:monthly-minor="$enterprisePricePerBranchMinor"
:prepaid-minor="$enterprisePriceMinor"
:monthly-display="$enterprisePerBranch"
monthly-suffix="/branch/mo"
dark
/>
<p class="mt-1 text-sm text-slate-300" x-show="billing === 'monthly'">
@if ($branchCount > 0)
{{ $branchCount }} active {{ str('branch')->plural($branchCount) }} = {{ $currency }} {{ $enterpriseTotal }}/mo
@else
Per-branch billing for multi-site
@endif
Unlimited branches · {{ $branchCount }} active = {{ $currency }} {{ $enterpriseTotal }}/mo
</p>
<ul class="mt-5 flex-1 space-y-2 text-sm text-slate-200">
<li>Everything in Pro</li>
<li>Multi-department workflows</li>
<li>Consolidated reporting</li>
<li>Dedicated onboarding (setup fee)</li>
<li>Custom multi-department workflow integration</li>
<li>Advanced data analytics</li>
<li>AI-assisted healthcare integration</li>
<li>Priority support & dedicated onboarding</li>
</ul>
<div class="mt-6 space-y-2">
@if ($planKey === 'enterprise')
@@ -117,8 +127,8 @@
@if ($planExpiresAt)
until <strong class="text-white">{{ $planExpiresAt->format('d M Y') }}</strong>
@endif
@if ($enterpriseBilledBranches > 0)
· billed for {{ $enterpriseBilledBranches }} {{ str('branch')->plural($enterpriseBilledBranches) }}
@if ($billedBranches > 0)
· billed for {{ $billedBranches }} {{ str('branch')->plural($billedBranches) }}
@endif
.
</p>
@@ -140,7 +150,7 @@
</form>
</template>
@else
<p class="text-sm text-slate-300">Add at least {{ $enterpriseMinBranches }} active branches, or choose Pro for a single site.</p>
<p class="text-sm text-slate-300">Ask an admin to upgrade, or contact sales for custom onboarding.</p>
@endif
<a href="{{ $salesUrl }}" target="_blank" rel="noopener" class="block text-center text-xs text-amber-200 underline hover:text-white">Contact sales for setup & SLA</a>
@else
+14 -5
View File
@@ -111,11 +111,20 @@
</div>
</x-settings.card>
<x-settings.card title="Integrations" description="Manage service queues and counters in Care. You must also enable Care integration in Ladill Queue settings.">
<label class="flex items-center gap-2 text-sm">
<input type="checkbox" name="queue_integration_enabled" value="1" @checked(data_get($organization->settings, 'queue_integration_enabled'))>
Enable Ladill Queue integration
</label>
<x-settings.card title="Integrations" description="Connect Ladill Queue for service counters. Requires Care Pro or Enterprise — and Care must also be enabled in Queue settings.">
@if (! empty($canUseQueueIntegration))
<label class="flex items-center gap-2 text-sm">
<input type="checkbox" name="queue_integration_enabled" value="1" @checked(data_get($organization->settings, 'queue_integration_enabled'))>
Enable Ladill Queue integration
</label>
@else
<div class="rounded-xl border border-amber-100 bg-amber-50 px-4 py-3 text-sm text-amber-900">
<p class="font-medium">Queue integration is a Pro feature</p>
<p class="mt-1 text-amber-800">Free includes core patient records, appointments &amp; consults, and basic workflows. Upgrade to connect service queues and counters.</p>
<a href="{{ route('care.pro.index') }}" class="mt-3 inline-flex text-sm font-semibold text-indigo-700 hover:text-indigo-900">View Care Pro plans </a>
</div>
<input type="hidden" name="queue_integration_enabled" value="0">
@endif
</x-settings.card>
<div class="flex justify-end">
+26 -23
View File
@@ -30,34 +30,37 @@
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.25 4.5h13.5a.75.75 0 0 1 .75.75v15.75a.75.75 0 0 1-.75.75H5.25a.75.75 0 0 1-.75-.75V5.25a.75.75 0 0 1 .75-.75Z" />'];
}
if ($permissions->can($member, 'lab.view')) {
$nav[] = ['name' => 'Laboratory', 'route' => route('care.lab.queue.index'), 'active' => request()->routeIs('care.lab.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714a2.25 2.25 0 0 0 .659 1.591L19 14.5M14.25 3.104c.251.023.501.05.75.082M19 14.5l-2.47 2.47a2.25 2.25 0 0 1-1.59.659H9.06a2.25 2.25 0 0 1-1.591-.659L5 14.5m14 0V17a2.25 2.25 0 0 1-2.25 2.25H7.25A2.25 2.25 0 0 1 5 17v-2.5" />'];
}
// Lab, pharmacy, billing, and Queue service counters are Pro/Enterprise modules.
if (! empty($hasPaidPlan)) {
if ($permissions->can($member, 'lab.view')) {
$nav[] = ['name' => 'Laboratory', 'route' => route('care.lab.queue.index'), 'active' => request()->routeIs('care.lab.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714a2.25 2.25 0 0 0 .659 1.591L19 14.5M14.25 3.104c.251.023.501.05.75.082M19 14.5l-2.47 2.47a2.25 2.25 0 0 1-1.59.659H9.06a2.25 2.25 0 0 1-1.591-.659L5 14.5m14 0V17a2.25 2.25 0 0 1-2.25 2.25H7.25A2.25 2.25 0 0 1 5 17v-2.5" />'];
}
if ($permissions->can($member, 'prescriptions.view')) {
$nav[] = ['name' => 'Pharmacy queue', 'route' => route('care.prescriptions.queue'), 'active' => request()->routeIs('care.prescriptions.*') && ! request()->routeIs('care.pharmacy.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714a2.25 2.25 0 0 0 .659 1.591L19 14.5" />'];
}
if ($permissions->can($member, 'prescriptions.view')) {
$nav[] = ['name' => 'Pharmacy queue', 'route' => route('care.prescriptions.queue'), 'active' => request()->routeIs('care.prescriptions.*') && ! request()->routeIs('care.pharmacy.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714a2.25 2.25 0 0 0 .659 1.591L19 14.5" />'];
}
if ($permissions->can($member, 'pharmacy.view')) {
$nav[] = ['name' => 'Inventory', 'route' => route('care.pharmacy.drugs.index'), 'active' => request()->routeIs('care.pharmacy.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5a1.125 1.125 0 0 0-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z" />'];
}
if ($permissions->can($member, 'pharmacy.view')) {
$nav[] = ['name' => 'Inventory', 'route' => route('care.pharmacy.drugs.index'), 'active' => request()->routeIs('care.pharmacy.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5a1.125 1.125 0 0 0-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z" />'];
}
if ($permissions->can($member, 'bills.view')) {
$nav[] = ['name' => 'Billing', 'route' => route('care.bills.index'), 'active' => request()->routeIs('care.bills.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18.75a60.07 60.07 0 0 1 15.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 0 1 3 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 0 0-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 0 1-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 0 0 3 15h-.375M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />'];
}
if ($permissions->can($member, 'bills.view')) {
$nav[] = ['name' => 'Billing', 'route' => route('care.bills.index'), 'active' => request()->routeIs('care.bills.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18.75a60.07 60.07 0 0 1 15.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 0 1 3 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 0 0-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 0 1-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 0 0 3 15h-.375M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />'];
}
if ($permissions->can($member, 'reports.finance.view')) {
$nav[] = ['name' => 'Reports', 'route' => route('care.reports.index'), 'active' => request()->routeIs('care.reports.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 0 1 3 19.875v-6.75ZM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125V8.625ZM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125V4.125Z" />'];
}
if ($permissions->can($member, 'reports.finance.view')) {
$nav[] = ['name' => 'Reports', 'route' => route('care.reports.index'), 'active' => request()->routeIs('care.reports.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 0 1 3 19.875v-6.75ZM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125V8.625ZM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125V4.125Z" />'];
}
if ($organization && data_get($organization->settings, 'queue_integration_enabled') && $permissions->can($member, 'service_queues.console')) {
$nav[] = ['name' => 'Service queues', 'route' => route('care.service-queues.index'), 'active' => request()->routeIs('care.service-queues.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 6v.75m0 3v.75m0 3v.75m0 3V18m-9-5.25h5.25M7.5 15h3M3.375 5.25c-.621 0-1.125.504-1.125 1.125v3.026a2.999 2.999 0 0 1 0 5.198v3.026c0 .621.504 1.125 1.125 1.125h17.25c.621 0 1.125-.504 1.125-1.125v-3.026a2.999 2.999 0 0 1 0-5.198V6.375c0-.621-.504-1.125-1.125-1.125H3.375Z" />'];
if ($organization && data_get($organization->settings, 'queue_integration_enabled') && $permissions->can($member, 'service_queues.console')) {
$nav[] = ['name' => 'Service queues', 'route' => route('care.service-queues.index'), 'active' => request()->routeIs('care.service-queues.*'),
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 6v.75m0 3v.75m0 3v.75m0 3V18m-9-5.25h5.25M7.5 15h3M3.375 5.25c-.621 0-1.125.504-1.125 1.125v3.026a2.999 2.999 0 0 1 0 5.198v3.026c0 .621.504 1.125 1.125 1.125h17.25c.621 0 1.125-.504 1.125-1.125v-3.026a2.999 2.999 0 0 1 0-5.198V6.375c0-.621-.504-1.125-1.125-1.125H3.375Z" />'];
}
}
$adminNav = [];
+52 -50
View File
@@ -82,61 +82,63 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
Route::get('/queue', [QueueController::class, 'index'])->name('care.queue.index');
Route::post('/queue/{appointment}/start', [QueueController::class, 'start'])->name('care.queue.start');
Route::get('/service-queues', [ServiceQueueController::class, 'index'])->name('care.service-queues.index');
Route::get('/service-queues/console/{counterUuid}', [ServiceQueueController::class, 'console'])->name('care.service-queues.console');
Route::post('/service-queues/console/{counterUuid}/action', [ServiceQueueController::class, 'action'])->name('care.service-queues.action');
Route::middleware('care.paid')->group(function () {
Route::get('/service-queues', [ServiceQueueController::class, 'index'])->name('care.service-queues.index');
Route::get('/service-queues/console/{counterUuid}', [ServiceQueueController::class, 'console'])->name('care.service-queues.console');
Route::post('/service-queues/console/{counterUuid}/action', [ServiceQueueController::class, 'action'])->name('care.service-queues.action');
Route::get('/lab/requests', [InvestigationController::class, 'index'])->name('care.lab.requests.index');
Route::get('/lab/queue', [InvestigationController::class, 'queue'])->name('care.lab.queue.index');
Route::get('/lab/requests/{investigation}', [InvestigationController::class, 'show'])->name('care.lab.requests.show');
Route::post('/consultations/{consultation}/investigations', [InvestigationController::class, 'requestFromConsultation'])->name('care.lab.requests.store');
Route::post('/lab/requests/{investigation}/collect-sample', [InvestigationController::class, 'collectSample'])->name('care.lab.requests.collect-sample');
Route::post('/lab/requests/{investigation}/start', [InvestigationController::class, 'startProcessing'])->name('care.lab.requests.start');
Route::post('/lab/requests/{investigation}/results', [InvestigationController::class, 'enterResults'])->name('care.lab.requests.results');
Route::post('/lab/requests/{investigation}/approve', [InvestigationController::class, 'approve'])->name('care.lab.requests.approve');
Route::post('/lab/requests/{investigation}/deliver', [InvestigationController::class, 'deliver'])->name('care.lab.requests.deliver');
Route::post('/lab/requests/{investigation}/cancel', [InvestigationController::class, 'cancel'])->name('care.lab.requests.cancel');
Route::get('/lab/catalog', [InvestigationTypeController::class, 'index'])->name('care.lab.catalog.index');
Route::get('/lab/catalog/create', [InvestigationTypeController::class, 'create'])->name('care.lab.catalog.create');
Route::post('/lab/catalog', [InvestigationTypeController::class, 'store'])->name('care.lab.catalog.store');
Route::get('/lab/catalog/{investigationType}/edit', [InvestigationTypeController::class, 'edit'])->name('care.lab.catalog.edit');
Route::put('/lab/catalog/{investigationType}', [InvestigationTypeController::class, 'update'])->name('care.lab.catalog.update');
Route::get('/prescriptions', [PrescriptionController::class, 'index'])->name('care.prescriptions.index');
Route::get('/prescriptions/queue', [PrescriptionController::class, 'queue'])->name('care.prescriptions.queue');
Route::get('/consultations/{consultation}/prescriptions/create', [PrescriptionController::class, 'create'])->name('care.prescriptions.create');
Route::post('/consultations/{consultation}/prescriptions', [PrescriptionController::class, 'store'])->name('care.prescriptions.store');
Route::get('/prescriptions/{prescription}', [PrescriptionController::class, 'show'])->name('care.prescriptions.show');
Route::post('/prescriptions/{prescription}/activate', [PrescriptionController::class, 'activate'])->name('care.prescriptions.activate');
Route::post('/prescriptions/{prescription}/dispense', [PrescriptionController::class, 'dispense'])->name('care.prescriptions.dispense');
Route::post('/prescriptions/{prescription}/cancel', [PrescriptionController::class, 'cancel'])->name('care.prescriptions.cancel');
Route::get('/bills', [BillController::class, 'index'])->name('care.bills.index');
Route::post('/visits/{visit}/bill', [BillController::class, 'generate'])->name('care.bills.generate');
Route::get('/bills/{bill}', [BillController::class, 'show'])->name('care.bills.show');
Route::get('/bills/{bill}/print', [BillController::class, 'print'])->name('care.bills.print');
Route::post('/bills/{bill}/line-items', [BillController::class, 'addLineItem'])->name('care.bills.line-items.store');
Route::post('/bills/{bill}/adjustments', [BillController::class, 'applyAdjustments'])->name('care.bills.adjustments');
Route::post('/bills/{bill}/payments', [BillController::class, 'recordPayment'])->name('care.bills.payments.store');
Route::post('/bills/{bill}/void', [BillController::class, 'void'])->name('care.bills.void');
Route::get('/pharmacy/drugs', [DrugController::class, 'index'])->name('care.pharmacy.drugs.index');
Route::get('/pharmacy/drugs/create', [DrugController::class, 'create'])->name('care.pharmacy.drugs.create');
Route::post('/pharmacy/drugs', [DrugController::class, 'store'])->name('care.pharmacy.drugs.store');
Route::get('/pharmacy/drugs/{drug}', [DrugController::class, 'show'])->name('care.pharmacy.drugs.show');
Route::get('/pharmacy/drugs/{drug}/edit', [DrugController::class, 'edit'])->name('care.pharmacy.drugs.edit');
Route::put('/pharmacy/drugs/{drug}', [DrugController::class, 'update'])->name('care.pharmacy.drugs.update');
Route::post('/pharmacy/drugs/{drug}/batches', [DrugController::class, 'receiveBatch'])->name('care.pharmacy.drugs.batches.store');
Route::get('/reports', [ReportController::class, 'index'])->name('care.reports.index');
Route::get('/reports/{type}', [ReportController::class, 'show'])->name('care.reports.show');
Route::get('/reports/{type}/export', [ReportController::class, 'export'])->name('care.reports.export');
});
Route::get('/consultations/{consultation}', [ConsultationController::class, 'show'])->name('care.consultations.show');
Route::put('/consultations/{consultation}', [ConsultationController::class, 'update'])->name('care.consultations.update');
Route::post('/consultations/{consultation}/complete', [ConsultationController::class, 'complete'])->name('care.consultations.complete');
Route::get('/lab/requests', [InvestigationController::class, 'index'])->name('care.lab.requests.index');
Route::get('/lab/queue', [InvestigationController::class, 'queue'])->name('care.lab.queue.index');
Route::get('/lab/requests/{investigation}', [InvestigationController::class, 'show'])->name('care.lab.requests.show');
Route::post('/consultations/{consultation}/investigations', [InvestigationController::class, 'requestFromConsultation'])->name('care.lab.requests.store');
Route::post('/lab/requests/{investigation}/collect-sample', [InvestigationController::class, 'collectSample'])->name('care.lab.requests.collect-sample');
Route::post('/lab/requests/{investigation}/start', [InvestigationController::class, 'startProcessing'])->name('care.lab.requests.start');
Route::post('/lab/requests/{investigation}/results', [InvestigationController::class, 'enterResults'])->name('care.lab.requests.results');
Route::post('/lab/requests/{investigation}/approve', [InvestigationController::class, 'approve'])->name('care.lab.requests.approve');
Route::post('/lab/requests/{investigation}/deliver', [InvestigationController::class, 'deliver'])->name('care.lab.requests.deliver');
Route::post('/lab/requests/{investigation}/cancel', [InvestigationController::class, 'cancel'])->name('care.lab.requests.cancel');
Route::get('/lab/catalog', [InvestigationTypeController::class, 'index'])->name('care.lab.catalog.index');
Route::get('/lab/catalog/create', [InvestigationTypeController::class, 'create'])->name('care.lab.catalog.create');
Route::post('/lab/catalog', [InvestigationTypeController::class, 'store'])->name('care.lab.catalog.store');
Route::get('/lab/catalog/{investigationType}/edit', [InvestigationTypeController::class, 'edit'])->name('care.lab.catalog.edit');
Route::put('/lab/catalog/{investigationType}', [InvestigationTypeController::class, 'update'])->name('care.lab.catalog.update');
Route::get('/prescriptions', [PrescriptionController::class, 'index'])->name('care.prescriptions.index');
Route::get('/prescriptions/queue', [PrescriptionController::class, 'queue'])->name('care.prescriptions.queue');
Route::get('/consultations/{consultation}/prescriptions/create', [PrescriptionController::class, 'create'])->name('care.prescriptions.create');
Route::post('/consultations/{consultation}/prescriptions', [PrescriptionController::class, 'store'])->name('care.prescriptions.store');
Route::get('/prescriptions/{prescription}', [PrescriptionController::class, 'show'])->name('care.prescriptions.show');
Route::post('/prescriptions/{prescription}/activate', [PrescriptionController::class, 'activate'])->name('care.prescriptions.activate');
Route::post('/prescriptions/{prescription}/dispense', [PrescriptionController::class, 'dispense'])->name('care.prescriptions.dispense');
Route::post('/prescriptions/{prescription}/cancel', [PrescriptionController::class, 'cancel'])->name('care.prescriptions.cancel');
Route::get('/bills', [BillController::class, 'index'])->name('care.bills.index');
Route::post('/visits/{visit}/bill', [BillController::class, 'generate'])->name('care.bills.generate');
Route::get('/bills/{bill}', [BillController::class, 'show'])->name('care.bills.show');
Route::get('/bills/{bill}/print', [BillController::class, 'print'])->name('care.bills.print');
Route::post('/bills/{bill}/line-items', [BillController::class, 'addLineItem'])->name('care.bills.line-items.store');
Route::post('/bills/{bill}/adjustments', [BillController::class, 'applyAdjustments'])->name('care.bills.adjustments');
Route::post('/bills/{bill}/payments', [BillController::class, 'recordPayment'])->name('care.bills.payments.store');
Route::post('/bills/{bill}/void', [BillController::class, 'void'])->name('care.bills.void');
Route::get('/pharmacy/drugs', [DrugController::class, 'index'])->name('care.pharmacy.drugs.index');
Route::get('/pharmacy/drugs/create', [DrugController::class, 'create'])->name('care.pharmacy.drugs.create');
Route::post('/pharmacy/drugs', [DrugController::class, 'store'])->name('care.pharmacy.drugs.store');
Route::get('/pharmacy/drugs/{drug}', [DrugController::class, 'show'])->name('care.pharmacy.drugs.show');
Route::get('/pharmacy/drugs/{drug}/edit', [DrugController::class, 'edit'])->name('care.pharmacy.drugs.edit');
Route::put('/pharmacy/drugs/{drug}', [DrugController::class, 'update'])->name('care.pharmacy.drugs.update');
Route::post('/pharmacy/drugs/{drug}/batches', [DrugController::class, 'receiveBatch'])->name('care.pharmacy.drugs.batches.store');
Route::get('/reports', [ReportController::class, 'index'])->name('care.reports.index');
Route::get('/reports/{type}', [ReportController::class, 'show'])->name('care.reports.show');
Route::get('/reports/{type}/export', [ReportController::class, 'export'])->name('care.reports.export');
Route::get('/settings', [SettingsController::class, 'edit'])->name('care.settings');
Route::put('/settings', [SettingsController::class, 'update'])->name('care.settings.update');
+1 -1
View File
@@ -40,7 +40,7 @@ class CareBillTest extends TestCase
'name' => 'Test Clinic',
'slug' => 'test-clinic',
'timezone' => 'UTC',
'settings' => ['onboarded' => true],
'settings' => ['onboarded' => true, 'plan' => 'pro', 'plan_expires_at' => now()->addMonth()->toIso8601String()],
]);
Member::create([
+1 -1
View File
@@ -50,7 +50,7 @@ class CareLabTest extends TestCase
'name' => 'Test Clinic',
'slug' => 'test-clinic',
'timezone' => 'UTC',
'settings' => ['onboarded' => true],
'settings' => ['onboarded' => true, 'plan' => 'pro', 'plan_expires_at' => now()->addMonth()->toIso8601String()],
]);
Member::create([
+1 -1
View File
@@ -50,7 +50,7 @@ class CarePharmacyInventoryTest extends TestCase
'name' => 'Test Clinic',
'slug' => 'test-clinic',
'timezone' => 'UTC',
'settings' => ['onboarded' => true],
'settings' => ['onboarded' => true, 'plan' => 'pro', 'plan_expires_at' => now()->addMonth()->toIso8601String()],
]);
Member::create([
+1 -1
View File
@@ -42,7 +42,7 @@ class CarePrescriptionTest extends TestCase
'name' => 'Test Clinic',
'slug' => 'test-clinic',
'timezone' => 'UTC',
'settings' => ['onboarded' => true],
'settings' => ['onboarded' => true, 'plan' => 'pro', 'plan_expires_at' => now()->addMonth()->toIso8601String()],
]);
Member::create([
+114 -35
View File
@@ -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']);
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ class CareReportTest extends TestCase
'name' => 'Test Clinic',
'slug' => 'test-clinic',
'timezone' => 'UTC',
'settings' => ['onboarded' => true],
'settings' => ['onboarded' => true, 'plan' => 'pro', 'plan_expires_at' => now()->addMonth()->toIso8601String()],
]);
Member::create([