wip: bulk insurance refactoring
This commit is contained in:
@@ -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).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user