feat: on-request days appear as partly occupied in the iCal feed

The feed now has the three levels of the sidebar calendar: BLOCKED runs
stay "Unavailable", ON_REQUEST runs (partly available) become
"Part-occupied:N", the format the portals read until June 2026, and OK
days get no event. Since June 2026 on-request days were sent as
"Unavailable".

TYPO3 10 took N from the booked beds of the XML import, which no longer
exists. N is now half of the hotel's beds ("Anzahl Betten"), at least 1,
so the beds of the group houses have to be maintained.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-11-05 14:52:59 +01:00
1 parent 3e36136bfa
commit e6d1009b52
1 file changed
+11 -7
@@ -10,18 +10,21 @@ use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
/**
* Contingent feed of a hotel for the booking portals, with the events of TYPO3 10
* Contingent feed of a hotel for the booking portals
*
* The availability comes from MyE&P (contingents/availability, the bpn-connect snapshot without the
* price rule of contingents/calendar); TYPO3 10 read it from bpn-connect directly. Every run of
* BLOCKED or ON_REQUEST days with one status becomes one "Unavailable" event, as bpn-connect's
* ranges did.
* price rule of contingents/calendar). Like the sidebar calendar, it has three levels: every run of
* BLOCKED days becomes an "Unavailable" event, every run of ON_REQUEST days (partly available) a
* "Part-occupied:N" event, the format of TYPO3 10 until June 2026; OK days get no event. TYPO3 10
* took N from the booked beds of the XML import, which no longer exists, so N stands in for it:
* half of the hotel's beds, at least 1.
*/
class IcalService implements LoggerAwareInterface
{
use LoggerAwareTrait;
private const string SUMMARY_UNAVAILABLE = 'Unavailable';
private const string SUMMARY_PART_OCCUPIED = 'Part-occupied:%d';
public function __construct(
private readonly ApiClient $apiClient,
@@ -48,19 +51,20 @@ class IcalService implements LoggerAwareInterface
$vcalendar = Vcalendar::factory([Vcalendar::UNIQUE_ID => 'www.ep-reisen.de']);
$vcalendar->setXprop(Vcalendar::X_WR_TIMEZONE, 'Europe/Berlin');
$partOccupiedSummary = sprintf(self::SUMMARY_PART_OCCUPIED, max(1, intdiv((int)$hotel->getBedsCount(), 2)));
foreach ($this->buildRanges($calendarRows) as $range) {
$vcalendar
->newVevent()
->setDtstart($range['from'])
->setDtend($range['to']->modify('+1 day'))
->setSummary(self::SUMMARY_UNAVAILABLE);
->setSummary('ON_REQUEST' === $range['status'] ? $partOccupiedSummary : self::SUMMARY_UNAVAILABLE);
}
return $vcalendar->vtimezonePopulate()->createCalendar();
}
/**
* @return array<int, array{from: \DateTimeImmutable, to: \DateTimeImmutable}> unavailable runs, both ends inclusive
* @return array<int, array{from: \DateTimeImmutable, to: \DateTimeImmutable, status: string}> BLOCKED / ON_REQUEST runs, both ends inclusive
*/
private function buildRanges(array $calendarRows): array
{
@@ -96,7 +100,7 @@ class IcalService implements LoggerAwareInterface
$ranges[] = $current;
}
return array_map(fn (array $range): array => ['from' => $range['from'], 'to' => $range['to']], $ranges);
return $ranges;
}
private function normalizeStatus(string $status): string