From 6b958d193d619036b919744edf8cb1223ceaeabb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 18 Sep 2023 13:38:45 +0200 Subject: [PATCH 01/18] add property to closing motive to identify motives related to erroneous accompanying periods --- .../AccompanyingPeriod/ClosingMotive.php | 23 +++++++++++++++ .../migrations/Version20230918115305.php | 29 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php index 08dca4537..2d0f5efd0 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php @@ -69,6 +69,12 @@ class ClosingMotive */ private ?ClosingMotive $parent = null; + /** + * @var bool + * @ORM\Column(type="boolean") + */ + private bool $isCanceledAccompanyingPeriod = false; + /** * ClosingMotive constructor. */ @@ -127,6 +133,11 @@ class ClosingMotive return $this->parent; } + public function getIsCanceledAccompanyingPeriod(): bool + { + return $this->isCanceledAccompanyingPeriod; + } + public function hasParent(): bool { return null !== $this->parent; @@ -152,6 +163,11 @@ class ClosingMotive return $this->children->count() > 0; } + public function isFalseAccompanyingPeriod(): bool + { + return $this->isFalseAccompanyingPeriod; + } + public function removeChildren(ClosingMotive $child): ClosingMotive { if ($this->children->removeElement($child)) { @@ -218,4 +234,11 @@ class ClosingMotive return $this; } + + public function setIsCanceledAccompanyingPeriod(bool $isCanceledAP): ClosingMotive + { + $this->isCanceledAccompanyingPeriod = $isCanceledAP; + + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php b/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php new file mode 100644 index 000000000..684ff422b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_person_accompanying_period_closingmotive ADD isCanceledAccompanyingPeriod BOOLEAN DEFAULT FALSE NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive DROP isCanceledAccompanyingPeriod'); + } +} From 7db7f34f62267bec5c76c772b82d2114b31d8808 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 18 Sep 2023 14:36:56 +0200 Subject: [PATCH 02/18] Adjust closing motive form --- .../ChillPersonBundle/Form/ClosingMotiveType.php | 12 ++++++++++++ .../ChillPersonBundle/translations/messages.fr.yml | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php b/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php index 35dc502b9..84081fdd5 100644 --- a/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php +++ b/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php @@ -19,12 +19,20 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Contracts\Translation\TranslatorInterface; /** * Class ClosingMotiveType. */ class ClosingMotiveType extends AbstractType { + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + public function buildForm(FormBuilderInterface $builder, array $options) { $builder @@ -46,6 +54,10 @@ class ClosingMotiveType extends AbstractType 'placeholder' => 'closing_motive.any parent', 'multiple' => false, 'only_leaf' => false, + ]) + ->add('isCanceledAccompanyingPeriod', CheckboxType::class, [ + 'label' => $this->translator->trans('Consider canceled'), + 'help' => $this->translator->trans('Canceled parcours help') ]); } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 12ec6ea29..2496a4555 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -349,6 +349,8 @@ CHILL_PERSON_HOUSEHOLD_STATS: Statistiques sur les ménages #period Period closed!: Parcours clôturé! Pediod closing form is not valide: Le formulaire de fermeture n'est pas valide +Consider canceled: Permet de considérer les parcours comme annulés +Canceled parcours help: Si coché, les parcours avec ce motif de cloture seront considérés comme annulés et ne seront pas pris en compte pour les statistiques. La modification se reflétera pour tous les motifs enfants #widget From 3816d68e188a6aae7d73f87d81e3e6d6cdeeafe3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 18 Sep 2023 15:16:26 +0200 Subject: [PATCH 03/18] add isCanceledAccompanyingPeriod field to form --- src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php b/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php index 84081fdd5..251044e9e 100644 --- a/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php +++ b/src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php @@ -57,6 +57,7 @@ class ClosingMotiveType extends AbstractType ]) ->add('isCanceledAccompanyingPeriod', CheckboxType::class, [ 'label' => $this->translator->trans('Consider canceled'), + 'required' => false, 'help' => $this->translator->trans('Canceled parcours help') ]); } From 9b061eeaae1d45b5a88c1309f88bfbb431861bef Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 18 Sep 2023 15:16:59 +0200 Subject: [PATCH 04/18] handle children of closing motive for isCanceledAccompanyingPeriod --- .../Entity/AccompanyingPeriod/ClosingMotive.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php index 2d0f5efd0..0b5b66f77 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php @@ -90,7 +90,7 @@ class ClosingMotive } $this->children->add($child); - $child->setParent($this); + $child->setParent($this)->setIsCanceledAccompanyingPeriod($this->getIsCanceledAccompanyingPeriod()); return $this; } @@ -239,6 +239,10 @@ class ClosingMotive { $this->isCanceledAccompanyingPeriod = $isCanceledAP; + foreach ($this->getChildren() as $child) { + $child->setIsCanceledAccompanyingPeriod($isCanceledAP); + } + return $this; } } From 05e86a3360b184d525e215e780415d271af16852 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 18 Sep 2023 15:17:26 +0200 Subject: [PATCH 05/18] adjust rendering of closing motive: indicate if isCanceledAccompanyingPeriod --- .../Templating/Entity/ClosingMotiveRender.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php index 0064a53d5..b574382ad 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php @@ -62,6 +62,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface private function renderStringRecursive(ClosingMotive $motive, string $existing, array $options) { $newExisting = $this->translatableStringHelper->localize($motive->getName()); + $isCancled = $motive->getIsCanceledAccompanyingPeriod() ? '( Annule le parcours )' : ''; if ($motive->hasParent()) { if ('' !== $existing) { @@ -70,7 +71,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface return $this->renderStringRecursive( $motive->getParent(), - $newExisting, + $newExisting . ' ' . $isCancled, $options ); } @@ -79,6 +80,6 @@ class ClosingMotiveRender implements ChillEntityRenderInterface return $newExisting . self::SEPARATOR . $existing; } - return $newExisting; + return $newExisting . ' ' . $isCancled; } } From 5d41b37620408fa2fb22829f88d2ab7e814b03a4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Sep 2023 13:06:19 +0200 Subject: [PATCH 06/18] create helper service to exclude accompanying periods from export result based on closing motive --- .../Export/AccompanyingCourseExportHelper.php | 22 +++++++++++++++++++ .../ChillMainBundle/config/services.yaml | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php diff --git a/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php b/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php new file mode 100644 index 000000000..dae4ce254 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php @@ -0,0 +1,22 @@ +leftJoin('acp.closingMotive', 'cm') + ->andWhere( + $qb->expr()->orX( + $qb->expr()->eq('cm.isCanceledAccompanyingPeriod', 'false'), + $qb->expr()->isNull('acp.closingMotive') + ) + ); + + return $qb; + } + +} diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index 5976cb8b0..501a894e6 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -125,3 +125,7 @@ services: Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager: arguments: $vienEntityInfoProviders: !tagged_iterator chill_main.entity_info_provider + + Chill\MainBundle\Export\AccompanyingCourseExportHelper: + autoconfigure: true + autowire: true From 500b37601aca5ed6753588d4ef667dff426f1540 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Sep 2023 13:06:50 +0200 Subject: [PATCH 07/18] implement new export service for accompanyingcourse exports --- .../Export/LinkedToACP/AvgActivityDuration.php | 9 ++++++++- .../Export/LinkedToACP/AvgActivityVisitDuration.php | 9 ++++++++- .../Export/Export/LinkedToACP/CountActivity.php | 12 ++++++++++-- .../Export/Export/LinkedToACP/ListActivity.php | 9 ++++++++- .../Export/LinkedToACP/SumActivityDuration.php | 9 ++++++++- .../Export/LinkedToACP/SumActivityVisitDuration.php | 9 ++++++++- .../Export/AccompanyingCourseExportHelper.php | 4 ++-- .../Export/Export/CountAccompanyingCourse.php | 9 ++++++++- .../Export/Export/CountAccompanyingPeriodWork.php | 9 ++++++++- .../Export/Export/CountEvaluation.php | 9 ++++++++- .../Export/CountPersonWithAccompanyingCourse.php | 9 ++++++++- .../Export/Export/ListAccompanyingPeriod.php | 4 ++++ .../Export/Export/ListAccompanyingPeriodWork.php | 9 ++++++++- .../Export/Export/ListEvaluation.php | 9 ++++++++- .../Export/ListPersonHavingAccompanyingPeriod.php | 9 ++++++++- .../ListPersonWithAccompanyingPeriodDetails.php | 4 ++++ .../Export/Export/StatAccompanyingCourseDuration.php | 9 ++++++++- 17 files changed, 124 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 128704296..7fe114401 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -30,10 +31,14 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) {} @@ -108,6 +113,8 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index f1e926c64..dc26dc926 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -30,10 +31,14 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac { protected EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -111,6 +116,8 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac ) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 28a318541..b6615f8e5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -30,10 +31,15 @@ class CountActivity implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em - ) { + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper + +) { $this->repository = $em->getRepository(Activity::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) {} @@ -105,6 +111,8 @@ class CountActivity implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb->select('COUNT(DISTINCT activity.id) as export_count_activity'); return $qb; diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 9ed6bcda2..73d98e954 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Export\ListActivityHelper; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Entity\Scope; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper; use Chill\MainBundle\Export\ListInterface; @@ -30,14 +31,18 @@ class ListActivity implements ListInterface, GroupedExportInterface private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( ListActivityHelper $helper, EntityManagerInterface $entityManager, - TranslatableStringExportLabelHelper $translatableStringExportLabelHelper + TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->helper = $helper; $this->entityManager = $entityManager; $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -147,6 +152,8 @@ class ListActivity implements ListInterface, GroupedExportInterface ->addSelect('(SELECT AGGREGATE(acpScope.name) FROM ' . Scope::class . ' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames') ->addGroupBy('scopesNames'); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 8adb3b77f..f9bb4fa37 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -30,10 +31,14 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -111,6 +116,8 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index cc424e68b..979974d36 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Export\Export\LinkedToACP; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -30,10 +31,14 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { protected EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -111,6 +116,8 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac ) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } diff --git a/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php b/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php index dae4ce254..3c49eb124 100644 --- a/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php +++ b/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php @@ -4,9 +4,9 @@ namespace Chill\MainBundle\Export; use Doctrine\ORM\QueryBuilder; -class AccompanyingCourseExportHelper +final readonly class AccompanyingCourseExportHelper { - public static function addClosingMotiveExclusionCriteria(QueryBuilder $qb): QueryBuilder + public static function addClosingMotiveExclusionClause(QueryBuilder $qb): QueryBuilder { $qb->leftJoin('acp.closingMotive', 'cm') ->andWhere( diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 58ef24e42..6fa24df4e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -29,10 +30,14 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(AccompanyingPeriod::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -111,6 +116,8 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb->select('COUNT(DISTINCT acp.id) AS export_result'); return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index cf9feb3af..a42c7eb66 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -28,10 +29,14 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter { protected EntityManagerInterface $em; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->em = $em; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -112,6 +117,8 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter $qb->select('COUNT(DISTINCT acpw.id) as export_result'); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index d9795e3ba..b61d2b5b1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -27,10 +28,14 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface { private EntityManagerInterface $entityManager; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->entityManager = $em; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -110,6 +115,8 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb->select('COUNT(DISTINCT workeval.id) AS export_result'); return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index ae7238d4e..63fa63f46 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -29,10 +30,14 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor { private EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(AccompanyingPeriod::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -111,6 +116,8 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor ) )->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb->select('COUNT(DISTINCT person.id) AS export_result'); return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 4c8c0cae8..c00e6e602 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Export; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Scope; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\Helper\DateTimeHelper; @@ -52,6 +53,7 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter, private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper, + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) {} public function buildForm(FormBuilderInterface $builder) @@ -132,6 +134,8 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb ->addOrderBy('acp.openingDate') ->addOrderBy('acp.closingDate') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index c437454c2..9e225a47c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\Helper\AggregateStringHelper; @@ -100,6 +101,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac private UserHelper $userHelper; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( EntityManagerInterface $entityManager, DateTimeHelper $dateTimeHelper, @@ -112,7 +115,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac SocialActionRender $socialActionRender, RollingDateConverterInterface $rollingDateConverter, AggregateStringHelper $aggregateStringHelper, - SocialActionRepository $socialActionRepository + SocialActionRepository $socialActionRepository, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->entityManager = $entityManager; $this->dateTimeHelper = $dateTimeHelper; @@ -126,6 +130,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac $this->rollingDateConverter = $rollingDateConverter; $this->aggregateStringHelper = $aggregateStringHelper; $this->socialActionRepository = $socialActionRepository; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -291,6 +296,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac ->setParameter('authorized_centers', $centers) ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date'])); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index c3e273733..8a2d6752a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\Helper\AggregateStringHelper; @@ -90,6 +91,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface private UserHelper $userHelper; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( EntityManagerInterface $entityManager, SocialIssueRender $socialIssueRender, @@ -101,7 +104,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface DateTimeHelper $dateTimeHelper, TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, AggregateStringHelper $aggregateStringHelper, - RollingDateConverterInterface $rollingDateConverter + RollingDateConverterInterface $rollingDateConverter, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->entityManager = $entityManager; $this->socialIssueRender = $socialIssueRender; @@ -114,6 +118,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; $this->aggregateStringHelper = $aggregateStringHelper; $this->rollingDateConverter = $rollingDateConverter; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -270,6 +275,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface ->setParameter('authorized_centers', $centers) ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date'])); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php index 408d0b3af..533f6cd60 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -48,14 +49,18 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf private ListPersonHelper $listPersonHelper; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( ExportAddressHelper $addressHelper, ListPersonHelper $listPersonHelper, - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->addressHelper = $addressHelper; $this->listPersonHelper = $listPersonHelper; $this->entityManager = $em; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -190,6 +195,8 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf $this->listPersonHelper->addSelect($qb, $fields, $data['address_date']); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb ->addOrderBy('person.lastName') ->addOrderBy('person.firstName') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php index 66d4d1530..0a1819884 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -50,6 +51,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper, private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter, + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) {} public function buildForm(FormBuilderInterface $builder) @@ -133,6 +135,8 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte $this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date'])); $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date'])); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb ->addOrderBy('person.lastName') ->addOrderBy('person.firstName') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 66b47131d..e558163dc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Export; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -31,10 +32,14 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn { private EntityRepository $repository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(AccompanyingPeriod::class); + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -142,6 +147,8 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT) ->setParameter('authorized_centers', $centers); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + return $qb; } From 260a173a61592a4a4af5dcbdcf15b830d6d4f64e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Sep 2023 15:21:14 +0200 Subject: [PATCH 08/18] Add test for accompanyingPeriodExportHelper: closing motive exclusion --- .../AccompanyingCourseExportHelperTest.php | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php diff --git a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php new file mode 100644 index 000000000..bc7f413d7 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php @@ -0,0 +1,114 @@ + + */ + private static array $entitiesToDelete = []; + + private EntityManagerInterface $em; + + private EntityRepository $repository; + + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + + protected function setUp(): void + { + self::bootKernel(); + $this->em = self::$container->get(EntityManagerInterface::class); + $this->repository = self::$container->get($this->em->getRepository(AccompanyingPeriod::class)); + $this->accompanyingPeriodExportHelper = self::$container->get(AccompanyingCourseExportHelper::class); + } + + public static function tearDownAfterClass(): void + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + foreach (self::$entitiesToDelete as [$class, $id]) { + $entity = $em->find($class, $id); + + if (null !== $entity) { + $em->remove($entity); + } + } + + $em->flush(); + } + + /** + * @dataProvider dataProviderExclusionOnClosingMotive + */ + public function testExclusionOnClosingMotive( + AccompanyingPeriod $periodA, //canceled + AccompanyingPeriod $periodB, // not canceled + AccompanyingPeriod $periodC // canceled (child cm of canceled cm) + ): void + { + $qb = $this->repository->createQueryBuilder('acp'); + $qb->select('acp.id')->from(AccompanyingPeriod::class, 'acp'); + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + + $periodIdsFound = $qb->getQuery()->getResult(); + + self::assertContains($periodB->getId(), $periodIdsFound, 'Period without canceled closing motive has been found'); + self::assertNotContains($periodA->getId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); + self::assertNotContains($periodC->getId(), $periodIdsFound, 'Period with child canceled closing motive has not been found'); + } + + public function dataProviderExclusionOnClosingMotive(): iterable + { + $this->setUp(); + + $cmA = new ClosingMotive(); + $cmA->setIsCanceledAccompanyingPeriod(true); + + $cmB = new ClosingMotive(); + $cmB->setIsCanceledAccompanyingPeriod(false); + + $cmChild = new ClosingMotive(); + $cmChild->setParent($cmA); + + $this->em->persist($cmA); + $this->em->persist($cmB); + $this->em->persist($cmChild); + + $periodA = new AccompanyingPeriod(); + $periodB = new AccompanyingPeriod(); + $periodC = new AccompanyingPeriod(); + + $periodA->setClosingMotive($cmA); + $periodB->setClosingMotive($cmB); + $periodC->setClosingMotive($cmChild); + + $this->em->persist($periodA); + $this->em->persist($periodB); + $this->em->persist($periodC); + + self::$entitiesToDelete[] = [ClosingMotive::class, $cmA]; + self::$entitiesToDelete[] = [ClosingMotive::class, $cmB]; + self::$entitiesToDelete[] = [ClosingMotive::class, $cmChild]; + + self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodA]; + self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodB]; + self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodC]; + + yield [$periodA, $periodB, $periodC]; + + $this->em->flush(); + $this->em->clear(); + } + +} From 29983cc2ad1657878a04adf0b1a0538ea82ce430 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Sep 2023 16:18:51 +0200 Subject: [PATCH 09/18] Work on test, but still fails --- .../AccompanyingCourseExportHelperTest.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php index bc7f413d7..a254a0d9c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php @@ -20,16 +20,13 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase private EntityManagerInterface $em; - private EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; protected function setUp(): void { self::bootKernel(); $this->em = self::$container->get(EntityManagerInterface::class); - $this->repository = self::$container->get($this->em->getRepository(AccompanyingPeriod::class)); - $this->accompanyingPeriodExportHelper = self::$container->get(AccompanyingCourseExportHelper::class); + $this->accompanyingCourseExportHelper = self::$container->get(AccompanyingCourseExportHelper::class); } public static function tearDownAfterClass(): void @@ -57,14 +54,19 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase AccompanyingPeriod $periodC // canceled (child cm of canceled cm) ): void { - $qb = $this->repository->createQueryBuilder('acp'); - $qb->select('acp.id')->from(AccompanyingPeriod::class, 'acp'); + $qb = $this->em->getRepository(AccompanyingPeriod::class)->createQueryBuilder('acp'); $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + $qb->select('acp.id'); + $periodIdsFound = $qb->getQuery()->getResult(); + $periodA = $this->em->find(AccompanyingPeriod::class, $periodA->getId()); + $periodB = $this->em->find(AccompanyingPeriod::class, $periodB->getId()); + $periodC = $this->em->find(AccompanyingPeriod::class, $periodC->getId()); + self::assertContains($periodB->getId(), $periodIdsFound, 'Period without canceled closing motive has been found'); - self::assertNotContains($periodA->getId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); + self::assertNotContains($periodA->getdId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); self::assertNotContains($periodC->getId(), $periodIdsFound, 'Period with child canceled closing motive has not been found'); } @@ -97,15 +99,15 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase $this->em->persist($periodB); $this->em->persist($periodC); + self::$entitiesToDelete[] = [ClosingMotive::class, $cmChild]; self::$entitiesToDelete[] = [ClosingMotive::class, $cmA]; self::$entitiesToDelete[] = [ClosingMotive::class, $cmB]; - self::$entitiesToDelete[] = [ClosingMotive::class, $cmChild]; self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodA]; self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodB]; self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodC]; - yield [$periodA, $periodB, $periodC]; + yield [$periodA, $periodB, $periodC, 'Verify that period with non-canceling closing motive is found']; $this->em->flush(); $this->em->clear(); From b38f5800d9a840d66605c9d4e25c00b2a414a18d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 29 Sep 2023 07:48:54 +0200 Subject: [PATCH 10/18] Adapt calendar exports to not take into account calendars of canceled accompanying periods --- .../Export/Export/CountCalendars.php | 12 +++++++++++- .../Export/Export/StatCalendarAvgDuration.php | 14 +++++++++++--- .../Export/Export/StatCalendarSumDuration.php | 13 ++++++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index e0391948e..3e96245c9 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\Export\Export; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -27,9 +28,15 @@ class CountCalendars implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; - public function __construct(CalendarRepository $calendarRepository) + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + + public function __construct( + CalendarRepository $calendarRepository, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper + ) { $this->calendarRepository = $calendarRepository; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -98,6 +105,9 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('COUNT(cal.id) AS export_result'); + $qb->join('cal.accompanyingPeriod', 'acp'); + + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index dcbfb695b..696bf02af 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\Export\Export; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -26,10 +27,15 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - CalendarRepository $calendarRepository + CalendarRepository $calendarRepository, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper + ) { $this->calendarRepository = $calendarRepository; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -92,8 +98,10 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { $qb = $this->calendarRepository->createQueryBuilder('cal'); - $qb - ->select('AVG(cal.endDate - cal.startDate) AS export_result'); + $qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); + $qb->join('cal.accompanyingPeriod', 'acp'); + + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 7f509a896..856e6996a 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\Export\Export; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; +use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -26,10 +27,14 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; + private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; + public function __construct( - CalendarRepository $calendarRepository + CalendarRepository $calendarRepository, + AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->calendarRepository = $calendarRepository; + $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -92,8 +97,10 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { $qb = $this->calendarRepository->createQueryBuilder('cal'); - $qb - ->select('SUM(cal.endDate - cal.startDate) AS export_result'); + $qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); + $qb->join('cal.accompanyingPeriod', 'acp'); + + $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } From 0c5b35926b9cde76b427ced44a1e36d9f2caf85f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 29 Sep 2023 07:52:50 +0200 Subject: [PATCH 11/18] php cs fixer and phpstan --- .../Export/LinkedToACP/CountActivity.php | 3 +-- .../Export/Export/CountCalendars.php | 3 +-- .../Export/Export/StatCalendarAvgDuration.php | 1 - .../Export/AccompanyingCourseExportHelper.php | 19 ++++++++++++++----- .../AccompanyingCourseExportHelperTest.php | 16 ++++++++++++++-- .../AccompanyingPeriod/ClosingMotive.php | 4 ++-- .../migrations/Version20230918115305.php | 7 +++++++ 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index b6615f8e5..81077be32 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -36,8 +36,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function __construct( EntityManagerInterface $em, AccompanyingCourseExportHelper $accompanyingCourseExportHelper - -) { + ) { $this->repository = $em->getRepository(Activity::class); $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 3e96245c9..77a2cfbc8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -33,8 +33,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function __construct( CalendarRepository $calendarRepository, AccompanyingCourseExportHelper $accompanyingCourseExportHelper - ) - { + ) { $this->calendarRepository = $calendarRepository; $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 696bf02af..3adfa1727 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -32,7 +32,6 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function __construct( CalendarRepository $calendarRepository, AccompanyingCourseExportHelper $accompanyingCourseExportHelper - ) { $this->calendarRepository = $calendarRepository; $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; diff --git a/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php b/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php index 3c49eb124..174548822 100644 --- a/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php +++ b/src/Bundle/ChillMainBundle/Export/AccompanyingCourseExportHelper.php @@ -1,5 +1,14 @@ leftJoin('acp.closingMotive', 'cm') ->andWhere( - $qb->expr()->orX( - $qb->expr()->eq('cm.isCanceledAccompanyingPeriod', 'false'), - $qb->expr()->isNull('acp.closingMotive') - ) - ); + $qb->expr()->orX( + $qb->expr()->eq('cm.isCanceledAccompanyingPeriod', 'false'), + $qb->expr()->isNull('acp.closingMotive') + ) + ); return $qb; } diff --git a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php index a254a0d9c..bb124c4bb 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php @@ -1,5 +1,14 @@ em->getRepository(AccompanyingPeriod::class)->createQueryBuilder('acp'); $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php index 0b5b66f77..cca307694 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php @@ -163,9 +163,9 @@ class ClosingMotive return $this->children->count() > 0; } - public function isFalseAccompanyingPeriod(): bool + public function isCanceledAccompanyingPeriod(): bool { - return $this->isFalseAccompanyingPeriod; + return $this->isCanceledAccompanyingPeriod; } public function removeChildren(ClosingMotive $child): ClosingMotive diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php b/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php index 684ff422b..3e3a3c643 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230918115305.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * Chill is a software for social workers + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + namespace Chill\Migrations\Person; use Doctrine\DBAL\Schema\Schema; From b0a7612329d43ab6c878016061518e02f0d669b9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 29 Sep 2023 08:51:14 +0200 Subject: [PATCH 12/18] make test easier to read --- .../Export/AccompanyingCourseExportHelperTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php index bb124c4bb..1e10e4834 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php @@ -62,8 +62,8 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase * @dataProvider dataProviderExclusionOnClosingMotive */ public function testExclusionOnClosingMotive( - AccompanyingPeriod $periodA, //canceled - AccompanyingPeriod $periodB, // not canceled + AccompanyingPeriod $periodA, //not canceled + AccompanyingPeriod $periodB, // canceled AccompanyingPeriod $periodC // canceled (child cm of canceled cm) ): void { $qb = $this->em->getRepository(AccompanyingPeriod::class)->createQueryBuilder('acp'); @@ -77,8 +77,8 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase $periodB = $this->em->find(AccompanyingPeriod::class, $periodB->getId()); $periodC = $this->em->find(AccompanyingPeriod::class, $periodC->getId()); - self::assertContains($periodB->getId(), $periodIdsFound, 'Period without canceled closing motive has been found'); - self::assertNotContains($periodA->getdId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); + self::assertContains($periodA->getId(), $periodIdsFound, 'Period without canceled closing motive has been found'); + self::assertNotContains($periodB->getdId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); self::assertNotContains($periodC->getId(), $periodIdsFound, 'Period with child canceled closing motive has not been found'); } @@ -87,13 +87,13 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase $this->setUp(); $cmA = new ClosingMotive(); - $cmA->setIsCanceledAccompanyingPeriod(true); + $cmA->setIsCanceledAccompanyingPeriod(false); $cmB = new ClosingMotive(); - $cmB->setIsCanceledAccompanyingPeriod(false); + $cmB->setIsCanceledAccompanyingPeriod(true); $cmChild = new ClosingMotive(); - $cmChild->setParent($cmA); + $cmChild->setParent($cmB); $this->em->persist($cmA); $this->em->persist($cmB); From af4bee4d509a695b1be2a60516a2f5c4de27f422 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 4 Oct 2023 10:43:37 +0200 Subject: [PATCH 13/18] correct test --- .../AccompanyingCourseExportHelperTest.php | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php index 1e10e4834..908c17f3f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php @@ -58,34 +58,27 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase $em->flush(); } - /** - * @dataProvider dataProviderExclusionOnClosingMotive - */ - public function testExclusionOnClosingMotive( - AccompanyingPeriod $periodA, //not canceled - AccompanyingPeriod $periodB, // canceled - AccompanyingPeriod $periodC // canceled (child cm of canceled cm) - ): void { + public function testExclusionOnClosingMotive(): void { + [$periodA, $periodB, $periodC] = $this->prepareData(); + $qb = $this->em->getRepository(AccompanyingPeriod::class)->createQueryBuilder('acp'); $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb->select('acp.id'); - $periodIdsFound = $qb->getQuery()->getResult(); + $periodIdsFound = array_map(fn ($el) => $el['id'], $qb->getQuery()->getResult()); $periodA = $this->em->find(AccompanyingPeriod::class, $periodA->getId()); $periodB = $this->em->find(AccompanyingPeriod::class, $periodB->getId()); $periodC = $this->em->find(AccompanyingPeriod::class, $periodC->getId()); self::assertContains($periodA->getId(), $periodIdsFound, 'Period without canceled closing motive has been found'); - self::assertNotContains($periodB->getdId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); + self::assertNotContains($periodB->getId(), $periodIdsFound, 'Period with canceled closing motive has not been found'); self::assertNotContains($periodC->getId(), $periodIdsFound, 'Period with child canceled closing motive has not been found'); } - public function dataProviderExclusionOnClosingMotive(): iterable + private function prepareData() { - $this->setUp(); - $cmA = new ClosingMotive(); $cmA->setIsCanceledAccompanyingPeriod(false); @@ -93,7 +86,7 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase $cmB->setIsCanceledAccompanyingPeriod(true); $cmChild = new ClosingMotive(); - $cmChild->setParent($cmB); + $cmB->addChildren($cmChild); $this->em->persist($cmA); $this->em->persist($cmB); @@ -119,10 +112,10 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodB]; self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodC]; - yield [$periodA, $periodB, $periodC, 'Verify that period with non-canceling closing motive is found']; - $this->em->flush(); $this->em->clear(); + + return [$periodA, $periodB, $periodC]; } } From dac48ea4e0471173b435a4fe96b151874968db6a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 4 Oct 2023 11:19:39 +0200 Subject: [PATCH 14/18] last processing of review remarks --- .../Export/Export/LinkedToACP/AvgActivityDuration.php | 6 +----- .../Export/Export/LinkedToACP/AvgActivityVisitDuration.php | 6 +----- .../Export/Export/LinkedToACP/CountActivity.php | 6 +----- .../Export/Export/LinkedToACP/ListActivity.php | 6 +----- .../Export/Export/LinkedToACP/SumActivityDuration.php | 6 +----- .../Export/Export/LinkedToACP/SumActivityVisitDuration.php | 6 +----- .../ChillCalendarBundle/Export/Export/CountCalendars.php | 6 +----- .../Export/Export/StatCalendarAvgDuration.php | 6 +----- .../Export/Export/StatCalendarSumDuration.php | 6 +----- src/Bundle/ChillMainBundle/config/services.yaml | 4 ---- src/Bundle/ChillMainBundle/config/services/export.yaml | 2 ++ .../Entity/AccompanyingPeriod/ClosingMotive.php | 3 +-- .../Export/Export/CountAccompanyingCourse.php | 6 +----- .../Export/Export/CountAccompanyingPeriodWork.php | 6 +----- .../ChillPersonBundle/Export/Export/CountEvaluation.php | 6 +----- .../Export/Export/CountPersonWithAccompanyingCourse.php | 6 +----- .../Export/Export/ListAccompanyingPeriod.php | 3 +-- .../Export/Export/ListAccompanyingPeriodWork.php | 6 +----- .../ChillPersonBundle/Export/Export/ListEvaluation.php | 6 +----- .../Export/Export/ListPersonHavingAccompanyingPeriod.php | 6 +----- .../Export/ListPersonWithAccompanyingPeriodDetails.php | 3 +-- .../Export/Export/StatAccompanyingCourseDuration.php | 6 +----- 22 files changed, 22 insertions(+), 95 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 7fe114401..352a67014 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -31,14 +31,10 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) {} @@ -113,7 +109,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index dc26dc926..4101408cc 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -31,14 +31,10 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac { protected EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -116,7 +112,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac ) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 81077be32..4926ecc33 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -31,14 +31,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) {} @@ -110,7 +106,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb->select('COUNT(DISTINCT activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 73d98e954..3f8d35e40 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -31,18 +31,14 @@ class ListActivity implements ListInterface, GroupedExportInterface private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( ListActivityHelper $helper, EntityManagerInterface $entityManager, TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->helper = $helper; $this->entityManager = $entityManager; $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -152,7 +148,7 @@ class ListActivity implements ListInterface, GroupedExportInterface ->addSelect('(SELECT AGGREGATE(acpScope.name) FROM ' . Scope::class . ' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames') ->addGroupBy('scopesNames'); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index f9bb4fa37..d9022f10e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -31,14 +31,10 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -116,7 +112,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 979974d36..81cbddc8e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -31,14 +31,10 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { protected EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(Activity::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -116,7 +112,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac ) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 77a2cfbc8..53be661a3 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -28,14 +28,10 @@ class CountCalendars implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( CalendarRepository $calendarRepository, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->calendarRepository = $calendarRepository; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -106,7 +102,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $qb->select('COUNT(cal.id) AS export_result'); $qb->join('cal.accompanyingPeriod', 'acp'); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 3adfa1727..de9086438 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -27,14 +27,10 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( CalendarRepository $calendarRepository, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->calendarRepository = $calendarRepository; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -100,7 +96,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface $qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); $qb->join('cal.accompanyingPeriod', 'acp'); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 856e6996a..0ef11f14d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -27,14 +27,10 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( CalendarRepository $calendarRepository, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->calendarRepository = $calendarRepository; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -100,7 +96,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface $qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); $qb->join('cal.accompanyingPeriod', 'acp'); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index 501a894e6..5976cb8b0 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -125,7 +125,3 @@ services: Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager: arguments: $vienEntityInfoProviders: !tagged_iterator chill_main.entity_info_provider - - Chill\MainBundle\Export\AccompanyingCourseExportHelper: - autoconfigure: true - autowire: true diff --git a/src/Bundle/ChillMainBundle/config/services/export.yaml b/src/Bundle/ChillMainBundle/config/services/export.yaml index b0dbf934d..6bae6f9c0 100644 --- a/src/Bundle/ChillMainBundle/config/services/export.yaml +++ b/src/Bundle/ChillMainBundle/config/services/export.yaml @@ -52,3 +52,5 @@ services: $exportManager: '@Chill\MainBundle\Export\ExportManager' tags: - { name: chill.export_formatter, alias: 'csv_pivoted_list' } + + Chill\MainBundle\Export\AccompanyingCourseExportHelper: ~ diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php index cca307694..5e65ba989 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php @@ -70,8 +70,7 @@ class ClosingMotive private ?ClosingMotive $parent = null; /** - * @var bool - * @ORM\Column(type="boolean") + * @ORM\Column(type="boolean", nullable=false, options={"default": false}) */ private bool $isCanceledAccompanyingPeriod = false; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 6fa24df4e..64a2bf53e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -30,14 +30,10 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { protected EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(AccompanyingPeriod::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -116,7 +112,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb->select('COUNT(DISTINCT acp.id) AS export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index a42c7eb66..236eea3cf 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -29,14 +29,10 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter { protected EntityManagerInterface $em; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->em = $em; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -117,7 +113,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter $qb->select('COUNT(DISTINCT acpw.id) as export_result'); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index b61d2b5b1..45ffaf1dc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -28,14 +28,10 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface { private EntityManagerInterface $entityManager; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->entityManager = $em; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -115,7 +111,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface ) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb->select('COUNT(DISTINCT workeval.id) AS export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index 63fa63f46..9a54095e7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -30,14 +30,10 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor { private EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(AccompanyingPeriod::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -116,7 +112,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor ) )->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb->select('COUNT(DISTINCT person.id) AS export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index c00e6e602..5595263d6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -53,7 +53,6 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter, private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper, - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) {} public function buildForm(FormBuilderInterface $builder) @@ -134,7 +133,7 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb ->addOrderBy('acp.openingDate') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 9e225a47c..b6a2b7221 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -101,8 +101,6 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac private UserHelper $userHelper; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $entityManager, DateTimeHelper $dateTimeHelper, @@ -116,7 +114,6 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac RollingDateConverterInterface $rollingDateConverter, AggregateStringHelper $aggregateStringHelper, SocialActionRepository $socialActionRepository, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->entityManager = $entityManager; $this->dateTimeHelper = $dateTimeHelper; @@ -130,7 +127,6 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac $this->rollingDateConverter = $rollingDateConverter; $this->aggregateStringHelper = $aggregateStringHelper; $this->socialActionRepository = $socialActionRepository; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -296,7 +292,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac ->setParameter('authorized_centers', $centers) ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date'])); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index 8a2d6752a..8f9f85ccc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -91,8 +91,6 @@ class ListEvaluation implements ListInterface, GroupedExportInterface private UserHelper $userHelper; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $entityManager, SocialIssueRender $socialIssueRender, @@ -105,7 +103,6 @@ class ListEvaluation implements ListInterface, GroupedExportInterface TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, AggregateStringHelper $aggregateStringHelper, RollingDateConverterInterface $rollingDateConverter, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->entityManager = $entityManager; $this->socialIssueRender = $socialIssueRender; @@ -118,7 +115,6 @@ class ListEvaluation implements ListInterface, GroupedExportInterface $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; $this->aggregateStringHelper = $aggregateStringHelper; $this->rollingDateConverter = $rollingDateConverter; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -275,7 +271,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface ->setParameter('authorized_centers', $centers) ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date'])); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php index 533f6cd60..26361858b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php @@ -49,18 +49,14 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf private ListPersonHelper $listPersonHelper; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( ExportAddressHelper $addressHelper, ListPersonHelper $listPersonHelper, EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->addressHelper = $addressHelper; $this->listPersonHelper = $listPersonHelper; $this->entityManager = $em; - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder) @@ -195,7 +191,7 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf $this->listPersonHelper->addSelect($qb, $fields, $data['address_date']); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb ->addOrderBy('person.lastName') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php index 0a1819884..958d52111 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php @@ -51,7 +51,6 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper, private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter, - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) {} public function buildForm(FormBuilderInterface $builder) @@ -135,7 +134,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte $this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date'])); $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date'])); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); $qb ->addOrderBy('person.lastName') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index e558163dc..ab12310c2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -32,14 +32,10 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn { private EntityRepository $repository; - private AccompanyingCourseExportHelper $accompanyingCourseExportHelper; - public function __construct( EntityManagerInterface $em, - AccompanyingCourseExportHelper $accompanyingCourseExportHelper ) { $this->repository = $em->getRepository(AccompanyingPeriod::class); - $this->accompanyingCourseExportHelper = $accompanyingCourseExportHelper; } public function buildForm(FormBuilderInterface $builder): void @@ -147,7 +143,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT) ->setParameter('authorized_centers', $centers); - $this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; } From 9f476dddaf26387c450396b5634c2aed54350cbe Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 4 Oct 2023 11:20:20 +0200 Subject: [PATCH 15/18] php cs fixer --- .../Tests/Export/AccompanyingCourseExportHelperTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php index 908c17f3f..62af515ec 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/AccompanyingCourseExportHelperTest.php @@ -58,7 +58,8 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase $em->flush(); } - public function testExclusionOnClosingMotive(): void { + public function testExclusionOnClosingMotive(): void + { [$periodA, $periodB, $periodC] = $this->prepareData(); $qb = $this->em->getRepository(AccompanyingPeriod::class)->createQueryBuilder('acp'); From 935210aa1dcb7222437c9b27ad959ff74be8ad62 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 4 Oct 2023 11:54:29 +0200 Subject: [PATCH 16/18] use translation --- .../Templating/Entity/ClosingMotiveRender.php | 5 +++-- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php index b574382ad..bdff04a22 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Templating\Entity\BoxUtilsChillEntityRenderTrait; use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; +use Symfony\Contracts\Translation\TranslatorInterface; /** * Render closing motive. @@ -32,7 +33,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface */ private $translatableStringHelper; - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) { $this->translatableStringHelper = $translatableStringHelper; } @@ -62,7 +63,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface private function renderStringRecursive(ClosingMotive $motive, string $existing, array $options) { $newExisting = $this->translatableStringHelper->localize($motive->getName()); - $isCancled = $motive->getIsCanceledAccompanyingPeriod() ? '( Annule le parcours )' : ''; + $isCancled = $motive->getIsCanceledAccompanyingPeriod() ? $this->translator->trans('( Canceled period )') : ''; if ($motive->hasParent()) { if ('' !== $existing) { diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 2496a4555..aea766902 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -351,6 +351,7 @@ Period closed!: Parcours clôturé! Pediod closing form is not valide: Le formulaire de fermeture n'est pas valide Consider canceled: Permet de considérer les parcours comme annulés Canceled parcours help: Si coché, les parcours avec ce motif de cloture seront considérés comme annulés et ne seront pas pris en compte pour les statistiques. La modification se reflétera pour tous les motifs enfants +( Canceled period ): ( annulé ) #widget From 9bbddd84056c8fd80088bc59be4e9723a114d2cc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 4 Oct 2023 12:09:12 +0200 Subject: [PATCH 17/18] add changie --- .changes/unreleased/Feature-20231004-120857.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Feature-20231004-120857.yaml diff --git a/.changes/unreleased/Feature-20231004-120857.yaml b/.changes/unreleased/Feature-20231004-120857.yaml new file mode 100644 index 000000000..b3cff5e82 --- /dev/null +++ b/.changes/unreleased/Feature-20231004-120857.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Allow closing motives to be identified as 'canceling the accompanying period' + + don't take canceled accompanying periods into account +time: 2023-10-04T12:08:57.586865276+02:00 +custom: + Issue: "146" From ada28265ee4d3dea2aabb4c757d5dfe618bc4fbf Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 4 Oct 2023 14:26:06 +0200 Subject: [PATCH 18/18] change join to leftjoin --- src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 53be661a3..2b0488b61 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -100,7 +100,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('COUNT(cal.id) AS export_result'); - $qb->join('cal.accompanyingPeriod', 'acp'); + $qb->leftJoin('cal.accompanyingPeriod', 'acp'); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);