[Household] when two adresses on same date, close the existing one

This commit is contained in:
Julien Fastré 2021-11-29 21:13:28 +01:00
parent 18cfe17878
commit 217b74b9e2
2 changed files with 2 additions and 1 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to
## Unreleased ## Unreleased
<!-- write down unreleased development here --> <!-- write down unreleased development here -->
* [household] do not allow to create two addresses on the same date
## Test releases ## Test releases

View File

@ -92,7 +92,7 @@ class Household
public function addAddress(Address $address) public function addAddress(Address $address)
{ {
foreach ($this->getAddresses() as $a) { foreach ($this->getAddresses() as $a) {
if ($a->getValidFrom() < $address->getValidFrom() && $a->getValidTo() === null) { if ($a->getValidFrom() <= $address->getValidFrom() && $a->getValidTo() === null) {
$a->setValidTo($address->getValidFrom()); $a->setValidTo($address->getValidFrom());
} }
} }