Bill Frontdesk Pro and Enterprise per branch.
Deploy Ladill Frontdesk / deploy (push) Successful in 47s
Deploy Ladill Frontdesk / deploy (push) Successful in 47s
Pro is GHS 990/branch/mo and Enterprise is GHS 1990/branch/mo, with the Care-style branch selector UI, self-serve Enterprise checkout, and renewal charges scaled to billed branches.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Frontdesk;
|
||||
|
||||
use App\Models\Branch;
|
||||
use App\Models\Device;
|
||||
use App\Models\Organization;
|
||||
use Carbon\Carbon;
|
||||
@@ -32,10 +33,9 @@ class PlanService
|
||||
return $this->planKey($organization) === 'enterprise';
|
||||
}
|
||||
|
||||
/** Self-serve paid plans only — enterprise is sales-led. */
|
||||
public function hasPaidPlan(Organization $organization): bool
|
||||
{
|
||||
return $this->planKey($organization) === 'pro';
|
||||
return in_array($this->planKey($organization), ['pro', 'enterprise'], true);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
@@ -49,7 +49,7 @@ class PlanService
|
||||
];
|
||||
}
|
||||
|
||||
/** Null means unlimited included host emails (Pro). */
|
||||
/** Null means unlimited included host emails (Pro / Enterprise). */
|
||||
public function freeEmailsPerMonth(Organization $organization): ?int
|
||||
{
|
||||
$value = config('frontdesk.plans.'.$this->planKey($organization).'.free_emails_per_month', 100);
|
||||
@@ -57,6 +57,14 @@ class PlanService
|
||||
return $value === null ? null : (int) $value;
|
||||
}
|
||||
|
||||
public function activeBranchCount(Organization $organization): int
|
||||
{
|
||||
return Branch::query()
|
||||
->where('organization_id', $organization->id)
|
||||
->where('is_active', true)
|
||||
->count();
|
||||
}
|
||||
|
||||
public function canAddBranch(Organization $organization, int $currentCount): bool
|
||||
{
|
||||
$limit = config('frontdesk.plans.'.$this->planKey($organization).'.max_branches');
|
||||
@@ -86,8 +94,59 @@ class PlanService
|
||||
return in_array($feature, $features, true);
|
||||
}
|
||||
|
||||
public function proPricePerBranchMinor(): int
|
||||
{
|
||||
return (int) config(
|
||||
'frontdesk.plans.pro.price_minor_per_branch',
|
||||
config('frontdesk.plans.pro.price_minor', 99000),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Per-branch rate (legacy callers treated this as a flat monthly fee).
|
||||
*
|
||||
* @deprecated Prefer proPricePerBranchMinor() / priceForBranches().
|
||||
*/
|
||||
public function proPriceMinor(): int
|
||||
{
|
||||
return (int) config('frontdesk.plans.pro.price_minor', 7900);
|
||||
return $this->proPricePerBranchMinor();
|
||||
}
|
||||
|
||||
public function enterprisePricePerBranchMinor(): int
|
||||
{
|
||||
return (int) config('frontdesk.plans.enterprise.price_minor_per_branch', 199000);
|
||||
}
|
||||
|
||||
public function proPriceTotalMinor(Organization $organization): int
|
||||
{
|
||||
return $this->priceForBranches('pro', $this->activeBranchCount($organization));
|
||||
}
|
||||
|
||||
public function enterprisePriceMinor(Organization $organization): int
|
||||
{
|
||||
return $this->priceForBranches('enterprise', $this->activeBranchCount($organization));
|
||||
}
|
||||
|
||||
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, $requested);
|
||||
$active = max(1, $this->activeBranchCount($organization));
|
||||
|
||||
return max($branches, $active);
|
||||
}
|
||||
|
||||
public function canSubscribeEnterprise(Organization $organization): bool
|
||||
{
|
||||
return $this->activeBranchCount($organization) >= (int) config('frontdesk.enterprise.min_branches', 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user