diff --git a/.changes/unreleased/Fixed-20240429-113804.yaml b/.changes/unreleased/Fixed-20240429-113804.yaml new file mode 100644 index 000000000..0fa696901 --- /dev/null +++ b/.changes/unreleased/Fixed-20240429-113804.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Allow the filter "filter accompanying period by geographical unit" to take period's + location on address into account +time: 2024-04-29T11:38:04.966027861+02:00 +custom: + Issue: "275" diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index ce193e1a4..7d0980dad 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -33,8 +33,12 @@ use Symfony\Component\Form\FormBuilderInterface; */ class GeographicalUnitStatFilter implements FilterInterface { - public function __construct(private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) - { + public function __construct( + private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, + private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, + private readonly TranslatableStringHelperInterface $translatableStringHelper, + private readonly RollingDateConverterInterface $rollingDateConverter + ) { } public function addRole(): ?string @@ -50,6 +54,10 @@ class GeographicalUnitStatFilter implements FilterInterface FROM '.AccompanyingPeriod\AccompanyingPeriodLocationHistory::class.' acp_geog_filter_location_history LEFT JOIN '.PersonHouseholdAddress::class.' acp_geog_filter_address_person_location WITH IDENTITY(acp_geog_filter_location_history.personLocation) = IDENTITY(acp_geog_filter_address_person_location.person) + AND + (acp_geog_filter_address_person_location.validFrom < :acp_geog_filter_date AND ( + acp_geog_filter_address_person_location.validTo IS NULL OR acp_geog_filter_address_person_location.validTo > :acp_geog_filter_date + )) LEFT JOIN '.Address::class.' acp_geog_filter_address WITH COALESCE(IDENTITY(acp_geog_filter_address_person_location.address), IDENTITY(acp_geog_filter_location_history.addressLocation)) = acp_geog_filter_address.id LEFT JOIN acp_geog_filter_address.geographicalUnits acp_geog_filter_units @@ -57,10 +65,6 @@ class GeographicalUnitStatFilter implements FilterInterface (acp_geog_filter_location_history.startDate <= :acp_geog_filter_date AND ( acp_geog_filter_location_history.endDate IS NULL OR acp_geog_filter_location_history.endDate > :acp_geog_filter_date )) - AND - (acp_geog_filter_address_person_location.validFrom < :acp_geog_filter_date AND ( - acp_geog_filter_address_person_location.validTo IS NULL OR acp_geog_filter_address_person_location.validTo > :acp_geog_filter_date - )) AND acp_geog_filter_units IN (:acp_geog_filter_units) AND acp_geog_filter_location_history.period = acp.id ';