feat: offer rooms on request by Anf code suffix

This commit is contained in:
fromme committed 2026-11-11 11:35:38 +01:00
1 parent 2936d8947a
commit 0b0286787b
11 files changed
+204 -41

No files matched your search

+26 -7
View File
@@ -22,15 +22,34 @@ class Room
public const SELECTION_TYPE_BY_ROOM = 'by_room';
/**
* Whether a room with this status and availability is offered for new bookings.
*
* Only 'Frei' rooms with rooms left. A room on request ('Anfrage') would turn the booking
* into an inquiry, so it is treated as sold out. Static and taking the raw values so the
* product export and the chatbot, which hold rooms as arrays, apply the same rule.
* Room code suffix by which the office marks a room as deliberately sold on request.
*/
public static function isBookableState(?string $status, ?int $available): bool
public const ON_REQUEST_CODE_SUFFIX = 'Anf';
/**
* Whether a room with this status, availability and code is offered for new bookings.
*
* 'Frei' rooms with rooms left. A room on request ('Anfrage') would turn the booking into
* an inquiry, so it is treated as sold out, unless isOnRequestByCode() says the office
* sells it that way on purpose. Static and taking the raw values so the product export
* and the chatbot, which hold rooms as arrays, apply the same rule.
*/
public static function isBookableState(?string $status, ?int $available, ?string $code): bool
{
return Constants::STATUS_AVAILABLE === $status && ($available ?? 0) > 0;
if (($available ?? 0) <= 0) {
return false;
}
return Constants::STATUS_AVAILABLE === $status
|| (Constants::STATUS_ON_REQUEST === $status && self::isOnRequestByCode($code));
}
/**
* Whether the room code carries the on-request suffix (case-sensitive, e.g. `6erSDAnf`).
*/
public static function isOnRequestByCode(?string $code): bool
{
return null !== $code && str_ends_with($code, self::ON_REQUEST_CODE_SUFFIX);
}
#[Groups(['api:list', 'api:single', 'snapshot'])]
+3 -2
View File
@@ -279,7 +279,8 @@ class Travel
/**
* Retrieves all bookable rooms.
*
* Returns the rooms Room::isBookableState() accepts: status 'Frei' with rooms left.
* Returns the rooms Room::isBookableState() accepts: status 'Frei' with rooms left, or rooms
* the office sells on request on purpose, which turn the booking into an inquiry.
*
* @return array<int, Room> The filtered array of bookable rooms, indexed by room ID
*/
@@ -287,7 +288,7 @@ class Travel
{
$result = [];
foreach ($this->rooms as $room) {
if (Room::isBookableState($room->status, $room->available)) {
if (Room::isBookableState($room->status, $room->available, $room->code)) {
$result[$room->id] = $room;
}
}
@@ -92,7 +92,7 @@ class ProductExportParser extends AbstractParser
'price' => $this->stringToFloat($this->getAttrOrNullValue($room, 'preis')),
'available' => $available,
'status' => $status,
'bookable' => Room::isBookableState($status, $available),
'bookable' => Room::isBookableState($status, $available, $code),
'boardCode' => $this->getAttrOrNullValue($room, 'vpcode'),
'boardBusProId' => $this->getIntAttrOrNullValue($room, 'idbuspro_vp'),
];