fix: don't rely on individual prices being available for all participants

This commit is contained in:
Björn Fromme
2025-11-06 15:24:51 +01:00
parent f19762d686
commit 2f78ddb8ad
+5 -4
View File
@@ -110,19 +110,20 @@ class Booking
// Sum up all services // Sum up all services
foreach ([...$this->transportationServices, ...$this->additionalServices] as $service) { foreach ([...$this->transportationServices, ...$this->additionalServices] as $service) {
if (in_array($participantIndex, $service->mapping) || true === $service->mandatory) { if (in_array($participantIndex, $service->mapping) || true === $service->mandatory) {
$price += $service->individualPrice[$participantIndex]; $price += $service->individualPrice[$participantIndex] ?? 0;
} }
} }
// Sum up all surcharges // Sum up all surcharges
foreach ($this->surcharges as $surcharge) { foreach ($this->surcharges as $surcharge) {
if (in_array($participantIndex, $surcharge->mapping)) { if (in_array($participantIndex, $surcharge->mapping)) {
$price += $surcharge->individualPrice[$participantIndex]; $price += $surcharge->individualPrice[$participantIndex] ?? 0;
} }
} }
$room = $this->getRoomForParticipant($participantIndex); if (null !== $room = $this->getRoomForParticipant($participantIndex)) {
$price += $room->individualPrice[$participantIndex]; $price += $room->individualPrice[$participantIndex] ?? 0;
}
return $price; return $price;
} }