feat: force booking status 'O' for selection id 1473
addresses #869d79q0r
This commit is contained in:
@@ -57,7 +57,7 @@ final class Constants
|
||||
// Booking status codes from buchungstatusmoeglich attribute
|
||||
public const BOOKING_STATUS_FREE = 'F';
|
||||
public const BOOKING_STATUS_INQUIRY = 'A';
|
||||
public const BOOKING_STATUS_OPEN = 'O'; // Optionsbuchung
|
||||
public const BOOKING_STATUS_OPTION = 'O'; // Optionsbuchung
|
||||
|
||||
// Payment methods
|
||||
public const PAYMENT_METHOD_TRANSFER = 'transfer';
|
||||
|
||||
@@ -218,6 +218,28 @@ class Travel
|
||||
return $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether any CRM selection group contains the given selection ID.
|
||||
*
|
||||
* This scans all parsed groups and their selections, regardless of group.
|
||||
*/
|
||||
public function hasSelectionId(int $selectionId): bool
|
||||
{
|
||||
foreach ($this->selectionGroups as $selectionGroup) {
|
||||
if (null === $selectionGroup->selections) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($selectionGroup->selections as $selection) {
|
||||
if ($selectionId === $selection->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves rooms filtered by their IDs.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Service\StatusRule;
|
||||
|
||||
use App\BusProNet\Service\Contract\BookingStatusRuleInterface;
|
||||
use App\Form\Model\BookingDto;
|
||||
|
||||
/**
|
||||
* Status rule for travels containing selection 1473.
|
||||
*
|
||||
* Forces Option status when the travel contains the CRM selection
|
||||
* "NICHT-automatisch bestätigen".
|
||||
*/
|
||||
class Selection1473StatusRule implements BookingStatusRuleInterface
|
||||
{
|
||||
private const STATUS = 'O';
|
||||
private const PRIORITY = 200;
|
||||
private const SELECTION_ID = 1473;
|
||||
|
||||
public function evaluate(BookingDto $bookingDto): bool
|
||||
{
|
||||
return $bookingDto->travel->hasSelectionId(self::SELECTION_ID);
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return self::STATUS;
|
||||
}
|
||||
|
||||
public function getPriority(): int
|
||||
{
|
||||
return self::PRIORITY;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Assigns Option status when selection 1473 is present';
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ class BookingConfigurator
|
||||
*
|
||||
* Handles three booking status types:
|
||||
* - 'Frei': Regular booking with availability checks
|
||||
* - 'Option': Create-flow override from specific rules
|
||||
* - 'Anfrage': Inquiry booking, allows booking even with 0 availability
|
||||
*/
|
||||
public function startFreshBooking(Request $request, int $dateId, int $hotelId, ?int $agencyId = null): BookingDto
|
||||
@@ -83,6 +84,7 @@ class BookingConfigurator
|
||||
? $this->agencyLoader->loadById($agencyId)?->code
|
||||
: null;
|
||||
$bookingCreateDto->bookingStatus = $bookingStatus;
|
||||
$this->applyCreateBookingStatusRules($bookingCreateDto);
|
||||
|
||||
$this->bookingSessionService->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
|
||||
|
||||
@@ -587,13 +589,13 @@ class BookingConfigurator
|
||||
return $this->defaultBookingStatus;
|
||||
}
|
||||
|
||||
// Fall back to allowed statuses in order of preference: F → O → A
|
||||
// Fall back to allowed statuses in order of preference: F → O(option) → 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_OPTION)) {
|
||||
return Constants::BOOKING_STATUS_OPTION;
|
||||
}
|
||||
|
||||
if ($travelData->isBookingStatusAllowed(Constants::BOOKING_STATUS_INQUIRY)) {
|
||||
|
||||
Reference in New Issue
Block a user