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

+25
View File
@@ -143,6 +143,31 @@ class Booking
});
}
/**
* Checks whether a participant already holds a service in this booking.
*
* This is the BusPro-side baseline, not the working edit selection: it answers
* "did the participant have this service when the booking was last read back".
* Services already held may be kept regardless of their current status or
* contingent - withdrawing one produces "Anzahl Leistung stimmt nicht mit
* Teilnehmerzuordnung überein" on the next update.
*
* @param int $participantIndex The participant index to search for
* @param int $serviceId The service ID to look for
*
* @return bool True if the participant already holds the service
*/
public function hasServiceForParticipant(int $participantIndex, int $serviceId): bool
{
foreach ([...$this->additionalServices, ...$this->transportationServices] as $service) {
if ($service->id === $serviceId && in_array($participantIndex, $service->mapping)) {
return true;
}
}
return false;
}
/**
* Retrieves transportation service for a specific participant and direction.
*