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:
@@ -74,9 +74,19 @@ class PlanService
|
||||
return $max === null || $currentCount < $max;
|
||||
}
|
||||
|
||||
public function proPriceMinor(): int
|
||||
public function proPricePerBranchMinor(): int
|
||||
{
|
||||
return (int) config('qms.plans.pro.price_minor', 249000);
|
||||
return (int) config(
|
||||
'qms.plans.pro.price_minor_per_branch',
|
||||
config('qms.plans.pro.price_minor', 249000)
|
||||
);
|
||||
}
|
||||
|
||||
public function proPriceMinor(Organization $organization): int
|
||||
{
|
||||
$branches = max(1, $this->activeBranchCount($organization));
|
||||
|
||||
return $branches * $this->proPricePerBranchMinor();
|
||||
}
|
||||
|
||||
public function enterprisePricePerBranchMinor(): int
|
||||
|
||||
@@ -52,9 +52,10 @@ class ProRenewalService
|
||||
$isEnterprise = $plan === 'enterprise';
|
||||
$price = $isEnterprise
|
||||
? $this->plans->enterprisePriceMinor($organization)
|
||||
: $this->plans->proPriceMinor();
|
||||
: $this->plans->proPriceMinor($organization);
|
||||
$reference = ($isEnterprise ? 'queue-enterprise-' : 'queue-pro-')
|
||||
.$organization->id.'-'.now()->format('YmdHis');
|
||||
$branchCount = $this->plans->activeBranchCount($organization);
|
||||
|
||||
try {
|
||||
$charged = $this->billing->debit(
|
||||
@@ -77,7 +78,11 @@ class ProRenewalService
|
||||
->addDays((int) config('qms.pro.period_days', 30))
|
||||
->toIso8601String();
|
||||
if ($isEnterprise) {
|
||||
$settings['enterprise_billed_branches'] = $this->plans->activeBranchCount($organization);
|
||||
$settings['enterprise_billed_branches'] = $branchCount;
|
||||
unset($settings['pro_billed_branches']);
|
||||
} else {
|
||||
$settings['pro_billed_branches'] = $branchCount;
|
||||
unset($settings['enterprise_billed_branches']);
|
||||
}
|
||||
unset($settings['plan_renewal_error']);
|
||||
$organization->update(['settings' => $settings]);
|
||||
@@ -89,7 +94,11 @@ class ProRenewalService
|
||||
$graceEnd = $expires->copy()->addDays((int) config('qms.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['enterprise_billed_branches'],
|
||||
$settings['pro_billed_branches'],
|
||||
);
|
||||
$settings['plan_renewal_error'] = 'Suspended after failed renewal.';
|
||||
} else {
|
||||
$settings['plan_renewal_error'] = 'Renewal failed — top up your wallet.';
|
||||
|
||||
Reference in New Issue
Block a user