wip: check eligibility based on ski pass availability
This commit is contained in:
@@ -19,6 +19,7 @@ class BookingService
|
||||
public function __construct(
|
||||
private readonly TravelDataService $travelDataService,
|
||||
private readonly BookingPriceCalculatorService $priceCalculator,
|
||||
private readonly ParticipantEligibilityService $participantEligibilityService,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ class BookingService
|
||||
* Converts a Room model into a RoomSelectionDto with the specified quantity
|
||||
* selection. Used during booking initialization to create selectable room options.
|
||||
*
|
||||
* @param Room $room The room model to convert
|
||||
* @param Room $room The room model to convert
|
||||
* @param array $roomsIdsAndQuantities Array of room ID to quantity mappings
|
||||
*
|
||||
* @return RoomSelectionDto The room selection DTO
|
||||
@@ -329,6 +330,10 @@ class BookingService
|
||||
* and pricing calculations, resolving timing issues where mandatory services
|
||||
* were only selected during form rendering via choice_attr callbacks.
|
||||
*
|
||||
* Mandatory services are only preselected for eligible participants - those who
|
||||
* have at least one skipass available for their age. Ineligible participants are
|
||||
* skipped to prevent their mandatory services from being included in pricing.
|
||||
*
|
||||
* @param BookingCreateDto $bookingDto The booking DTO to update with mandatory services
|
||||
*/
|
||||
public function preselectMandatoryServices(BookingCreateDto $bookingDto): void
|
||||
@@ -337,11 +342,16 @@ class BookingService
|
||||
$mandatoryServices = array_filter($additionalServices, fn ($service) => true === $service->mandatory);
|
||||
|
||||
// Pre-select mandatory services for each participant
|
||||
foreach ($bookingDto->participants as $participant) {
|
||||
foreach ($bookingDto->participants as $participantIndex => $participant) {
|
||||
if (null === $participant->dateOfBirth) {
|
||||
continue; // Skip participants without age information
|
||||
}
|
||||
|
||||
// Skip ineligible participants (no skipasses available for their age)
|
||||
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get age-appropriate mandatory services for this participant
|
||||
$ageAppropriateServices = array_filter($mandatoryServices, function ($service) use ($bookingDto, $participant) {
|
||||
if (null === $service->ageFrom && null === $service->ageTo) {
|
||||
|
||||
Reference in New Issue
Block a user