feat: consolidated insurance service

This commit is contained in:
Björn Fromme
2025-10-20 09:22:03 +02:00
parent fb9c9d91ee
commit 38bc594ca4
12 changed files with 681 additions and 545 deletions
+7 -10
View File
@@ -22,8 +22,7 @@ class BookingPriceCalculatorService
{
public function __construct(
private readonly ParticipantEligibilityService $participantEligibilityService,
private readonly InsuranceTypeFilterService $insuranceTypeFilterService,
private readonly InsuranceEligibilityService $insuranceEligibilityService,
private readonly InsuranceService $insuranceService,
) {
}
@@ -772,22 +771,20 @@ class BookingPriceCalculatorService
// For dependent participants: calculate price-tier-adjusted insurance
// This mirrors the logic in BookingDataProcessor::applyBulkInsuranceIfActive()
$availableInsurances = $bookingDto->travel->insurances;
// Exclude complementary insurances (only available as part of packages)
$availableInsurances = $this->insuranceTypeFilterService->filterNonComplementary($availableInsurances);
// Get selectable (non-complementary) insurances with caching
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
// Get insurances of the same type as applicant's selection
$sameTypeInsurances = $this->insuranceTypeFilterService->filterByType(
$availableInsurances,
$sameTypeInsurances = $this->insuranceService->filterByType(
$selectableInsurances,
$applicant->insurance
);
// Calculate participant's travel price (excluding insurance)
// Calculate travel price for eligibility checks
$travelPrice = $this->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $participant->index);
// Get eligible insurances for THIS participant (price tier adjusted)
$eligibleInsurances = $this->insuranceEligibilityService->getEligibleInsurances(
$eligibleInsurances = $this->insuranceService->getEligibleInsurances(
$sameTypeInsurances,
$participant,
$bookingDto,