fix: preserve selected services from booking even when unavailable
When editing a booking, services that were previously booked but are no
longer available in the travel catalog were being dropped. This caused
API error 650 ("Anzahl Leistung stimmt nicht mit Teilnehmerzuordnung
überein") because the service participant counts no longer matched.
The fix ensures that in edit mode, booked services are merged with
travel data services in both:
- Form rendering (ParticipantFieldOptionsProvider): so checkboxes appear
- Handler validation (AbstractParticipantFieldHandler): so selections
are accepted
This allows users to keep their existing service selections or
deliberately replace them with other available options. Create mode
remains unchanged.
This commit is contained in:
@@ -73,7 +73,7 @@ class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
||||
|
||||
// Store parking service object for pricing calculation
|
||||
if (true === $isParkingSelected) {
|
||||
$participant->parkingService = $this->findParkingService($bookingDto);
|
||||
$participant->parkingService = $this->findParkingService($bookingDto, $participantIndex);
|
||||
} else {
|
||||
$participant->parkingService = null;
|
||||
}
|
||||
@@ -112,13 +112,19 @@ class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
||||
* Gets the first (and typically only) parking service for pricing calculation.
|
||||
* Returns null if no parking services are available.
|
||||
*
|
||||
* @param BookingDto $bookingDto The booking DTO containing travel data
|
||||
* @param BookingDto $bookingDto The booking DTO containing travel data
|
||||
* @param int $participantIndex The participant index for booked services lookup
|
||||
*
|
||||
* @return Service|null The parking service object, or null if not found
|
||||
*/
|
||||
private function findParkingService(BookingDto $bookingDto): ?Service
|
||||
private function findParkingService(BookingDto $bookingDto, int $participantIndex): ?Service
|
||||
{
|
||||
$parkingServices = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_PARKING);
|
||||
// Get available parking services (includes booked parking in edit mode)
|
||||
$parkingServices = $this->getAvailableServicesWithBooked(
|
||||
$bookingDto,
|
||||
$participantIndex,
|
||||
Constants::TOKEN_PARKING
|
||||
);
|
||||
|
||||
if (empty($parkingServices)) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user