Add condition to household export queries to exclude accompanying periods that are in draft.

This commit is contained in:
LenaertsJ 2023-12-20 10:46:29 +00:00
parent 0da12cdc2e
commit 4d72933edb
4 changed files with 17 additions and 5 deletions

View File

@ -0,0 +1,6 @@
kind: Fixed
body: Fix the household export query to exclude accompanying periods that are in draft
state.
time: 2023-12-18T16:21:57.827287397+01:00
custom:
Issue: ""

View File

@ -17,6 +17,7 @@ use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
@ -121,7 +122,9 @@ class CountHouseholdInPeriod implements ExportInterface, GroupedExportInterface
->join('acppart.accompanyingPeriod', 'acp') ->join('acppart.accompanyingPeriod', 'acp')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL') ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)') ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date'])); ->andWhere('acp.step != :count_acp_step')
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']))
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT);
$qb $qb
->select('COUNT(DISTINCT household.id) AS household_export_result') ->select('COUNT(DISTINCT household.id) AS household_export_result')

View File

@ -20,6 +20,7 @@ use Chill\MainBundle\Export\ListInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\HouseholdComposition; use Chill\PersonBundle\Entity\Household\HouseholdComposition;
use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Household\HouseholdMember;
@ -144,7 +145,9 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
->join('acppart.accompanyingPeriod', 'acp') ->join('acppart.accompanyingPeriod', 'acp')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL') ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)') ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date'])); ->andWhere('acp.step != :list_acp_step')
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']))
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT);
if ($this->filterStatsByCenters) { if ($this->filterStatsByCenters) {
$qb $qb

View File

@ -50,7 +50,7 @@ final class RelationshipApiControllerTest extends WebTestCase
->join('p.centerCurrent', 'center_current') ->join('p.centerCurrent', 'center_current')
->join('center_current.center', 'c') ->join('center_current.center', 'c')
->where('c.name LIKE :name') ->where('c.name LIKE :name')
->andWhere('EXISTS (SELECT 1 FROM ' . Relationship::class . ' r WHERE r.fromPerson = p OR r.toPerson = p)') ->andWhere('EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
->setParameter('name', 'Center A') ->setParameter('name', 'Center A')
->getQuery() ->getQuery()
->setMaxResults(1) ->setMaxResults(1)
@ -62,7 +62,7 @@ final class RelationshipApiControllerTest extends WebTestCase
->join('p.centerCurrent', 'center_current') ->join('p.centerCurrent', 'center_current')
->join('center_current.center', 'c') ->join('center_current.center', 'c')
->where('c.name LIKE :name') ->where('c.name LIKE :name')
->andWhere('NOT EXISTS (SELECT 1 FROM ' . Relationship::class . ' r WHERE r.fromPerson = p OR r.toPerson = p)') ->andWhere('NOT EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
->setParameter('name', 'Center A') ->setParameter('name', 'Center A')
->getQuery() ->getQuery()
->setMaxResults(1) ->setMaxResults(1)
@ -85,7 +85,7 @@ final class RelationshipApiControllerTest extends WebTestCase
->join('p.centerCurrent', 'center_current') ->join('p.centerCurrent', 'center_current')
->join('center_current.center', 'c') ->join('center_current.center', 'c')
->where('c.name LIKE :name') ->where('c.name LIKE :name')
->andWhere('NOT EXISTS (SELECT 1 FROM ' . Relationship::class . ' r WHERE r.fromPerson = p OR r.toPerson = p)') ->andWhere('NOT EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
->setParameter('name', 'Center A') ->setParameter('name', 'Center A')
->getQuery() ->getQuery()
->setMaxResults(2) ->setMaxResults(2)