wip: insurance booking
This commit is contained in:
@@ -55,18 +55,21 @@ class BookingCreateDto implements BookingDtoInterface
|
||||
* Determines if this is a family booking based on participant age distribution.
|
||||
*
|
||||
* A family booking is defined as:
|
||||
* - 1-2 participants aged 18 or older (adults)
|
||||
* - At least 1 participant aged 20 or younger (young people/children)
|
||||
* - 1 or 2 participants aged 18 or older (adults)
|
||||
* - At least 1 participant younger than 18 (children)
|
||||
*
|
||||
* @return bool True if this qualifies as a family booking
|
||||
*/
|
||||
public function isFamilyBooking(): bool
|
||||
{
|
||||
$adults = 0; // Count of participants >= 18 years
|
||||
$youngPeople = 0; // Count of participants <= 20 years
|
||||
$children = 0; // Count of participants < 18 years
|
||||
|
||||
// Use travel start date for age calculation
|
||||
$travelStartDate = $this->travel->dateFrom;
|
||||
|
||||
foreach ($this->participants as $participant) {
|
||||
$age = $participant->getAge();
|
||||
$age = $participant->getAge($travelStartDate);
|
||||
|
||||
if (null === $age) {
|
||||
continue; // Skip participants without birth date
|
||||
@@ -74,15 +77,12 @@ class BookingCreateDto implements BookingDtoInterface
|
||||
|
||||
if ($age >= 18) {
|
||||
++$adults;
|
||||
}
|
||||
|
||||
if ($age <= 20) {
|
||||
++$youngPeople;
|
||||
} else {
|
||||
++$children;
|
||||
}
|
||||
}
|
||||
|
||||
// Check family booking criteria
|
||||
return ($adults >= 1 && $adults <= 2) && ($youngPeople >= 1);
|
||||
return ($adults >= 1 && $adults <= 2) && ($children >= 1);
|
||||
}
|
||||
|
||||
#[Assert\Callback(callback: 'validateRoomSelection', groups: ['booking_create_step_1'])]
|
||||
|
||||
Reference in New Issue
Block a user