From 1663c6f7c7a42977cb872ef201bdf3ecb48cd4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Nov 2023 12:56:59 +0100 Subject: [PATCH] DX: rename CountHousehold => CountHouseholdInPeriod.php + add test --- ...usehold.php => CountHouseholdInPeriod.php} | 4 +- .../Export/CountHouseholdInPeriodTest.php | 58 +++++++++++++++++++ .../config/services/exports_household.yaml | 16 ++--- 3 files changed, 64 insertions(+), 14 deletions(-) rename src/Bundle/ChillPersonBundle/Export/Export/{CountHousehold.php => CountHouseholdInPeriod.php} (95%) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Export/CountHouseholdInPeriodTest.php diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHouseholdInPeriod.php similarity index 95% rename from src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php rename to src/Bundle/ChillPersonBundle/Export/Export/CountHouseholdInPeriod.php index 82a5c4aa4..8b56be371 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHouseholdInPeriod.php @@ -26,7 +26,7 @@ use Doctrine\ORM\Query; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; -class CountHousehold implements ExportInterface, GroupedExportInterface +class CountHouseholdInPeriod implements ExportInterface, GroupedExportInterface { private const TR_PREFIX = 'export.export.nb_household_with_course.'; private readonly bool $filterStatsByCenters; @@ -120,6 +120,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface ->join('person.accompanyingPeriodParticipations', 'acppart') ->join('acppart.accompanyingPeriod', 'acp') ->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)') ->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date'])); $qb @@ -135,7 +136,6 @@ class CountHousehold implements ExportInterface, GroupedExportInterface ' ) ) - ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)') ->setParameter('authorized_centers', $centers); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountHouseholdInPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountHouseholdInPeriodTest.php new file mode 100644 index 000000000..b29c9a1f9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountHouseholdInPeriodTest.php @@ -0,0 +1,58 @@ +get(EntityManagerInterface::class); + $rollingDate = self::$container->get(RollingDateConverterInterface::class); + + yield new CountHouseholdInPeriod($em, $rollingDate, $this->getParameters(true)); + yield new CountHouseholdInPeriod($em, $rollingDate, $this->getParameters(false)); + } + + public function getFormData() + { + return [ + ['calc_date' => new RollingDate(RollingDate::T_TODAY)], + ]; + } + + public function getModifiersCombination() + { + return [ + [ + Declarations::HOUSEHOLD_TYPE, + Declarations::ACP_TYPE, + Declarations::PERSON_TYPE, + ]]; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_household.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_household.yaml index 1a12c1bc8..15386c2cd 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_household.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_household.yaml @@ -1,38 +1,30 @@ services: + _defaults: + autoconfigure: true + autowire: true ## Indicators - chill.person.export.count_household: - class: Chill\PersonBundle\Export\Export\CountHousehold - autowire: true - autoconfigure: true + Chill\PersonBundle\Export\Export\CountHouseholdInPeriod: tags: - { name: chill.export, alias: count_household } Chill\PersonBundle\Export\Export\ListHouseholdInPeriod: - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: list_household_in_period } ## Filters chill.person.export.filter_household_composition: class: Chill\PersonBundle\Export\Filter\HouseholdFilters\CompositionFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: household_composition_filter } ## Aggregators chill.person.export.aggregator_household_composition: class: Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\CompositionAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: household_composition_aggregator } chill.person.export.aggregator_household_childrennumber: class: Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\ChildrenNumberAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: household_childrennumber_aggregator }