fix: treat dates without price as unavailable

This commit is contained in:
Björn Fromme
2026-08-04 11:29:58 +02:00
parent 331c88c38e
commit 8ff13614d2
8 changed files with 407 additions and 23 deletions
+14
View File
@@ -10,6 +10,7 @@ use App\BpnConnect\Model\ContingentStatus;
use App\Entity\Groups\Accommodation;
use App\Model\CalendarDay;
use App\Model\CalendarMonth;
use App\Service\AccommodationPriceCoverage;
use Carbon\CarbonImmutable;
use Psr\Cache\InvalidArgumentException;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
@@ -45,6 +46,7 @@ class Calendar
public function __construct(
private readonly ContingentsClient $contingentsClient,
private readonly CacheInterface $cache,
private readonly AccommodationPriceCoverage $priceCoverage,
) {
}
@@ -119,6 +121,18 @@ class Calendar
}
}
// A day without a price is not sold, no matter what the contingent says.
$rangeStart = new \DateTimeImmutable($dateFrom);
$rangeEnd = new \DateTimeImmutable($dateTo);
$covered = $this->priceCoverage->coveredDates($hotelCode, $rangeStart, $rangeEnd);
for ($day = $rangeStart->setTime(0, 0); $day <= $rangeEnd->setTime(0, 0); $day = $day->modify('+1 day')) {
$key = $day->format('Y-m-d');
if (!isset($covered[$key])) {
$blocked[$key] = true;
}
}
return $blocked;
}