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

@@ -15,13 +15,14 @@ use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Notification;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class PersonMoveEventSubscriber implements EventSubscriberInterface
class PersonAddressMoveEventSubscriber implements EventSubscriberInterface
{
private EngineInterface $engine;
@@ -62,17 +63,11 @@ class PersonMoveEventSubscriber implements EventSubscriberInterface
continue;
}
$now = new \DateTimeImmutable('now');
if (
$period->getPersonLocation() === $person
&&
(
&& (
$event->getMoveDate() >= $period->getLastLocationHistory()->getStartDate()
|| (
$event->getNextAddress()->getValidFrom() < $now
&& (null === $event->getNextAddress()->getValidTo() || $event->getNextAddress()->getValidTo() > $now)
)
|| $event->willChangeBeActiveAt(new DateTimeImmutable('now'))
)
&& null !== $period->getUser()
&& $period->getUser() !== $this->security->getUser()