feat: special treatment of services for participants of age 0-2

This commit is contained in:
Björn Fromme
2025-12-08 15:26:30 +01:00
parent 118f86b2a0
commit 6dbbfd87f8
7 changed files with 635 additions and 18 deletions
@@ -754,12 +754,26 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
return [];
}
return array_filter($services, function (Service $service) use ($bookingDto, $participantIndex, $ageEvaluator) {
// No age constraints = available to all
if (false === $ageEvaluator->canEvaluate($service)) {
// Check if participant is a baby
$age = $participant->getAge($bookingDto->travel->dateFrom);
$isBaby = null !== $age && $age <= Constants::BABY_MAX_AGE;
return array_filter($services, function (Service $service) use ($bookingDto, $participantIndex, $ageEvaluator, $isBaby) {
// Check if service has age constraints
$hasAgeConstraints = $ageEvaluator->canEvaluate($service);
// For babies: ONLY show services with explicit age ranges that include them
// Services without age restrictions are hidden for babies
if ($isBaby && false === $hasAgeConstraints) {
return false;
}
// No age constraints and not a baby = available to all
if (false === $hasAgeConstraints) {
return true;
}
// Has age constraints = check if participant's age is within range
return $ageEvaluator->isServiceAvailableForParticipant($service, $bookingDto, $participantIndex);
});
}
@@ -887,8 +901,15 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
// If we have both discounted and regular options, apply smart filtering
if (null !== $discountedPkw && null !== $regularPkw) {
// Get participant to check inbound transportation
$participant = $bookingDto->getParticipant($participantIndex);
// Baby participants always get regular PKW (no discounts)
$age = $participant?->getAge($bookingDto->travel->dateFrom);
if (null !== $age && $age <= Constants::BABY_MAX_AGE) {
return [...$otherServices, $regularPkw];
}
// Check if inbound is BUS
$inboundIsBus = null !== $participant?->transportationInbound
&& DirectionMapper::SUBTYPE_BUS_API === $participant->transportationInbound->subType;
+6
View File
@@ -442,6 +442,12 @@ class BookingService
continue; // Skip participants without age information
}
// Skip babies - they only get services with explicit age ranges (handled by field filtering)
$age = $participant->getAge($bookingDto->travel->dateFrom);
if (null !== $age && $age <= Constants::BABY_MAX_AGE) {
continue;
}
// Skip ineligible participants (no skipasses available for their age)
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
continue;