wip: bulk insurance refactoring

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent a3d7ee63d3
commit 1f5c835f8a
9 changed files with 359 additions and 51 deletions
@@ -774,9 +774,8 @@ class BookingPriceCalculatorService
// This mirrors the logic in BookingDataProcessor::applyBulkInsuranceIfActive()
$availableInsurances = $bookingDto->travel->insurances;
// Exclude complementary insurances
$availableInsurances = array_filter($availableInsurances, fn ($insurance) => false === $insurance->complementary);
$availableInsurances = array_values($availableInsurances);
// Exclude complementary insurances (only available as part of packages)
$availableInsurances = $this->insuranceTypeFilterService->filterNonComplementary($availableInsurances);
// Get insurances of the same type as applicant's selection
$sameTypeInsurances = $this->insuranceTypeFilterService->filterByType(
@@ -11,6 +11,23 @@ use App\BusProNet\Model\Insurance;
*/
class InsuranceTypeFilterService
{
/**
* Filters out complementary insurances from an insurance array.
*
* Complementary insurances are only available as part of packages
* and cannot be directly selected by users.
*
* @param array<Insurance> $insurances Array of insurances to filter
*
* @return array<Insurance> Array containing only non-complementary insurances with reset keys
*/
public function filterNonComplementary(array $insurances): array
{
return array_values(
array_filter($insurances, fn (Insurance $insurance) => false === $insurance->complementary)
);
}
/**
* Filters insurances by type based on label (for packages) or subType (for individual insurances).
*