diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f5473057..d2e1a939b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to * [docgen]: add base context + tests * [docgen]: add age for person * [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338) +* Household: fix bug when moving person on the same day (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/281) ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php index c4fad7e41..49a995341 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php @@ -29,7 +29,7 @@ class MaxHolderValidator extends ConstraintValidator $covers = new DateRangeCovering( self::MAX_HOLDERS, - $holders[0]->getStartDate()->getTimezone() + $holders->first()->getStartDate()->getTimezone() ); foreach ($holders as $key => $member) { diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php b/src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php new file mode 100644 index 000000000..1cd430055 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE chill_person_household_members DROP CONSTRAINT chill_person_household_members_check'); + $this->addSql('ALTER TABLE chill_person_household_members ADD CONSTRAINT chill_person_household_members_check CHECK (startdate < enddate)'); + } + + public function getDescription(): string + { + return 'Allow a person to be moved into different household on same day'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_household_members DROP CONSTRAINT chill_person_household_members_check'); + $this->addSql('ALTER TABLE chill_person_household_members ADD CONSTRAINT chill_person_household_members_check CHECK (startdate <= enddate)'); + } +}