mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix bounds for view current person address
This commit is contained in:
parent
da686ab3b5
commit
2d536b8b53
@ -12,6 +12,7 @@ and this project adheres to
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
* [person] create an accompanying course: add client-side validation if no origin (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/210)
|
||||
* [person] fix bounds for computing current person address: the new address appears immediatly
|
||||
|
||||
* [main] fix adding multiple AddresseDeRelais (combine PickAddressType with ChillCollection)
|
||||
* [person]: do not suggest the current household of the person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/51)
|
||||
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211119215630 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'update computation of view_chill_person_current_address: do not take enddate into account';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("CREATE OR REPLACE VIEW view_chill_person_current_address AS
|
||||
SELECT
|
||||
cphm.person_id AS person_id,
|
||||
cma.id AS address_id,
|
||||
CASE WHEN cphm.startdate > COALESCE(cma.validfrom, '-infinity'::date) THEN cphm.startdate ELSE cma.validfrom END AS valid_from,
|
||||
CASE WHEN COALESCE(cphm.enddate, 'infinity'::date) < COALESCE(cma.validto, 'infinity'::date) THEN cphm.enddate ELSE cma.validto END AS valid_to
|
||||
FROM chill_person_household_members AS cphm
|
||||
LEFT JOIN chill_person_household_to_addresses AS cphta ON cphta.household_id = cphm.household_id
|
||||
LEFT JOIN chill_main_address AS cma ON cphta.address_id = cma.id
|
||||
WHERE
|
||||
cphm.sharedhousehold IS TRUE
|
||||
AND
|
||||
daterange(cphm.startdate, cphm.enddate, '[)') @> current_date
|
||||
AND
|
||||
daterange(cma.validfrom, cma.validto, '[)') @> current_date
|
||||
");
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("CREATE VIEW view_chill_person_current_address AS
|
||||
SELECT
|
||||
cphm.person_id AS person_id,
|
||||
cma.id AS address_id,
|
||||
CASE WHEN cphm.startdate > COALESCE(cma.validfrom, '-infinity'::date) THEN cphm.startdate ELSE cma.validfrom END AS valid_from,
|
||||
CASE WHEN COALESCE(cphm.enddate, 'infinity'::date) < COALESCE(cma.validto, 'infinity'::date) THEN cphm.enddate ELSE cma.validto END AS valid_to
|
||||
FROM chill_person_household_members AS cphm
|
||||
LEFT JOIN chill_person_household_to_addresses AS cphta ON cphta.household_id = cphm.household_id
|
||||
LEFT JOIN chill_main_address AS cma ON cphta.address_id = cma.id
|
||||
WHERE
|
||||
cphm.sharedhousehold IS TRUE
|
||||
AND
|
||||
current_date between cphm.startdate AND coalesce(enddate, 'infinity'::date)
|
||||
AND
|
||||
current_date between cma.validfrom AND coalesce(validto, 'infinity'::date)
|
||||
");
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user