PersonAddressMove: fix tests, address history on household, and household::getMembersOnRange

This commit is contained in:
2022-02-21 00:12:57 +01:00
parent caa63ea97a
commit 4f4b1bfbaa
9 changed files with 288 additions and 210 deletions

View File

@@ -168,4 +168,42 @@ class PersonAddressMoveEvent extends Event
return $this;
}
/**
* Will the change affect this date ?
*/
public function willChangeBeActiveAt(DateTimeImmutable $date): bool
{
if ($this->getMoveDate() < $date && $this->personLeaveWithoutHousehold()) {
return true;
}
if ($this->personChangeHousehold()) {
if ($this->getMoveDate() > $date) {
return false;
}
if (null === $this->getNextMembership()->getEndDate()) {
return true;
}
if ($this->getNextMembership()->getEndDate() > $date) {
return true;
}
} else {
if ($this->getNextAddress()->getValidFrom() > $date) {
return false;
}
if (null === $this->getNextAddress()->getValidTo()) {
return true;
}
if ($this->getNextAddress()->getValidTo() > $date) {
return true;
}
}
return false;
}
}