fix: stop offering unbookable services in the booking edit flow

This commit is contained in:
fromme committed 2026-09-16 15:28:07 +02:00
1 parent 672fc30d7e
commit 160ebef39e
18 files changed
+1094 -104

No files matched your search

+16 -5
View File
@@ -281,9 +281,9 @@ class TravelLoader extends AbstractLoader
/**
* Apply availability data to travel services.
*
* Updates the availability status of additional and transportation
* services, and the allowed booking status, based on the provided
* availability data.
* Updates the remaining contingent and the live status of additional and
* transportation services, and the allowed booking status, based on the
* provided availability data.
*
* @param Travel $travel The travel object to update
* @param ServiceAvailabilityResponse $availabilities The availability data for services
@@ -293,8 +293,19 @@ class TravelLoader extends AbstractLoader
$serviceAvailabilities = $availabilities->getServices();
foreach ([...$travel->additionalServices, ...$travel->transportationServices] as $service) {
if (array_key_exists($service->id, $serviceAvailabilities)) {
$service->available = $serviceAvailabilities[$service->id]->available;
if (false === array_key_exists($service->id, $serviceAvailabilities)) {
continue;
}
$availability = $serviceAvailabilities[$service->id];
$service->available = $availability->available;
// The live status is the only signal that a contingent has run out: BusPro moves a
// Leistung to 'Anfrage' without necessarily reporting frei="0". Only overwrite when the
// response actually carries one, so a response that omits the attribute does not wipe
// the value parsed from the XML export. Mirrors TravelSnapshotManager::applyExtendedToService().
if (null !== $availability->status && '' !== trim($availability->status)) {
$service->status = $availability->status;
}
}