fix: properly handle 'veg' services in booking edit flow
This commit is contained in:
@@ -105,6 +105,9 @@ class BookingDataProcessor
|
||||
$participantData->board = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_BOARD);
|
||||
|
||||
$vegServices = $booking->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_VEG);
|
||||
$participantData->veg = false === empty($vegServices) ? reset($vegServices) : null;
|
||||
|
||||
$participantData->rentals = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_RENTALS);
|
||||
|
||||
@@ -211,6 +214,11 @@ class BookingDataProcessor
|
||||
}
|
||||
}
|
||||
|
||||
// Enrich veg
|
||||
if (null !== $participant->veg && isset($travel->additionalServices[$participant->veg->id])) {
|
||||
$participant->veg = $travel->additionalServices[$participant->veg->id];
|
||||
}
|
||||
|
||||
// Enrich rentals
|
||||
foreach ($participant->rentals as $key => $rental) {
|
||||
if (isset($travel->additionalServices[$rental->id])) {
|
||||
|
||||
@@ -171,8 +171,8 @@ class BookingPayloadBuilder
|
||||
'@idzimmer' => $room->id,
|
||||
'@kategorie' => $room->category,
|
||||
'@idverpflegung' => $room->boardId,
|
||||
'@anreise' => $room->dateFrom ? $room->dateFrom->format('d.m.Y') : null,
|
||||
'@abreise' => $room->dateTo ? $room->dateTo->format('d.m.Y') : null,
|
||||
'@anreise' => $room->dateFrom?->format('d.m.Y'),
|
||||
'@abreise' => $room->dateTo?->format('d.m.Y'),
|
||||
'@anzahl' => $room->totalCount,
|
||||
'@zuordnung' => implode(',', array_map(fn ($index) => $index + 1, $uniqueMapping)),
|
||||
];
|
||||
|
||||
@@ -131,6 +131,11 @@ class ParticipantServiceProcessor
|
||||
...$participant->rentals,
|
||||
];
|
||||
|
||||
// Veg is encoded as an additional service in the edit/update payload.
|
||||
if (null !== $participant->veg) {
|
||||
$services[] = $participant->veg;
|
||||
}
|
||||
|
||||
// Add ski pass if selected (single service, not an array)
|
||||
if (null !== $participant->skiPass) {
|
||||
$services[] = $participant->skiPass;
|
||||
|
||||
@@ -96,6 +96,7 @@ class BookingChangeTracker
|
||||
'skiPass' => $participant->skiPass?->id,
|
||||
'courses' => $this->normalizeServiceArray($participant->courses),
|
||||
'board' => $this->normalizeServiceArray($participant->board),
|
||||
'veg' => $participant->veg?->id,
|
||||
'rentals' => $this->normalizeServiceArray($participant->rentals),
|
||||
'rentalInsurance' => $participant->rentalInsurance?->id,
|
||||
'additionalServices' => $this->normalizeServiceArray($participant->additionalServices),
|
||||
|
||||
@@ -209,6 +209,14 @@ class BookingEditDraftMerger
|
||||
$participant->board = $this->resolveServiceArray($data['board'], $travel->additionalServices);
|
||||
}
|
||||
|
||||
// Veg (single service) - merge strategy: only apply if resolves to valid service
|
||||
if (true === array_key_exists('veg', $data) && null !== $data['veg']) {
|
||||
$resolved = $this->resolveService($data['veg'], $travel->additionalServices);
|
||||
if (null !== $resolved) {
|
||||
$participant->veg = $resolved;
|
||||
}
|
||||
}
|
||||
|
||||
// Rentals (array) - overwrite strategy: user can deselect all
|
||||
if (true === array_key_exists('rentals', $data) && true === is_array($data['rentals'])) {
|
||||
$participant->rentals = $this->resolveServiceArray($data['rentals'], $travel->additionalServices);
|
||||
|
||||
@@ -93,6 +93,11 @@ class BookingEditSubmitGuard
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if (false === $this->isSameService($participant->veg, $baseline->veg)) {
|
||||
$participant->veg = $baseline->veg;
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if (false === $this->isSameService($participant->skiPass, $baseline->skiPass)) {
|
||||
$participant->skiPass = $baseline->skiPass;
|
||||
$changed = true;
|
||||
|
||||
Reference in New Issue
Block a user