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
@@ -14,8 +14,8 @@ use App\BusProNet\Utility\DirectionMapper;
use App\Form\Model\BankAccountDto;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Service\InsuranceMatchingService;
use App\Service\InsuranceTypeFilterService;
use App\Service\BookingPriceCalculatorService;
use App\Service\InsuranceService;
/**
* Processes booking form data and converts it into BusProNet API payload format.
@@ -29,8 +29,8 @@ use App\Service\InsuranceTypeFilterService;
class BookingDataProcessor
{
public function __construct(
private readonly InsuranceMatchingService $insuranceMatchingService,
private readonly InsuranceTypeFilterService $insuranceTypeFilterService,
private readonly InsuranceService $insuranceService,
private readonly BookingPriceCalculatorService $priceCalculatorService,
) {
}
@@ -1111,17 +1111,21 @@ class BookingDataProcessor
return;
}
// Get all available insurances from travel data
$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 prices for all participants (excluding insurance)
$participantPrices = [];
foreach ($bookingDto->getParticipants() as $index => $participant) {
$participantPrices[$index] = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $index);
}
// Use InsuranceMatchingService for proper type-based assignment with price tier matching
$assignments = $this->insuranceMatchingService->batchAssignInsuranceToParticipants(
$availableInsurances,
// Use InsuranceService for proper type-based assignment with price tier matching
$assignments = $this->insuranceService->batchAssignInsuranceToParticipants(
$selectableInsurances,
$applicant->insurance,
$bookingDto
$bookingDto,
$participantPrices
);
// Apply assignments to dependent participants (skip applicant at index 0)