[export] create a parameter that will force to skip the filtering by center (ACL) when generating an export

This commit is contained in:
2023-10-19 17:19:28 +02:00
parent c7bd60a106
commit a6e930958b
47 changed files with 1145 additions and 407 deletions

View File

@@ -23,16 +23,20 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(AccompanyingPeriod::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void
@@ -102,15 +106,19 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
->andWhere('acp.step != :count_acp_step')
->leftJoin('acp.participations', 'acppart')
->leftJoin('acppart.person', 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT);
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -22,11 +22,19 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInterface
{
public function __construct(protected EntityManagerInterface $em) {}
private readonly bool $filterStatsByCenters;
public function __construct(
protected EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void
{
@@ -95,15 +103,19 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
->from(AccompanyingPeriod\AccompanyingPeriodWork::class, 'acpw')
->join('acpw.accompanyingPeriod', 'acp')
->join('acp.participations', 'acppart')
->join('acppart.person', 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->join('acppart.person', 'person');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
$qb->select('COUNT(DISTINCT acpw.id) as export_result');

View File

@@ -21,11 +21,19 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountEvaluation implements ExportInterface, GroupedExportInterface
{
public function __construct(private readonly EntityManagerInterface $entityManager) {}
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly EntityManagerInterface $entityManager,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
@@ -92,15 +100,19 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
->join('workeval.accompanyingPeriodWork', 'acpw')
->join('acpw.accompanyingPeriod', 'acp')
->join('acp.participations', 'acppart')
->join('acppart.person', 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->join('acppart.person', 'person');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -23,13 +23,21 @@ use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountHousehold implements ExportInterface, GroupedExportInterface
{
private const TR_PREFIX = 'export.export.nb_household_with_course.';
private readonly bool $filterStatsByCenters;
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly RollingDateConverterInterface $rollingDateConverter) {}
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly RollingDateConverterInterface $rollingDateConverter,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -112,21 +120,25 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
->join('person.accompanyingPeriodParticipations', 'acppart')
->join('acppart.accompanyingPeriod', 'acp')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
->setParameter('authorized_centers', $centers)
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
$qb
->select('COUNT(DISTINCT household.id) AS household_export_result')
->addSelect('COUNT(DISTINCT acp.id) AS acp_export_result');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
->setParameter('authorized_centers', $centers);
}
return $qb;
}

View File

@@ -20,11 +20,19 @@ use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountPerson implements ExportInterface, GroupedExportInterface
{
public function __construct(protected PersonRepository $personRepository) {}
private readonly bool $filterStatsByCenters;
public function __construct(
protected PersonRepository $personRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -94,13 +102,17 @@ class CountPerson implements ExportInterface, GroupedExportInterface
$qb = $this->personRepository->createQueryBuilder('person');
$qb->select('COUNT(DISTINCT person.id) AS export_result')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
$qb->select('COUNT(DISTINCT person.id) AS export_result');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
return $qb;
}

View File

@@ -22,16 +22,20 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExportInterface
{
private readonly EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(AccompanyingPeriod::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
@@ -105,11 +109,13 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
$qb->join('acppart.person', 'person');
}
$qb->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
if ($this->filterStatsByCenters) {
$qb->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -26,15 +26,21 @@ use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
{
private bool $filterStatsByCenters;
public function __construct(
private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter,
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
) {}
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -102,16 +108,20 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
$qb
->from(AccompanyingPeriod::class, 'acp')
->andWhere('acp.step != :list_acp_step')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT);
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));

View File

@@ -44,6 +44,7 @@ use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterface
@@ -78,6 +79,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
'updatedBy',
];
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly DateTimeHelper $dateTimeHelper,
@@ -90,8 +93,11 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
private readonly SocialActionRender $socialActionRender,
private readonly RollingDateConverterInterface $rollingDateConverter,
private readonly AggregateStringHelper $aggregateStringHelper,
private readonly SocialActionRepository $socialActionRepository
) {}
private readonly SocialActionRepository $socialActionRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -214,15 +220,19 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
// get participants at the given date
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers)
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -37,6 +37,7 @@ use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ListEvaluation implements ListInterface, GroupedExportInterface
@@ -68,7 +69,24 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
'updatedBy',
];
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly SocialIssueRender $socialIssueRender, private readonly SocialIssueRepository $socialIssueRepository, private readonly SocialActionRender $socialActionRender, private readonly SocialActionRepository $socialActionRepository, private readonly UserHelper $userHelper, private readonly LabelPersonHelper $personHelper, private readonly DateTimeHelper $dateTimeHelper, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private readonly AggregateStringHelper $aggregateStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) {}
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly SocialIssueRender $socialIssueRender,
private readonly SocialIssueRepository $socialIssueRepository,
private readonly SocialActionRender $socialActionRender,
private readonly SocialActionRepository $socialActionRepository,
private readonly UserHelper $userHelper,
private readonly LabelPersonHelper $personHelper,
private readonly DateTimeHelper $dateTimeHelper,
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
private readonly AggregateStringHelper $aggregateStringHelper,
private readonly RollingDateConverterInterface $rollingDateConverter,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -190,15 +208,19 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
// get participants at the given date
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers)
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -29,6 +29,7 @@ use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
@@ -42,14 +43,18 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
'compositionComment',
'compositionType',
];
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly ExportAddressHelper $addressHelper,
private readonly AggregateStringHelper $aggregateStringHelper,
private readonly EntityManagerInterface $entityManager,
private readonly RollingDateConverterInterface $rollingDateConverter,
private readonly TranslatableStringExportLabelHelper $translatableStringHelper
) {}
private readonly TranslatableStringExportLabelHelper $translatableStringHelper,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -138,16 +143,20 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
->join('person.accompanyingPeriodParticipations', 'acppart')
->join('acppart.accompanyingPeriod', 'acp')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
->setParameter('authorized_centers', $centers)
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
->setParameter('authorized_centers', $centers);
}
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));

View File

@@ -29,6 +29,7 @@ use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback;
@@ -40,14 +41,18 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
class ListPerson implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
{
private array $slugs = [];
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly ExportAddressHelper $addressHelper,
private readonly CustomFieldProvider $customFieldProvider,
private readonly ListPersonHelper $listPersonHelper,
private readonly EntityManagerInterface $entityManager,
private readonly TranslatableStringHelper $translatableStringHelper
) {}
private readonly TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -184,16 +189,18 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields have been checked');
}
$qb = $this->entityManager->createQueryBuilder();
$qb = $this->entityManager->createQueryBuilder()
->from(Person::class, 'person');
$qb
->from(Person::class, 'person')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.Person\PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.Person\PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
$fields = $data['fields'];

View File

@@ -17,7 +17,9 @@ use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Export\ListInterface;
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\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
@@ -27,6 +29,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback;
@@ -37,9 +40,19 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
*
* Details of the accompanying period are not included
*/
class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
final readonly class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
{
public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly ListPersonHelper $listPersonHelper, private readonly EntityManagerInterface $entityManager) {}
private bool $filterStatsByCenters;
public function __construct(
private ExportAddressHelper $addressHelper,
private ListPersonHelper $listPersonHelper,
private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -69,10 +82,9 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
])],
]);
$builder->add('address_date', ChillDateType::class, [
$builder->add('address_date_rolling', PickRollingDateType::class, [
'label' => 'Data valid at this date',
'help' => 'Data regarding center, addresses, and so on will be computed at this date',
'input' => 'datetime_immutable',
]);
}
@@ -80,7 +92,7 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
{
$choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS);
return ['fields' => array_values($choices), 'address_date' => new \DateTimeImmutable()];
return ['fields' => array_values($choices), 'address_date_rolling' => new RollingDate(RollingDate::T_TODAY)];
}
public function getAllowedFormattersTypes()
@@ -162,16 +174,20 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf
$qb->from(Person::class, 'person')
->join('person.accompanyingPeriodParticipations', 'acppart')
->join('acppart.accompanyingPeriod', 'acp')
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"))
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
}
$fields = $data['fields'];
$this->listPersonHelper->addSelect($qb, $fields, $data['address_date']);
$this->listPersonHelper->addSelect($qb, $fields, $this->rollingDateConverter->convert($data['address_date_rolling']));
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -28,6 +28,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
/**
@@ -35,12 +36,17 @@ use Symfony\Component\Form\FormBuilderInterface;
*/
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
{
private bool $filterStatsByCenters;
public function __construct(
private ListPersonHelper $listPersonHelper,
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter,
) {}
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -114,12 +120,16 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
$qb->from(Person::class, 'person')
->join('person.accompanyingPeriodParticipations', 'acppart')
->join('acppart.accompanyingPeriod', 'acp')
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"))
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
}
$this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));

View File

@@ -15,7 +15,9 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
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\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations;
@@ -24,28 +26,34 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface
final readonly class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface
{
private readonly EntityRepository $repository;
private bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
private RollingDateConverterInterface $rollingDateConverter,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(AccompanyingPeriod::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void
{
$builder->add('closingdate', ChillDateType::class, [
$builder->add('closingdate_rolling', PickRollingDateType::class, [
'label' => 'Closingdate to apply',
]);
}
public function getFormDefaultData(): array
{
return ['closingdate' => new \DateTime('now')];
return ['closingdate_rolling' => new RollingDate(RollingDate::T_TODAY)];
}
public function getAllowedFormattersTypes(): array
@@ -118,20 +126,24 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
->addSelect('COUNT(DISTINCT acppart.id) AS count_acppart_export_result')
->addSelect('COUNT(DISTINCT person.id) AS count_pers_export_result')
->addSelect('COUNT(DISTINCT acp.id) AS count_acp_export_result')
->setParameter('force_closingDate', $data['closingdate'])
->setParameter('force_closingDate', $this->rollingDateConverter->convert($data['closingdate_rolling']))
->leftJoin('acp.participations', 'acppart')
->leftJoin('acppart.person', 'person')
->andWhere('acp.step != :count_acp_step')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT);
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -14,6 +14,7 @@ namespace Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\CountAccompanyingCourse;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -22,18 +23,17 @@ use Chill\PersonBundle\Export\Export\CountAccompanyingCourse;
*/
final class CountAccompanyingCourseTest extends AbstractExportTest
{
private CountAccompanyingCourse $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.person.export.count_accompanyingcourse');
}
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
yield new CountAccompanyingCourse($em, $this->getParameters(true));
yield new CountAccompanyingCourse($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -14,6 +14,7 @@ namespace Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\CountAccompanyingPeriodWork;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -33,7 +34,10 @@ final class CountAccompanyingPeriodWorkTest extends AbstractExportTest
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
yield new CountAccompanyingPeriodWork($em, $this->getParameters(true));
yield new CountAccompanyingPeriodWork($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Export\CountPerson;
use Chill\PersonBundle\Repository\PersonRepository;
/**
* Test CountPerson export.
@@ -23,18 +24,17 @@ use Chill\PersonBundle\Export\Export\CountPerson;
*/
final class CountPersonTest extends AbstractExportTest
{
private ?object $export = null;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get(CountPerson::class);
}
public function getExport()
{
return $this->export;
$personRepository = self::$container->get(PersonRepository::class);
yield new CountPerson($personRepository, $this->getParameters(true));
yield new CountPerson($personRepository, $this->getParameters(false));
}
public function getFormData()

View File

@@ -0,0 +1,48 @@
<?php
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\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\CountPersonWithAccompanyingCourse;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class CountPersonWithAccompanyingCourseTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$em = self::$container->get(EntityManagerInterface::class);
yield new CountPersonWithAccompanyingCourse($em, $this->getParameters(true));
yield new CountPersonWithAccompanyingCourse($em, $this->getParameters(false));
}
public function getFormData()
{
return [[]];
}
public function getModifiersCombination()
{
return [[Declarations::ACP_TYPE]];
}
}

View File

@@ -11,43 +11,51 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriod;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ListAccompanyingPeriodTest extends KernelTestCase
class ListAccompanyingPeriodTest extends AbstractExportTest
{
private ListAccompanyingPeriod $listAccompanyingPeriod;
private readonly ListAccompanyingPeriod $listAccompanyingPeriod;
private CenterRepositoryInterface $centerRepository;
private readonly CenterRepositoryInterface $centerRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->listAccompanyingPeriod = self::$container->get(ListAccompanyingPeriod::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function testQuery(): void
public function getExport()
{
$centers = $this->centerRepository->findAll();
$em = self::$container->get(EntityManagerInterface::class);
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
$query = $this->listAccompanyingPeriod->initiateQuery([], array_map(fn (Center $c) => ['center' => $c], $centers), $exportOpts = ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
yield new ListAccompanyingPeriod($em, $rollingDateConverter, $listAccompanyingPeriodHelper, $this->getParameters(true));
yield new ListAccompanyingPeriod($em, $rollingDateConverter, $listAccompanyingPeriodHelper, $this->getParameters(false));
}
$query->setMaxResults(1);
public function getFormData()
{
return [
['calc_date' => new RollingDate(RollingDate::T_TODAY)],
];
}
$actual = $query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY);
self::assertIsArray($actual);
public function getModifiersCombination()
{
return [[Declarations::ACP_TYPE]];
}
}

View File

@@ -11,40 +11,93 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
use Chill\MainBundle\Export\Helper\DateTimeHelper;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\Helper\UserHelper;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWork;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ListAccompanyingPeriodWorkTest extends KernelTestCase
class ListAccompanyingPeriodWorkTest extends AbstractExportTest
{
private ListAccompanyingPeriodWork $listAccompanyingPeriodWork;
private CenterRepositoryInterface $centerRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->listAccompanyingPeriodWork = self::$container->get(ListAccompanyingPeriodWork::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function testQuery(): void
public function getExport()
{
$centers = $this->centerRepository->findAll();
$entityManager = self::$container->get(EntityManagerInterface::class);
$dateTimeHelper = self::$container->get(DateTimeHelper::class);
$userHelper = self::$container->get(UserHelper::class);
$personHelper = self::$container->get(LabelPersonHelper::class);
$thirdPartyHelper = self::$container->get(LabelThirdPartyHelper::class);
$translatableStringExportLabelHelper = self::$container->get(TranslatableStringExportLabelHelper::class);
$socialIssueRender = self::$container->get(SocialIssueRender::class);
$socialIssueRepository = self::$container->get(SocialIssueRepository::class);
$socialActionRender = self::$container->get(SocialActionRender::class);
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
$socialActionRepository = self::$container->get(SocialActionRepository::class);
$query = $this->listAccompanyingPeriodWork->initiateQuery([], array_map(fn (Center $c) => ['center' => $c], $centers), ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
$query->setMaxResults(1);
yield new ListAccompanyingPeriodWork(
$entityManager,
$dateTimeHelper,
$userHelper,
$personHelper,
$thirdPartyHelper,
$translatableStringExportLabelHelper,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$rollingDateConverter,
$aggregateStringHelper,
$socialActionRepository,
$this->getParameters(true),
);
self::assertIsArray($query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY));
yield new ListAccompanyingPeriodWork(
$entityManager,
$dateTimeHelper,
$userHelper,
$personHelper,
$thirdPartyHelper,
$translatableStringExportLabelHelper,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$rollingDateConverter,
$aggregateStringHelper,
$socialActionRepository,
$this->getParameters(false),
);
}
public function getFormData()
{
return [
['calc_date' => new RollingDate(RollingDate::T_TODAY)],
];
}
public function getModifiersCombination()
{
return [[Declarations::ACP_TYPE]];
}
}

View File

@@ -12,18 +12,30 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
use Chill\MainBundle\Export\Helper\DateTimeHelper;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\Helper\UserHelper;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListEvaluation;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ListEvaluationTest extends KernelTestCase
class ListEvaluationTest extends AbstractExportTest
{
private ListEvaluation $listEvaluation;
@@ -38,6 +50,61 @@ class ListEvaluationTest extends KernelTestCase
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function getExport()
{
$entityManager = self::$container->get(EntityManagerInterface::class);
$dateTimeHelper = self::$container->get(DateTimeHelper::class);
$userHelper = self::$container->get(UserHelper::class);
$personHelper = self::$container->get(LabelPersonHelper::class);
$translatableStringExportLabelHelper = self::$container->get(TranslatableStringExportLabelHelper::class);
$socialIssueRender = self::$container->get(SocialIssueRender::class);
$socialIssueRepository = self::$container->get(SocialIssueRepository::class);
$socialActionRender = self::$container->get(SocialActionRender::class);
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
$socialActionRepository = self::$container->get(SocialActionRepository::class);
yield new ListEvaluation(
$entityManager,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$socialActionRepository,
$userHelper,
$personHelper,
$dateTimeHelper,
$translatableStringExportLabelHelper,
$aggregateStringHelper,
$rollingDateConverter,
$this->getParameters(true),
);
yield new ListEvaluation(
$entityManager,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$socialActionRepository,
$userHelper,
$personHelper,
$dateTimeHelper,
$translatableStringExportLabelHelper,
$aggregateStringHelper,
$rollingDateConverter,
$this->getParameters(false),
);
}
public function getFormData()
{
return [['calc_date' => new RollingDate(RollingDate::T_TODAY)]];
}
public function getModifiersCombination()
{
return [[Declarations::ACP_TYPE]];
}
public function testQuery(): void
{
$centers = $this->centerRepository->findAll();

View File

@@ -0,0 +1,72 @@
<?php
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\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListHouseholdInPeriod;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ListHouseholdInPeriodTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$addressHelper = self::$container->get(ExportAddressHelper::class);
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
$entityManager = self::$container->get(EntityManagerInterface::class);
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$translatableStringHelper = self::$container->get(TranslatableStringExportLabelHelper::class);
yield new ListHouseholdInPeriod(
$addressHelper,
$aggregateStringHelper,
$entityManager,
$rollingDateConverter,
$translatableStringHelper,
$this->getParameters(true),
);
yield new ListHouseholdInPeriod(
$addressHelper,
$aggregateStringHelper,
$entityManager,
$rollingDateConverter,
$translatableStringHelper,
$this->getParameters(false),
);
}
public function getFormData()
{
return [['calc_date' => new RollingDate(RollingDate::T_TODAY)]];
}
public function getModifiersCombination()
{
return [[Declarations::PERSON_TYPE]];
}
}

View File

@@ -0,0 +1,69 @@
<?php
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\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListPersonHavingAccompanyingPeriod;
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ListPersonHavingAccompanyingPeriodTest extends AbstractExportTest
{
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
}
public function getExport()
{
$addressHelper = self::$container->get(ExportAddressHelper::class);
$listPersonHelper = self::$container->get(ListPersonHelper::class);
$entityManager = self::$container->get(EntityManagerInterface::class);
$rollingDateconverter = self::$container->get(RollingDateConverterInterface::class);
yield new ListPersonHavingAccompanyingPeriod(
$addressHelper,
$listPersonHelper,
$entityManager,
$rollingDateconverter,
$this->getParameters(true),
);
yield new ListPersonHavingAccompanyingPeriod(
$addressHelper,
$listPersonHelper,
$entityManager,
$rollingDateconverter,
$this->getParameters(false),
);
}
public function getFormData()
{
return [['address_date_rolling' => new RollingDate(RollingDate::T_TODAY), 'fields' => ListPersonHelper::FIELDS]];
}
public function getModifiersCombination()
{
return [[Declarations::PERSON_TYPE, Declarations::ACP_TYPE]];
}
}

View File

@@ -11,8 +11,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Export\ListPerson;
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
/**
@@ -45,7 +50,29 @@ final class ListPersonTest extends AbstractExportTest
public function getExport()
{
return $this->export;
$addressHelper = self::$container->get(ExportAddressHelper::class);
$customFieldProvider = self::$container->get(CustomFieldProvider::class);
$listPersonHelper = self::$container->get(ListPersonHelper::class);
$entityManager = self::$container->get(EntityManagerInterface::class);
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
yield new ListPerson(
$addressHelper,
$customFieldProvider,
$listPersonHelper,
$entityManager,
$translatableStringHelper,
$this->getParameters(true),
);
yield new ListPerson(
$addressHelper,
$customFieldProvider,
$listPersonHelper,
$entityManager,
$translatableStringHelper,
$this->getParameters(false),
);
}
public function getFormData(): iterable

View File

@@ -0,0 +1,73 @@
<?php
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\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails;
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest
{
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
}
public function getExport()
{
$listPersonHelper = self::$container->get(ListPersonHelper::class);
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
$entityManager = self::$container->get(EntityManagerInterface::class);
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
yield new ListPersonWithAccompanyingPeriodDetails(
$listPersonHelper,
$listAccompanyingPeriodHelper,
$entityManager,
$rollingDateConverter,
$this->getParameters(true),
);
yield new ListPersonWithAccompanyingPeriodDetails(
$listPersonHelper,
$listAccompanyingPeriodHelper,
$entityManager,
$rollingDateConverter,
$this->getParameters(false),
);
}
public function getFormData()
{
return [
['address_date' => new RollingDate(RollingDate::T_TODAY)],
];
}
public function getModifiersCombination()
{
return [
[Declarations::PERSON_TYPE, Declarations::ACP_TYPE],
];
}
}

View File

@@ -11,9 +11,12 @@ declare(strict_types=1);
namespace Export\Export;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -33,13 +36,17 @@ final class StatAccompanyingCourseDurationTest extends AbstractExportTest
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
$rollingDateconverter = self::$container->get(RollingDateConverterInterface::class);
yield new StatAccompanyingCourseDuration($em, $rollingDateconverter, $this->getParameters(true));
yield new StatAccompanyingCourseDuration($em, $rollingDateconverter, $this->getParameters(false));
}
public function getFormData(): array
{
return [
['closingdate' => \DateTime::createFromFormat('Y-m-d', '2022-06-30')],
['closingdate_rolling' => new RollingDate(RollingDate::T_TODAY)],
];
}