household editor: handle case when the person is repositionned in the

same household, and the person is already in a position "without
household"
This commit is contained in:
2022-03-30 17:00:07 +02:00
parent c477996acf
commit 83dfe530e9
2 changed files with 48 additions and 0 deletions

View File

@@ -119,6 +119,20 @@ class MembersEditor
if ($person->getCurrentHousehold($date) === $this->household) {
$this->leaveMovement($date, $person);
}
// if there are multiple belongings not sharing household, close the others
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
if ($participation === $membership) {
continue;
}
if ($participation->getHousehold() === $this->household
&& ($participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate())
&& $participation->getStartDate() <= $membership->getStartDate()
) {
$participation->setEndDate($membership->getStartDate());
}
}
}
$this->membershipsAffected[] = $membership;