fix: consider booking status O correctly
This commit is contained in:
@@ -57,7 +57,7 @@ final class Constants
|
|||||||
// Booking status codes from buchungstatusmoeglich attribute
|
// Booking status codes from buchungstatusmoeglich attribute
|
||||||
public const BOOKING_STATUS_FREE = 'F';
|
public const BOOKING_STATUS_FREE = 'F';
|
||||||
public const BOOKING_STATUS_INQUIRY = 'A';
|
public const BOOKING_STATUS_INQUIRY = 'A';
|
||||||
public const BOOKING_STATUS_OPEN = 'O'; // Optionsbuchung - not relevant for current implementation
|
public const BOOKING_STATUS_OPEN = 'O'; // Optionsbuchung
|
||||||
|
|
||||||
// Payment methods
|
// Payment methods
|
||||||
public const PAYMENT_METHOD_TRANSFER = 'transfer';
|
public const PAYMENT_METHOD_TRANSFER = 'transfer';
|
||||||
|
|||||||
@@ -527,32 +527,49 @@ class BookingService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the initial booking status based on travel configuration.
|
* Determines the initial booking status based on travel configuration and API restrictions.
|
||||||
*
|
*
|
||||||
* This method implements a multi-stage check to determine if a booking
|
* This method implements a multi-stage check to determine the appropriate booking status:
|
||||||
* should start as inquiry ('A') or use the configured default status:
|
* 1. Checks API restrictions via buchungstatusmoeglich attribute
|
||||||
* 1. Checks if final bookings are allowed via buchungstatusmoeglich attribute from API
|
|
||||||
* 2. Checks if only inquiry rooms are available (no Frei rooms with available > 0)
|
* 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'.
|
||||||
|
*
|
||||||
* The default status is configured via DEFAULT_BOOKING_STATUS env variable.
|
* The default status is configured via DEFAULT_BOOKING_STATUS env variable.
|
||||||
* Use 'O' (Option) during beta for agency confirmation, 'F' (Final) for production.
|
* Use 'O' (Option) during beta for agency confirmation, 'F' (Final) for production.
|
||||||
*
|
*
|
||||||
* @param Travel $travelData The travel data to evaluate
|
* @param Travel $travelData The travel data to evaluate
|
||||||
*
|
*
|
||||||
* @return string 'A' for inquiry booking, or the configured default status
|
* @return string The appropriate booking status code ('F', 'O', or 'A')
|
||||||
*/
|
*/
|
||||||
private function determineInitialBookingStatus(Travel $travelData): string
|
private function determineInitialBookingStatus(Travel $travelData): string
|
||||||
{
|
{
|
||||||
// Check 1: Allowed booking status from buchungstatusmoeglich attribute (from availability API)
|
// Check 1: Only inquiry rooms available (all rooms with available > 0 have status 'Anfrage')
|
||||||
// Only applies if the API provided status restrictions
|
// This takes precedence as it's a business rule independent of API restrictions
|
||||||
if ([] !== $travelData->allowedBookingStatus
|
if ($travelData->requiresInquiryBooking()) {
|
||||||
&& false === $travelData->isBookingStatusAllowed(Constants::BOOKING_STATUS_FREE)) {
|
return Constants::BOOKING_STATUS_INQUIRY;
|
||||||
return 'A';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check 2: Only inquiry rooms available (all rooms with available > 0 have status 'Anfrage')
|
// Check 2: If API provided allowed status restrictions, respect them
|
||||||
if ($travelData->requiresInquiryBooking()) {
|
if ([] !== $travelData->allowedBookingStatus) {
|
||||||
return 'A';
|
// Prefer configured default status if allowed
|
||||||
|
if ($travelData->isBookingStatusAllowed($this->defaultBookingStatus)) {
|
||||||
|
return $this->defaultBookingStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to allowed statuses in order of preference: F → O → A
|
||||||
|
if ($travelData->isBookingStatusAllowed(Constants::BOOKING_STATUS_FREE)) {
|
||||||
|
return Constants::BOOKING_STATUS_FREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($travelData->isBookingStatusAllowed(Constants::BOOKING_STATUS_OPEN)) {
|
||||||
|
return Constants::BOOKING_STATUS_OPEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($travelData->isBookingStatusAllowed(Constants::BOOKING_STATUS_INQUIRY)) {
|
||||||
|
return Constants::BOOKING_STATUS_INQUIRY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->defaultBookingStatus;
|
return $this->defaultBookingStatus;
|
||||||
|
|||||||
Reference in New Issue
Block a user