feat: consolidated insurance service
This commit is contained in:
@@ -12,8 +12,8 @@ use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Abstract\AbstractFieldOptionsProvider;
|
||||
use App\Form\Service\Factory\ParticipantRoomChoiceLoaderFactory;
|
||||
use App\Service\InsuranceMatchingService;
|
||||
use App\Service\InsuranceTypeFilterService;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\ServiceAvailabilityCalculator;
|
||||
|
||||
/**
|
||||
@@ -45,13 +45,14 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
*
|
||||
* @param ParticipantRoomChoiceLoaderFactory $roomChoiceLoaderFactory Factory for creating room choice loaders
|
||||
* @param ServiceAvailabilityCalculator $serviceAvailabilityCalculator Service for calculating dynamic availability
|
||||
* @param InsuranceMatchingService $insuranceMatchingService Service for matching insurances to participants
|
||||
* @param InsuranceService $insuranceService Service for insurance operations
|
||||
* @param BookingPriceCalculatorService $priceCalculatorService Service for calculating participant prices
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly ParticipantRoomChoiceLoaderFactory $roomChoiceLoaderFactory,
|
||||
private readonly ServiceAvailabilityCalculator $serviceAvailabilityCalculator,
|
||||
private readonly InsuranceMatchingService $insuranceMatchingService,
|
||||
private readonly InsuranceTypeFilterService $insuranceTypeFilterService,
|
||||
private readonly InsuranceService $insuranceService,
|
||||
private readonly BookingPriceCalculatorService $priceCalculatorService,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -756,16 +757,18 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
return [];
|
||||
}
|
||||
|
||||
$availableInsurances = $bookingDto->travel->insurances ?? [];
|
||||
// Get selectable (non-complementary) insurances with caching
|
||||
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
|
||||
|
||||
// Exclude complementary insurances (only available as part of packages)
|
||||
$availableInsurances = $this->insuranceTypeFilterService->filterNonComplementary($availableInsurances);
|
||||
// Calculate travel price for eligibility filtering
|
||||
$travelPrice = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $participantIndex);
|
||||
|
||||
// Use insurance matching service to filter based on eligibility criteria
|
||||
return $this->insuranceMatchingService->getEligibleInsurances(
|
||||
$availableInsurances,
|
||||
// Filter based on eligibility criteria for this participant
|
||||
return $this->insuranceService->getEligibleInsurances(
|
||||
$selectableInsurances,
|
||||
$participant,
|
||||
$bookingDto
|
||||
$bookingDto,
|
||||
$travelPrice
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user