fix: correctly calculate undersubscription fees

This commit is contained in:
Björn Fromme
2026-08-06 12:05:03 +02:00
parent 3a5895e356
commit 577f7445ab
2 changed files with 99 additions and 4 deletions
+11 -4
View File
@@ -244,10 +244,17 @@ class GroupsPriceCalculator
$shortTermSurcharge = (int) round(($basePrice + $additionalPersonsPrice) * self::SHORT_TERM_FACTORS[$nights] / 100);
}
// Rule 4: undersubscription surcharge (only when board is selected)
// Board is only billable — and only triggers the catering surcharge when it costs
// something. A free "Selbstversorgung" board is stored as 0 (BoardService::$price is
// non-nullable), so a plain null check would charge the surcharge for it.
$paidBoardPricePerPersonNight = ($boardServicePricePerPersonNight ?? 0) > 0
? $boardServicePricePerPersonNight
: null;
// Rule 4: undersubscription surcharge (only when a paid board is selected)
$undersubscriptionSurcharge = 0;
$undersubscriptionThreshold = null;
if ($boardServicePricePerPersonNight !== null) {
if ($paidBoardPricePerPersonNight !== null) {
$surcharge30 = (int) round(('CHF' === $currency ? $this->config['undersubscription30Chf'] : $this->config['undersubscription30Eur']) * 100);
$surcharge40 = (int) round(('CHF' === $currency ? $this->config['undersubscription40Chf'] : $this->config['undersubscription40Eur']) * 100);
@@ -262,8 +269,8 @@ class GroupsPriceCalculator
// Rule 5: board price
$boardPrice = 0;
if ($boardServicePricePerPersonNight !== null) {
$boardPrice = $boardServicePricePerPersonNight * $effectivePax * $nights;
if ($paidBoardPricePerPersonNight !== null) {
$boardPrice = $paidBoardPricePerPersonNight * $effectivePax * $nights;
}
// Rule 6: additional services