feat: offer rooms on request by Anf code suffix
This commit is contained in:
1 parent
2936d8947a
commit
0b0286787b
11 files changed
+204
-41
No files matched your search
@@ -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'])]
|
||||
|
||||
Reference in new issue
Block a user