Household/composition add + fixes household composition editor

This commit is contained in:
2022-01-24 10:59:00 +00:00
parent 2b47868d88
commit 53b3f98bba
35 changed files with 1489 additions and 63 deletions

View File

@@ -29,6 +29,8 @@ class MembersEditor
{
public const VALIDATION_GROUP_AFFECTED = 'household_memberships';
public const VALIDATION_GROUP_COMPOSITION = 'household_composition';
public const VALIDATION_GROUP_CREATED = 'household_memberships_created';
private ?Household $household = null;
@@ -77,6 +79,15 @@ class MembersEditor
$this->oldMembershipsHashes[] = spl_object_hash($participation);
}
}
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
if ($participation->getHousehold() === $this->household
&& $participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate()
&& $participation->getStartDate() <= $membership->getStartDate()
) {
$participation->setEndDate($membership->getStartDate());
}
}
}
$this->membershipsAffected[] = $membership;
@@ -129,7 +140,7 @@ class MembersEditor
{
if ($this->hasHousehold()) {
$list = $this->validator
->validate($this->getHousehold(), null, [self::VALIDATION_GROUP_AFFECTED]);
->validate($this->getHousehold(), null, [self::VALIDATION_GROUP_AFFECTED, self::VALIDATION_GROUP_COMPOSITION]);
} else {
$list = new ConstraintViolationList();
}