Feature: Apply rolling date on StepAggregator

This commit is contained in:
Julien Fastré 2022-11-07 21:11:20 +01:00
parent 50db96ffbc
commit 48da6d0a92

View File

@ -12,10 +12,11 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators; namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use DateTime;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,11 +28,15 @@ final class StepAggregator implements AggregatorInterface
private const P = 'acp_step_agg_date'; private const P = 'acp_step_agg_date';
private RollingDateConverterInterface $rollingDateConverter;
private TranslatorInterface $translator; private TranslatorInterface $translator;
public function __construct( public function __construct(
RollingDateConverterInterface $rollingDateConverter,
TranslatorInterface $translator TranslatorInterface $translator
) { ) {
$this->rollingDateConverter = $rollingDateConverter;
$this->translator = $translator; $this->translator = $translator;
} }
@ -60,7 +65,7 @@ final class StepAggregator implements AggregatorInterface
) )
) )
) )
->setParameter(self::P, $data['on_date']) ->setParameter(self::P, $this->rollingDateConverter->convert($data['on_date']))
->addGroupBy('step_aggregator'); ->addGroupBy('step_aggregator');
} }
@ -71,8 +76,8 @@ final class StepAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
$builder->add('on_date', ChillDateType::class, [ $builder->add('on_date', PickRollingDateType::class, [
'data' => new DateTime(), 'data' => new RollingDate(RollingDate::T_TODAY),
]); ]);
} }