diff --git a/src/BusProNet/DataProcessor/BookingDataProcessor.php b/src/BusProNet/DataProcessor/BookingDataProcessor.php index adad9106..9eb0bd43 100644 --- a/src/BusProNet/DataProcessor/BookingDataProcessor.php +++ b/src/BusProNet/DataProcessor/BookingDataProcessor.php @@ -153,7 +153,6 @@ class BookingDataProcessor $roomSelection->price = $room->price; $roomSelection->quantity = $bookingRoom->totalCount; // Actual quantity from booking XML (anzahl) $roomSelection->capacity = $room->minPax ?? 1; - $roomSelection->maxQuantity = $bookingRoom->totalCount + ($room->available ?? 0); $dto->roomSelections[] = $roomSelection; } } diff --git a/src/Form/Service/ParticipantAssignedRoomFieldHandler.php b/src/Form/Service/ParticipantAssignedRoomFieldHandler.php index d213b726..6f14d724 100644 --- a/src/Form/Service/ParticipantAssignedRoomFieldHandler.php +++ b/src/Form/Service/ParticipantAssignedRoomFieldHandler.php @@ -76,7 +76,7 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle * 6. Updates the participant's assignedRoomId property * * @param array $submittedData The submitted participant form data - * @param BookingDto $bookingDto The booking DTO to update (create or edit) + * @param BookingDto $bookingDto The booking DTO to update * @param int $participantIndex The index of the participant being processed */ public function processField(array $submittedData, BookingDto $bookingDto, int $participantIndex): void @@ -133,15 +133,8 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle return false; } - // Calculate total capacity for this room type - // In edit mode, use maxQuantity which includes available rooms beyond the booked count. - // In create mode, use quantity which is the user's room selection from step 1. - if (BookingDto::MODE_EDIT === $bookingDto->getMode()) { - $effectiveQuantity = $roomSelection->maxQuantity; - } else { - $effectiveQuantity = $roomSelection->quantity ?? 0; - } - $totalCapacity = $effectiveQuantity * $roomSelection->capacity; + // Calculate total capacity for this room type from the step 1 selection + $totalCapacity = ($roomSelection->quantity ?? 0) * $roomSelection->capacity; // Count current occupancy (excluding current participant) $occupancy = 0; @@ -193,12 +186,7 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle return; // Shouldn't happen } - if (BookingDto::MODE_EDIT === $bookingDto->getMode()) { - $effectiveQuantity = $roomSelection->maxQuantity; - } else { - $effectiveQuantity = $roomSelection->quantity ?? 0; - } - $totalCapacity = $effectiveQuantity * $roomSelection->capacity; + $totalCapacity = ($roomSelection->quantity ?? 0) * $roomSelection->capacity; $currentOccupancy = count($participantsWithRoom); $spacesNeeded = ($currentOccupancy + 1) - $totalCapacity; diff --git a/src/Form/Service/ParticipantFieldOptionsProvider.php b/src/Form/Service/ParticipantFieldOptionsProvider.php index 209557b1..faadc971 100644 --- a/src/Form/Service/ParticipantFieldOptionsProvider.php +++ b/src/Form/Service/ParticipantFieldOptionsProvider.php @@ -8,7 +8,6 @@ use App\BusProNet\Constants; use App\BusProNet\Model\Booking; use App\BusProNet\Model\Insurance; use App\BusProNet\Model\Pickup; -use App\BusProNet\Model\Room; use App\BusProNet\Model\Service; use App\BusProNet\Utility\DirectionMapper; use App\Form\Model\BookingDto; @@ -86,21 +85,18 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider */ protected function registerFieldOptionProviders(): void { - // Room assignment field provider (available for both create and edit workflows) + // Room assignment field provider (create only: edit mode renders the room as static text) // Returns empty array when no room choices available $this->fieldOptionProviders['assignedRoomId'] = function (BookingDto $bookingDto, int $participantIndex, array $options = []): array { $choices = []; if (BookingDto::MODE_CREATE === $bookingDto->getMode()) { - // Create context: use selected rooms from step 1, filtered by participant age + // Use selected rooms from step 1, filtered by participant age $choices = $this->filterRoomsByParticipantAge( $bookingDto->getSelectedRooms(), $bookingDto, $participantIndex ); - } elseif (BookingDto::MODE_EDIT === $bookingDto->getMode()) { - // Edit context: convert booked rooms to RoomSelectionDto for consistent handling - $choices = $this->convertBookedRoomsToSelectionDtos($bookingDto->booking->rooms); } if (true === empty($choices)) { @@ -782,31 +778,6 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider }); } - /** - * Converts booked Room objects to RoomSelectionDto for consistent form handling. - * - * In edit mode, we need to convert Room entities to RoomSelectionDto objects - * so the form can use the same choice_value and choice_label configuration - * as create mode, enabling consistent price display in the template. - * - * @param Room[] $bookedRooms Rooms from existing booking - * - * @return RoomSelectionDto[] Array of room selection DTOs - */ - private function convertBookedRoomsToSelectionDtos(array $bookedRooms): array - { - $selections = []; - foreach ($bookedRooms as $room) { - $selection = new RoomSelectionDto(); - $selection->id = $room->id; - $selection->label = $room->label; - $selection->price = $room->price; - $selections[] = $selection; - } - - return $selections; - } - /** * Filters rental services by selected skipass duration. *