feat: consolidated insurance service
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user