feat: offer only free rooms in booking step 1
This commit is contained in:
1 parent
980e378a7b
commit
2b27b9809d
6 files changed
+17
-119
No files matched your search
@@ -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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user