fix: adjust detection of overlapping applications
addresses #869ar02xk
This commit is contained in:
1 parent
bdd06f0187
commit
804dab335f
5 files changed
+342
-322
No files matched your search
@@ -37,17 +37,21 @@ class ApplicationValidator extends ConstraintValidator
|
||||
return;
|
||||
}
|
||||
|
||||
$assignment = $application->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
if (null === $period = $application->getAssignment()->getEffectivePeriod()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$applicationDateFrom = $destination->getDateFrom();
|
||||
$applicationDateTo = $destination->getDateTo();
|
||||
$applicationDateFrom = $period->start->toDateTimeImmutable();
|
||||
$applicationDateTo = $period->end->toDateTimeImmutable();
|
||||
|
||||
$qb = $this
|
||||
->dispositionRepository
|
||||
->createQueryBuilder('disposition')
|
||||
;
|
||||
|
||||
// the same overlap test as App\Repository\ApplicationRepository::findOverlappingForTeamer(),
|
||||
// so an application that passes this validation is not purged later on by
|
||||
// App\EventListener\InvalidateApplicationsListener
|
||||
$conflictingCount = $qb
|
||||
->select($qb->expr()->count('disposition'))
|
||||
->innerJoin('disposition.assignment', 'assignment')
|
||||
@@ -60,12 +64,22 @@ class ApplicationValidator extends ConstraintValidator
|
||||
$qb->expr()->isNull('destination.deletedAt'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->gt('destination.dateTo', ':application_date_from'),
|
||||
$qb->expr()->lt('destination.dateTo', ':application_date_to'),
|
||||
$qb->expr()->isNull('assignment.dateFrom'),
|
||||
$qb->expr()->lte('destination.dateFrom', ':application_date_to')
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lt('destination.dateFrom', ':application_date_to'),
|
||||
$qb->expr()->gt('destination.dateFrom', ':application_date_from'),
|
||||
$qb->expr()->isNotNull('assignment.dateFrom'),
|
||||
$qb->expr()->lte('assignment.dateFrom', ':application_date_to')
|
||||
)
|
||||
),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->isNull('assignment.dateTo'),
|
||||
$qb->expr()->gte('destination.dateTo', ':application_date_from')
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->isNotNull('assignment.dateTo'),
|
||||
$qb->expr()->gte('assignment.dateTo', ':application_date_from')
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user