wip: incorrect rules around family insurances
addresses #869dr80qj
This commit is contained in:
1 parent
97d98f7f12
commit
27255691b6
15 files changed
+859
-50
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
/**
|
||||
* True for dependent participants when the applicant has a family insurance selected.
|
||||
*
|
||||
* Family insurance covers the whole family under a single policy on the applicant, so
|
||||
* dependents must not be offered their own insurance selection while it's active.
|
||||
*/
|
||||
class FamilyInsuranceActiveCondition implements FieldConditionInterface
|
||||
{
|
||||
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
||||
{
|
||||
if (0 === $participantIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
|
||||
return null !== $applicant
|
||||
&& null !== $applicant->insurance
|
||||
&& true === $applicant->insurance->familyInsurance;
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
{
|
||||
return ['insurance'];
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Applicant has a family insurance selected';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user