wip: rentals insurance field

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 3063a7c05f
commit b84997d058
13 changed files with 315 additions and 83 deletions
@@ -183,6 +183,13 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
'choice_label' => fn (?Service $service) => $this->formatServiceLabelWithPrice($service),
];
// Rental insurance field provider - provides rental insurance options when rental services are selected
$this->fieldOptionProviders['rentalInsurance'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
'label' => $this->getRentalInsuranceCheckboxLabel($bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_RENTAL_INSURANCE, true, true)),
'required' => false,
'property_path' => 'rentalInsuranceSelected',
];
// Skipass field provider - provides age-appropriate skipass options from travel data filtered by date range
$this->fieldOptionProviders['skiPass'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
'label' => 'Skipass',
@@ -477,4 +484,16 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
return $ageEvaluator->isServiceAvailableForParticipant($service, $bookingDto, $participantIndex);
});
}
/**
* Generates label for rental insurance checkbox including pricing information.
*/
private function getRentalInsuranceCheckboxLabel(array $rentalInsuranceServices): string
{
if (empty($rentalInsuranceServices)) {
return 'Leihmaterial-Versicherung';
}
$rentalInsuranceService = reset($rentalInsuranceServices); // Get the first (and only) rental insurance service
return $this->formatServiceLabelWithPrice($rentalInsuranceService);
}
}