feat: bulk insurance booking by applicant

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 66dd51d75a
commit f2681af9ee
10 changed files with 402 additions and 24 deletions
@@ -82,13 +82,22 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
* where the selection is cleared (field not present in data). This ensures
* the participant DTO is updated with null when no insurance is selected.
*
* However, when bulk insurance booking is active for a dependent participant,
* we skip processing to prevent overwriting the insurance assigned by the
* bulk insurance handler.
*
* @param array<string, mixed> $submittedData The submitted participant form data
* @param int $participantIndex The index of the participant being processed
*
* @return bool Always returns true for insurance selection fields
* @return bool True if processing should occur, false if bulk insurance handles it
*/
public function shouldProcess(array $submittedData, int $participantIndex): bool
{
// Skip processing for dependent participants when bulk insurance booking is active
if ($participantIndex > 0 && $this->isBulkInsuranceBookingActive($submittedData)) {
return false;
}
return true; // Always process to handle deselection cases
}
@@ -258,4 +267,35 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
{
return (string) $currentInsurance->id === (string) $selectedInsuranceId;
}
/**
* Checks if bulk insurance booking is active for dependent participants.
*
* Bulk insurance is active when the applicant has enabled the bulkInsuranceBooking
* flag and has selected an insurance.
*
* @param array<string, mixed> $submittedData The submitted form data
*
* @return bool True if bulk insurance booking is active
*/
private function isBulkInsuranceBookingActive(array $submittedData): bool
{
// Check if applicant data exists
if (!isset($submittedData['participants'][0])) {
return false;
}
$applicantData = $submittedData['participants'][0];
// Check if bulk insurance booking is enabled
$bulkInsuranceBooking = $applicantData['bulkInsuranceBooking'] ?? false;
if (false === (bool) $bulkInsuranceBooking) {
return false;
}
// Check if applicant has selected an insurance
$applicantInsurance = $applicantData['insurance'] ?? null;
return null !== $applicantInsurance;
}
}