Harte Teilnehmer-Obergrenze je Tarif statt automatischem Stufenwechsel
Statt automatisch hochzustufen, blockiert das Anlegen/Reaktivieren weiterer aktiver Mitglieder, sobald das Limit des gebuchten Tarifs erreicht ist (Neuanlage, Bearbeiten mit Statuswechsel, Aktivieren- Button). mitarbeiterverwalten.php zeigt die aktuelle Auslastung an. Neuer Regressionstest scripts/check-billing-capacity.php deckt alle drei Enforcement-Stellen ab.
This commit is contained in:
@@ -129,6 +129,34 @@ function billing_find_tenant_id_by_stripe_subscription(PDO $pdo, string $stripeS
|
||||
return $tenantId !== false ? (int)$tenantId : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hard cap enforcement: whether the tenant's current plan still has room
|
||||
* for $additional more active participants. There is no automatic plan
|
||||
* upgrade - tenants that outgrow their plan must upgrade themselves
|
||||
* (mandant-einstellungen.php) before adding/reactivating more members.
|
||||
*/
|
||||
function billing_has_capacity_for(PDO $pdo, int $tenantId, int $additional = 1): bool
|
||||
{
|
||||
$billing = billing_fetch_or_init($pdo, $tenantId);
|
||||
$max = billing_plans()[$billing['plan_code']]['max_participants'] ?? null;
|
||||
if ($max === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return billing_count_active_participants($pdo, $tenantId) + $additional <= $max;
|
||||
}
|
||||
|
||||
function billing_capacity_error_message(PDO $pdo, int $tenantId): string
|
||||
{
|
||||
$billing = billing_fetch_or_init($pdo, $tenantId);
|
||||
$plan = billing_plans()[$billing['plan_code']] ?? null;
|
||||
$label = $plan['label'] ?? $billing['plan_code'];
|
||||
$max = $plan['max_participants'] ?? null;
|
||||
|
||||
return "Euer aktueller Tarif „{$label}\" erlaubt maximal {$max} aktive Mitglieder. "
|
||||
. 'Bitte upgradet unter Mandant-Einstellungen, um mehr Mitglieder freizuschalten.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the tenant's currently booked plan against what their active
|
||||
* participant count actually requires. Purely informational until the
|
||||
|
||||
Reference in New Issue
Block a user