Merge branch 'testing' of gitlab.com:Chill-Projet/chill-bundles into testing

This commit is contained in:
2022-11-16 18:41:42 +01:00
35 changed files with 733 additions and 280 deletions

View File

@@ -14,12 +14,13 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\GeographicalUnitLayer;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\GeographicalUnitLayerRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -30,14 +31,18 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
{
private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository;
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository,
TranslatableStringHelperInterface $translatableStringHelper
TranslatableStringHelperInterface $translatableStringHelper,
RollingDateConverterInterface $rollingDateConverter
) {
$this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -59,8 +64,6 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
)
);
$qb->setParameter('acp_geog_aggregator_date', $data['date_calc']);
// link between location history and person
$qb->leftJoin(
PersonHouseholdAddress::class,
@@ -76,7 +79,10 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
)
);
$qb->setParameter('acp_geog_aggregator_date', $data['date_calc']);
$qb->setParameter(
'acp_geog_aggregator_date',
$this->rollingDateConverter->convert($data['date_calc'])
);
// we finally find an address
$qb->leftJoin(
@@ -112,11 +118,10 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('date_calc', ChillDateType::class, [
->add('date_calc', PickRollingDateType::class, [
'label' => 'Compute geographical location at date',
'required' => true,
'data' => new DateTimeImmutable('today'),
'input' => 'datetime_immutable',
'data' => new RollingDate(RollingDate::T_TODAY),
])
->add('level', EntityType::class, [
'label' => 'Geographical layer',

View File

@@ -12,11 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -26,16 +27,20 @@ final class ReferrerAggregator implements AggregatorInterface
private const P = 'acp_ref_agg_date';
private RollingDateConverterInterface $rollingDateConverter;
private UserRender $userRender;
private UserRepository $userRepository;
public function __construct(
UserRepository $userRepository,
UserRender $userRender
UserRender $userRender,
RollingDateConverterInterface $rollingDateConverter
) {
$this->userRepository = $userRepository;
$this->userRender = $userRender;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -61,7 +66,10 @@ final class ReferrerAggregator implements AggregatorInterface
)
)
)
->setParameter(self::P, $data['date_calc']);
->setParameter(
self::P,
$this->rollingDateConverter->convert($data['date_calc'])
);
}
public function applyOn(): string
@@ -72,9 +80,8 @@ final class ReferrerAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('date_calc', ChillDateType::class, [
'input' => 'datetime_immutable',
'data' => new DateTimeImmutable('now'),
->add('date_calc', PickRollingDateType::class, [
'data' => new RollingDate(RollingDate::T_TODAY),
'label' => 'export.aggregator.course.by_referrer.Computation date for referrer',
'required' => true,
]);

View File

@@ -12,11 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
@@ -25,16 +26,20 @@ class ReferrerScopeAggregator implements AggregatorInterface
{
private const SCOPE_KEY = 'acp_agg_refscope_user_history_ref_scope_name';
private RollingDateConverterInterface $rollingDateConverter;
private ScopeRepositoryInterface $scopeRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
ScopeRepositoryInterface $scopeRepository,
TranslatableStringHelperInterface $translatableStringHelper
TranslatableStringHelperInterface $translatableStringHelper,
RollingDateConverterInterface $rollingDateConverter
) {
$this->scopeRepository = $scopeRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -64,7 +69,10 @@ class ReferrerScopeAggregator implements AggregatorInterface
)
)
)
->setParameter($dateCalc, $data['date_calc']);
->setParameter(
$dateCalc,
$this->rollingDateConverter->convert($data['date_calc'])
);
// add groups
$qb
@@ -79,9 +87,8 @@ class ReferrerScopeAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('date_calc', ChillDateType::class, [
'input' => 'datetime_immutable',
'data' => new DateTimeImmutable('now'),
$builder->add('date_calc', PickRollingDateType::class, [
'data' => new RollingDate(RollingDate::T_TODAY),
'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer',
'required' => true,
]);

View File

@@ -12,10 +12,10 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
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\Export\Declarations;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -24,12 +24,16 @@ use function in_array;
class ChildrenNumberAggregator implements AggregatorInterface
{
private RollingDateConverterInterface $rollingDateConverter;
private TranslatorInterface $translator;
public function __construct(
TranslatorInterface $translator
TranslatorInterface $translator,
RollingDateConverterInterface $rollingDateConverter
) {
$this->translator = $translator;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -55,7 +59,10 @@ class ChildrenNumberAggregator implements AggregatorInterface
->addSelect('composition_children.numberOfChildren AS childrennumber_aggregator')
->addGroupBy('childrennumber_aggregator');
$qb->setParameter('ondate_composition_children', $data['on_date'], Types::DATE_MUTABLE);
$qb->setParameter(
'ondate_composition_children',
$this->rollingDateConverter->convert($data['on_date'])
);
}
public function applyOn(): string
@@ -65,8 +72,8 @@ class ChildrenNumberAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('on_date', ChillDateType::class, [
'data' => new DateTime('now'),
$builder->add('on_date', PickRollingDateType::class, [
'data' => new RollingDate(RollingDate::T_TODAY),
]);
}

View File

@@ -12,12 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
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\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -25,16 +25,20 @@ use function in_array;
class CompositionAggregator implements AggregatorInterface
{
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringHelper $translatableStringHelper;
private HouseholdCompositionTypeRepository $typeRepository;
public function __construct(
HouseholdCompositionTypeRepository $typeRepository,
TranslatableStringHelper $translatableStringHelper
TranslatableStringHelper $translatableStringHelper,
RollingDateConverterInterface $rollingDateConverter
) {
$this->typeRepository = $typeRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -60,7 +64,10 @@ class CompositionAggregator implements AggregatorInterface
->addSelect('IDENTITY(composition_type.householdCompositionType) AS composition_aggregator')
->addGroupBy('composition_aggregator');
$qb->setParameter('ondate_composition_type', $data['on_date'], Types::DATE_MUTABLE);
$qb->setParameter(
'ondate_composition_type',
$this->rollingDateConverter->convert($data['on_date'])
);
}
public function applyOn(): string
@@ -70,8 +77,8 @@ class CompositionAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('on_date', ChillDateType::class, [
'data' => new DateTime('now'),
$builder->add('on_date', PickRollingDateType::class, [
'data' => new RollingDate(RollingDate::T_TODAY),
]);
}

View File

@@ -12,12 +12,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
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\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Household\HouseholdComposition;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepositoryInterface;
use DateTimeImmutable;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -28,12 +29,18 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository;
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, TranslatableStringHelperInterface $translatableStringHelper)
{
public function __construct(
RollingDateConverterInterface $rollingDateConverter,
HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->householdCompositionTypeRepository = $householdCompositionTypeRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -71,7 +78,10 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
)
)
->addSelect("IDENTITY({$p}_compo.householdCompositionType) AS {$p}_select")
->setParameter("{$p}_date", $data['date_calc'])
->setParameter(
"{$p}_date",
$this->rollingDateConverter->convert($data['date_calc'])
)
->addGroupBy("{$p}_select");
}
@@ -82,10 +92,9 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('date_calc', ChillDateType::class, [
$builder->add('date_calc', PickRollingDateType::class, [
'label' => 'export.aggregator.person.by_household_composition.Calc date',
'input_format' => 'datetime_immutable',
'data' => new DateTimeImmutable('now'),
'data' => new RollingDate(RollingDate::T_TODAY),
]);
}

View File

@@ -13,11 +13,12 @@ namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Entity\GeographicalUnitLayer;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\GeographicalUnitLayerRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -27,14 +28,18 @@ class GeographicalUnitAggregator implements AggregatorInterface
{
private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository;
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository,
TranslatableStringHelperInterface $translatableStringHelper
TranslatableStringHelperInterface $translatableStringHelper,
RollingDateConverterInterface $rollingDateConverter
) {
$this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -66,7 +71,10 @@ class GeographicalUnitAggregator implements AggregatorInterface
$qb->expr()->in('person_geog_agg_geog_unit.layer', ':person_geog_agg_layers')
)
)
->setParameter('person_geog_agg_date', $data['date_calc'])
->setParameter(
'person_geog_agg_date',
$this->rollingDateConverter->convert($data['date_calc'])
)
->setParameter('person_geog_agg_layers', $data['level'])
->addSelect('person_geog_agg_geog_unit.unitName AS geog_unit_name')
->addSelect('person_geog_agg_geog_unit.unitRefId AS geog_unit_key')
@@ -82,11 +90,10 @@ class GeographicalUnitAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('date_calc', ChillDateType::class, [
->add('date_calc', PickRollingDateType::class, [
'label' => 'Address valid at this date',
'required' => true,
'data' => new DateTimeImmutable('today'),
'input' => 'datetime_immutable',
'data' => new RollingDate(RollingDate::T_TODAY),
])
->add('level', EntityType::class, [
'label' => 'Geographical layer',

View File

@@ -13,12 +13,13 @@ namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
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\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\Household\PositionRepository;
use DateTime;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -30,6 +31,8 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
{
private PositionRepository $positionRepository;
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringHelper $translatableStringHelper;
private TranslatorInterface $translator;
@@ -37,11 +40,13 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
public function __construct(
TranslatorInterface $translator,
TranslatableStringHelper $translatableStringHelper,
PositionRepository $positionRepository
PositionRepository $positionRepository,
RollingDateConverterInterface $rollingDateConverter
) {
$this->translator = $translator;
$this->positionRepository = $positionRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -67,7 +72,10 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
)
));
$qb->setParameter('date', $data['date_position']);
$qb->setParameter(
'date',
$this->rollingDateConverter->convert($data['date_position'])
);
$qb->addSelect('IDENTITY(householdmember.position) AS household_position_aggregator');
$qb->addGroupBy('household_position_aggregator');
@@ -80,9 +88,9 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('date_position', ChillDateType::class, [
$builder->add('date_position', PickRollingDateType::class, [
'label' => 'Household position in relation to this date',
'data' => new DateTime(),
'data' => new RollingDate(RollingDate::T_TODAY),
]);
}