fix: pass BusPro room assignments through on edit

This commit is contained in:
fromme committed 2026-11-09 18:00:47 +01:00
1 parent 897a1ac7f9
commit d50995a21c
7 files changed
+163 -45

No files matched your search

@@ -341,6 +341,7 @@ class BookingDataProcessor
$this->serviceProcessor->processParticipantServices($participant, $bookingData, $travelData);
}
$this->serviceProcessor->removeCanceledParticipantsFromRooms($bookingData);
$this->serviceProcessor->removeUnusedServices($bookingData);
$this->personalDataSynchronizer->updateParticipantPersonalData(
$formData->participants,
@@ -14,8 +14,9 @@ use Psr\Log\LoggerInterface;
* Processes participant service selections for booking updates.
*
* Handles the assignment and mapping of services (additional, transportation,
* pickup, room, insurance) from participant DTOs to the booking model during
* the update request workflow.
* pickup, insurance) from participant DTOs to the booking model during the
* update request workflow. Rooms are not taken from the DTOs: they cannot be
* changed in edit mode, so the booking's own room assignments are sent back.
*/
class ParticipantServiceProcessor
{
@@ -28,7 +29,7 @@ class ParticipantServiceProcessor
* Resets all existing participant-to-service mappings to start with a clean slate.
*
* This ensures that service assignments are rebuilt from scratch based on current form selections.
* Includes resetting room mappings to allow room reassignments during edit.
* Room mappings are left alone, see removeCanceledParticipantsFromRooms().
*
* @param Booking $bookingData The booking data object containing services to reset
*/
@@ -39,7 +40,6 @@ class ParticipantServiceProcessor
...$bookingData->transportationServices,
...$bookingData->pickups,
...$bookingData->dropOffs,
...$bookingData->rooms,
...$bookingData->insurances,
];
@@ -52,7 +52,7 @@ class ParticipantServiceProcessor
* Processes all services for a single participant.
*
* This orchestrator method handles the complete service assignment workflow for one participant,
* including additional services, transportation services, pickup locations, and room assignments.
* including additional services, transportation services, pickup locations, and insurance.
*
* @param ParticipantDto $participant The participant data from the form
* @param Booking $bookingData The booking data object to update
@@ -68,7 +68,6 @@ class ParticipantServiceProcessor
$this->processTransportationServices($participant, $bookingData, $travelData);
$this->processPickupLocations($participant, $bookingData);
$this->processDropOffLocations($participant, $bookingData);
$this->processRoomAssignment($participant, $bookingData);
$this->processInsurance($participant, $bookingData, $travelData);
}
@@ -271,27 +270,23 @@ class ParticipantServiceProcessor
}
/**
* Processes room assignment for a participant.
* Removes canceled participants from the booking's room assignments.
*
* Maps the participant to their assigned room. Allows room reassignment during
* booking edits while maintaining the constraint that participants can only be
* assigned to room types that have already been booked.
* Room assignments cannot be changed in edit mode, so they are sent back as BusPro reports
* them on the booking reloaded at submit, together with its anzahl. Rebuilding them from the
* session would undo any reassignment made in BusPro while the edit was open, and send a
* zuordnung that no longer matches anzahl. Canceled participants are left out, as for every
* other service.
*
* @param ParticipantDto $participant The participant data from the form
* @param Booking $bookingData The booking data object to update
* @param Booking $bookingData The booking data object to update
*/
private function processRoomAssignment(ParticipantDto $participant, Booking $bookingData): void
public function removeCanceledParticipantsFromRooms(Booking $bookingData): void
{
if (null === $participant->assignedRoomId) {
return;
}
// Find the room in the existing booking by ID
foreach ($bookingData->rooms as $room) {
if ($room->id === $participant->assignedRoomId) {
$room->mapping[] = $participant->index;
break;
}
$room->mapping = array_values(array_filter(
$room->mapping,
fn (int $index) => 'S' !== ($bookingData->participantsStatus[$index] ?? null)
));
}
}