fix: correctly determine number of participants

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent 1f2f2751e4
commit b73a02048e
+25 -1
View File
@@ -75,9 +75,12 @@ class BookingSummaryDataService
// Fetch CMS data (images, etc.) // Fetch CMS data (images, etc.)
$cmsData = $this->getCmsData($bookingDto); $cmsData = $this->getCmsData($bookingDto);
// Calculate participant count from room capacity (source of truth)
$participantCount = $this->calculateParticipantCountFromRooms($bookingDto);
return [ return [
'selectedRooms' => $selectedRooms, 'selectedRooms' => $selectedRooms,
'participantCount' => count($bookingDto->participants), 'participantCount' => $participantCount,
'totalPrice' => number_format($totalPrice, 2, ',', '.').' €', 'totalPrice' => number_format($totalPrice, 2, ',', '.').' €',
'groupedSelectedRooms' => $groupedSelectedRooms, 'groupedSelectedRooms' => $groupedSelectedRooms,
'assignmentCounts' => $roomCounts, 'assignmentCounts' => $roomCounts,
@@ -86,6 +89,27 @@ class BookingSummaryDataService
]; ];
} }
/**
* Calculates participant count from room selections.
*
* This is the source of truth for participant count, calculated by
* multiplying each selected room's quantity by its maximum capacity (maxPax).
*/
private function calculateParticipantCountFromRooms(BookingDto $bookingDto): int
{
$totalCapacity = 0;
$availableRooms = $bookingDto->travel->getAvailableRooms();
foreach ($bookingDto->roomSelections as $selection) {
if ($selection->quantity > 0 && isset($availableRooms[$selection->roomId])) {
$room = $availableRooms[$selection->roomId];
$totalCapacity += $selection->quantity * ($room->maxPax ?? 0);
}
}
return $totalCapacity;
}
/** /**
* Fetches CMS data for the product and hotel in the booking. * Fetches CMS data for the product and hotel in the booking.
* *