diff --git a/src/BusProNet/Model/Travel.php b/src/BusProNet/Model/Travel.php index a3e6a9dd..a2695f3e 100644 --- a/src/BusProNet/Model/Travel.php +++ b/src/BusProNet/Model/Travel.php @@ -278,10 +278,10 @@ class Travel } /** - * Retrieves all bookable rooms (both regular and inquiry). + * Retrieves all bookable rooms. * - * Returns rooms that have availability greater than zero and a bookable status - * (either 'Frei' for regular booking or 'Anfrage' for inquiry booking). + * Returns rooms with status 'Frei' and availability greater than zero. Rooms on request + * ('Anfrage') are not offered: they would turn the booking into an inquiry. * * @return array The filtered array of bookable rooms, indexed by room ID */ @@ -289,7 +289,7 @@ class Travel { $result = []; foreach ($this->rooms as $room) { - if ($room->available > 0 && $this->isBookableRoomStatus($room->status)) { + if ($room->available > 0 && Constants::STATUS_AVAILABLE === $room->status) { $result[$room->id] = $room; } } @@ -307,40 +307,6 @@ class Travel return [] !== $this->getAvailableRooms(); } - /** - * Checks if all bookable rooms require inquiry booking. - * - * Returns true if there are bookable rooms but none with 'Frei' status. - * This indicates the booking must be submitted as an inquiry. - * - * @return bool True if only inquiry rooms are available - */ - public function requiresInquiryBooking(): bool - { - $bookableRooms = $this->getAvailableRooms(); - - if ([] === $bookableRooms) { - return false; - } - - foreach ($bookableRooms as $room) { - if (Constants::STATUS_AVAILABLE === $room->status) { - return false; - } - } - - return true; - } - - /** - * Checks if a room status allows booking. - */ - private function isBookableRoomStatus(?string $status): bool - { - return Constants::STATUS_AVAILABLE === $status - || Constants::STATUS_ON_REQUEST === $status; - } - /** * Retrieves a room by its ID. * diff --git a/src/Controller/Booking/Create/Step1Controller.php b/src/Controller/Booking/Create/Step1Controller.php index 939cd227..ca14f8ba 100644 --- a/src/Controller/Booking/Create/Step1Controller.php +++ b/src/Controller/Booking/Create/Step1Controller.php @@ -66,7 +66,6 @@ class Step1Controller extends AbstractBookingCreateController $bookingCreateDto->resetParticipantAssignments(); } - // Check if room selection forces inquiry mode $this->bookingService->updateBookingStatusFromRoomSelection($bookingCreateDto); $bookingCreateDto->currentStep = 2; diff --git a/src/Form/RoomSelectType.php b/src/Form/RoomSelectType.php index ac1df7eb..d4ac1c64 100644 --- a/src/Form/RoomSelectType.php +++ b/src/Form/RoomSelectType.php @@ -2,7 +2,6 @@ namespace App\Form; -use App\BusProNet\Constants; use App\Form\Model\RoomSelectionDto; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -45,7 +44,6 @@ class RoomSelectType extends AbstractType $view->vars['label_room'] = $data->label; $view->vars['label_price_amount'] = null; - $view->vars['is_inquiry'] = Constants::STATUS_ON_REQUEST === $data->status; if (null !== $data->price) { $view->vars['label_price_amount'] = (float) $data->price; diff --git a/src/Service/BookingConfigurator.php b/src/Service/BookingConfigurator.php index 0c04a869..f7fc7eff 100644 --- a/src/Service/BookingConfigurator.php +++ b/src/Service/BookingConfigurator.php @@ -611,10 +611,6 @@ class BookingConfigurator /** * Determines the initial booking status based on travel configuration and API restrictions. * - * This method implements a multi-stage check to determine the appropriate booking status: - * 1. Checks API restrictions via buchungstatusmoeglich attribute - * 2. Checks if only inquiry rooms are available (no Frei rooms with available > 0) - * * When API provides allowed status restrictions, the method respects them by selecting * the best available status in order of preference: configured default → 'F' → 'O' → 'A'. * @@ -627,13 +623,7 @@ class BookingConfigurator */ private function determineInitialBookingStatus(Travel $travelData): string { - // Check 1: Only inquiry rooms available (all rooms with available > 0 have status 'Anfrage') - // This takes precedence as it's a business rule independent of API restrictions - if ($travelData->requiresInquiryBooking()) { - return Constants::BOOKING_STATUS_INQUIRY; - } - - // Check 2: If API provided allowed status restrictions, respect them + // If API provided allowed status restrictions, respect them if ([] !== $travelData->allowedBookingStatus) { // Prefer configured default status if allowed if ($travelData->isBookingStatusAllowed($this->defaultBookingStatus)) { @@ -658,24 +648,16 @@ class BookingConfigurator } /** - * Updates booking status based on selected room requirements. + * Resets the booking status after the room selection in Step 1. * - * If ANY selected room is only bookable on request, the whole booking becomes an inquiry. - * Otherwise the status returns to what the travel called for when the booking started, - * and the create-flow rules run again, so a customer who swaps an on-request room for a - * free one in Step 1 is no longer submitted as an inquiry. An 'A' from the Step 3 BusPro - * fallback is cleared the same way; Step 3 validates again and re-applies it if needed. + * The status returns to what the travel called for when the booking started, and the + * create-flow rules run again. An 'A' from the Step 3 BusPro fallback is cleared this way; + * Step 3 validates again with the new rooms and re-applies it if needed. * * @param BookingDto $bookingDto The booking DTO to update */ public function updateBookingStatusFromRoomSelection(BookingDto $bookingDto): void { - if (true === $this->hasOnRequestRoomSelected($bookingDto)) { - $bookingDto->bookingStatus = Constants::BOOKING_STATUS_INQUIRY; - - return; - } - // Sessions started before the initial status was recorded keep their current status if (null === $bookingDto->initialBookingStatus) { return; @@ -685,20 +667,6 @@ class BookingConfigurator $this->applyCreateBookingStatusRules($bookingDto); } - private function hasOnRequestRoomSelected(BookingDto $bookingDto): bool - { - foreach ($bookingDto->getSelectedRooms() as $roomSelection) { - $room = $bookingDto->travel->getRoomById($roomSelection->id); - if (null !== $room - && Constants::STATUS_ON_REQUEST === $room->status - && $room->available > 0) { - return true; - } - } - - return false; - } - /** * Applies booking-level status rules in create flow. * diff --git a/templates/booking/create/step_1.html.twig b/templates/booking/create/step_1.html.twig index 5a6be8a4..9cc49e43 100644 --- a/templates/booking/create/step_1.html.twig +++ b/templates/booking/create/step_1.html.twig @@ -6,7 +6,7 @@
- {{ form.vars.label_room }} {% if form.vars.is_inquiry %}(nur auf Anfrage){% endif %} + {{ form.vars.label_room }}
{% if form.vars.label_price_amount is defined and form.vars.label_price_amount is not null %} diff --git a/tests/Service/BookingConfiguratorStatusTest.php b/tests/Service/BookingConfiguratorStatusTest.php index 5f9b84c2..7c8e2cf7 100644 --- a/tests/Service/BookingConfiguratorStatusTest.php +++ b/tests/Service/BookingConfiguratorStatusTest.php @@ -84,7 +84,7 @@ class BookingConfiguratorStatusTest extends TestCase $this->bookingService->startFreshBooking($request, 123, 456); } - public function testStartFreshBookingWithAnfrageRooms(): void + public function testStartFreshBookingWithAnfrageRoomsThrowsException(): void { $travel = $this->createTravelWithRooms([ ['status' => Constants::STATUS_ON_REQUEST, 'available' => 5], @@ -96,10 +96,9 @@ class BookingConfiguratorStatusTest extends TestCase $request = $this->createRequestWithSession(); - $bookingDto = $this->bookingService->startFreshBooking($request, 123, 456); + $this->expectException(NoRoomsAvailableException::class); - $this->assertSame('A', $bookingDto->bookingStatus); - $this->assertCount(1, $bookingDto->roomSelections); + $this->bookingService->startFreshBooking($request, 123, 456); } public function testStartFreshBookingWithAnfrageRoomsAndNoAvailabilityThrowsException(): void @@ -119,9 +118,8 @@ class BookingConfiguratorStatusTest extends TestCase $this->bookingService->startFreshBooking($request, 123, 456); } - public function testStartFreshBookingWithMixedRoomsUsesFreeStatus(): void + public function testStartFreshBookingWithMixedRoomsOffersOnlyFreeRooms(): void { - // When both Frei and Anfrage rooms with availability exist, booking status should be 'F' $travel = $this->createTravelWithRooms([ ['status' => Constants::STATUS_AVAILABLE, 'available' => 5], ['status' => Constants::STATUS_ON_REQUEST, 'available' => 3], @@ -136,7 +134,7 @@ class BookingConfiguratorStatusTest extends TestCase $bookingDto = $this->bookingService->startFreshBooking($request, 123, 456); $this->assertSame('F', $bookingDto->bookingStatus); - $this->assertCount(2, $bookingDto->roomSelections); + $this->assertSame([1], array_keys($bookingDto->roomSelections)); } public function testStartFreshBookingWithNoBookableRoomsThrowsException(): void @@ -208,42 +206,11 @@ class BookingConfiguratorStatusTest extends TestCase $this->assertSame('O', $bookingDto->bookingStatus); } - public function testStartFreshBookingWithInquiryRoomsAndSelection1473KeepsInquiryStatus(): void - { - $travel = $this->createTravelWithRooms( - [ - ['status' => Constants::STATUS_ON_REQUEST, 'available' => 5], - ], - [$this->createSelectionGroupWithSelectionId(1473)] - ); - - $this->travelDataService - ->method('getTravelData') - ->willReturn($travel); - - $request = $this->createRequestWithSession(); - - $bookingDto = $this->bookingService->startFreshBooking($request, 123, 456); - - $this->assertSame('A', $bookingDto->bookingStatus); - } - - public function testRoomSelectionSwitchesToInquiryForOnRequestRoom(): void + public function testRoomSelectionClearsInquiryFromStep3Fallback(): void { $bookingDto = $this->startMixedRoomsBooking(); + $bookingDto->bookingStatus = 'A'; - $this->selectRoom($bookingDto, 2); - $this->bookingService->updateBookingStatusFromRoomSelection($bookingDto); - - $this->assertSame('A', $bookingDto->bookingStatus); - } - - public function testRoomSelectionRevertsInquiryWhenOnRequestRoomIsDeselected(): void - { - $bookingDto = $this->startMixedRoomsBooking(); - - $this->selectRoom($bookingDto, 2); - $this->bookingService->updateBookingStatusFromRoomSelection($bookingDto); $this->selectRoom($bookingDto, 1); $this->bookingService->updateBookingStatusFromRoomSelection($bookingDto);