feat: special treatment of participants with age 0-2 (babies)
This commit is contained in:
@@ -31,12 +31,15 @@ class ParticipantEligibilityService
|
||||
* Returns true when the participant can book services (at least one skipass available).
|
||||
* Returns false when the participant cannot book (no skipasses available for their age).
|
||||
*
|
||||
* Baby age exemption: Participants aged 0-2 years (at travel date) are always eligible
|
||||
* regardless of skipass availability, as babies don't require ski passes.
|
||||
*
|
||||
* Results are cached per request to avoid redundant calculations.
|
||||
*
|
||||
* @param BookingDto $bookingDto The current booking data
|
||||
* @param int $participantIndex The index of the participant being evaluated
|
||||
*
|
||||
* @return bool True if participant is eligible (has available skipasses)
|
||||
* @return bool True if participant is eligible (has available skipasses or is baby age)
|
||||
*/
|
||||
public function isParticipantEligible(BookingDto $bookingDto, int $participantIndex): bool
|
||||
{
|
||||
@@ -54,7 +57,13 @@ class ParticipantEligibilityService
|
||||
$participantIndex
|
||||
);
|
||||
|
||||
return $this->eligibilityCache[$cacheKey] ??= (function () use ($bookingDto, $participantIndex) {
|
||||
return $this->eligibilityCache[$cacheKey] ??= (function () use ($bookingDto, $participantIndex, $participant) {
|
||||
// Baby age exemption: participants at or under BABY_MAX_AGE are always eligible
|
||||
$age = $participant->getAge($bookingDto->travel->dateFrom);
|
||||
if (null !== $age && $age <= Constants::BABY_MAX_AGE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$allSkiPasses = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_SKI_PASS, true, true);
|
||||
$availableSkiPasses = array_filter(
|
||||
$allSkiPasses,
|
||||
|
||||
Reference in New Issue
Block a user