diff --git a/.changes/unreleased/Fixed-20251230-125728.yaml b/.changes/unreleased/Fixed-20251230-125728.yaml new file mode 100644 index 000000000..2ee7b761a --- /dev/null +++ b/.changes/unreleased/Fixed-20251230-125728.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix export group by center for persons without a center in CenterAggregator.php +time: 2025-12-30T12:57:28.773521385+01:00 +custom: + Issue: "477" + SchemaChange: No schema change diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php index 6f4082d46..bf9901207 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php @@ -19,6 +19,7 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final readonly class CenterAggregator implements AggregatorInterface { @@ -27,6 +28,7 @@ final readonly class CenterAggregator implements AggregatorInterface public function __construct( private CenterRepositoryInterface $centerRepository, private RollingDateConverterInterface $rollingDateConverter, + private TranslatorInterface $translator, ) {} public function buildForm(FormBuilderInterface $builder): void @@ -62,7 +64,7 @@ final readonly class CenterAggregator implements AggregatorInterface { return function (int|string|null $value) { if (null === $value || '' === $value) { - return ''; + return $this->translator->trans('person.export.aggregator.by_center.no_center'); } if ('_header' === $value) { @@ -94,15 +96,18 @@ final readonly class CenterAggregator implements AggregatorInterface $atDate = 'pers_center_agg_at_date'; $qb->leftJoin('person.centerHistory', $alias); - $qb - ->andWhere( - $qb->expr()->lte($alias.'.startDate', ':'.$atDate), - )->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull($alias.'.endDate'), - $qb->expr()->gt($alias.'.endDate', ':'.$atDate) + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->isNull($alias.'.id'), + $qb->expr()->andX( + $qb->expr()->lte($alias.'.startDate', ':'.$atDate), + $qb->expr()->orX( + $qb->expr()->isNull($alias.'.endDate'), + $qb->expr()->gt($alias.'.endDate', ':'.$atDate) + ) ) - ); + ) + ); $qb->setParameter($atDate, $this->rollingDateConverter->convert($data['at_date'])); $qb->addSelect("IDENTITY({$alias}.center) AS ".self::COLUMN_NAME); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 88b12f7bd..b62908dc0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -103,6 +103,11 @@ Employment status: Situation professionelle Administrative status: Situation administrative person: + # trans key according to new conventions + export: + aggregator: + by_center: + no_center: Sans territoire Identifiers: Identifiants