chore: cgl fixes

This commit is contained in:
2026-09-11 19:37:00 +02:00
parent 5f8a586385
commit 5b133f724d
26 changed files with 87 additions and 92 deletions
+12 -11
View File
@@ -30,6 +30,7 @@ class GroupsPriceCalculator
/**
* @param array<string, int|float> $config
*
* @return array<string, int|float>
*/
private function resolveConfig(array $config): array
@@ -47,8 +48,8 @@ class GroupsPriceCalculator
}
/**
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param AdditionalService[] $additionalServices only the selected services
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param AdditionalService[] $additionalServices only the selected services
*
* @return array{
* effectivePax: int,
@@ -88,7 +89,7 @@ class GroupsPriceCalculator
$prices,
$boardService?->getPrice(),
array_map(
fn(AdditionalService $s) => [
fn (AdditionalService $s) => [
'label' => $s->getLabel() ?? '',
'price' => $s->getPrice() ?? 0,
'type' => $s->getType(),
@@ -103,7 +104,7 @@ class GroupsPriceCalculator
* Same calculation but using frozen snapshot data from an AccommodationBooking entity
* instead of live catalog entities.
*
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param AccommodationPrice[] $prices all prices overlapping the booking window
* @param list<array{label: string, price: int, type: string, originalServiceId: int|null}> $additionalServiceSnapshots
*
* @return array{
@@ -136,7 +137,7 @@ class GroupsPriceCalculator
string $currency,
): array {
$items = array_map(
fn(array $s) => [
fn (array $s) => [
'label' => $s['label'],
'price' => $s['price'],
'type' => AdditionalServiceType::tryFrom($s['type']) ?? AdditionalServiceType::Flat,
@@ -158,7 +159,7 @@ class GroupsPriceCalculator
}
/**
* @param AccommodationPrice[] $prices
* @param AccommodationPrice[] $prices
* @param list<array{label: string, price: int, type: AdditionalServiceType}> $additionalItems
*
* @return array{
@@ -193,7 +194,7 @@ class GroupsPriceCalculator
// Derive effectivePax: children 03 don't count, but never drop below includedPax
$firstCandidates = array_values(array_filter(
$prices,
fn(AccommodationPrice $p) => $p->getDateFrom() <= $dateFrom && $p->getDateTo() >= $dateFrom,
fn (AccommodationPrice $p) => $p->getDateFrom() <= $dateFrom && $p->getDateTo() >= $dateFrom,
));
$firstWinner = $this->priceTimelineBuilder->resolveWinner($firstCandidates);
$includedPaxFloor = $firstWinner?->getIncludedPax() ?? 1;
@@ -224,11 +225,11 @@ class GroupsPriceCalculator
$candidates = array_values(array_filter(
$prices,
fn(AccommodationPrice $p) => $p->getDateFrom() <= $segStart && $p->getDateTo() >= $segStart,
fn (AccommodationPrice $p) => $p->getDateFrom() <= $segStart && $p->getDateTo() >= $segStart,
));
$winner = $this->priceTimelineBuilder->resolveWinner($candidates) ?? $lastWinner;
if ($winner !== null) {
if (null !== $winner) {
$lastWinner = $winner;
$basePrice += ($winner->getPricePerNight() ?? 0) * $segNights;
$includedPax = $winner->getIncludedPax() ?? 0;
@@ -254,7 +255,7 @@ class GroupsPriceCalculator
// Rule 4: undersubscription surcharge (only when a paid board is selected)
$undersubscriptionSurcharge = 0;
$undersubscriptionThreshold = null;
if ($paidBoardPricePerPersonNight !== null) {
if (null !== $paidBoardPricePerPersonNight) {
$surcharge30 = (int) round(('CHF' === $currency ? $this->config['undersubscription30Chf'] : $this->config['undersubscription30Eur']) * 100);
$surcharge40 = (int) round(('CHF' === $currency ? $this->config['undersubscription40Chf'] : $this->config['undersubscription40Eur']) * 100);
@@ -269,7 +270,7 @@ class GroupsPriceCalculator
// Rule 5: board price
$boardPrice = 0;
if ($paidBoardPricePerPersonNight !== null) {
if (null !== $paidBoardPricePerPersonNight) {
$boardPrice = $paidBoardPricePerPersonNight * $effectivePax * $nights;
}