Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9577a70ea3 | ||
| e85f7b6f4c |
@@ -1,2 +1,2 @@
|
||||
parameters:
|
||||
app.version: '0.1.56'
|
||||
app.version: '0.1.57'
|
||||
|
||||
@@ -230,26 +230,36 @@ final class WorkHourRepository extends ServiceEntityRepository implements WorkHo
|
||||
|
||||
public function isWeekFullyValidated(Employee $employee, DateTimeImmutable $from, DateTimeImmutable $to): bool
|
||||
{
|
||||
// At least one validated day must exist
|
||||
$validatedCount = (int) $this->createQueryBuilder('w')
|
||||
// Count weekdays (Mon-Fri) in range
|
||||
$expectedWeekdays = 0;
|
||||
for ($d = $from; $d <= $to; $d = $d->modify('+1 day')) {
|
||||
if ((int) $d->format('N') <= 5) {
|
||||
++$expectedWeekdays;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 === $expectedWeekdays) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Every weekday must have a work_hour row
|
||||
$totalCount = (int) $this->createQueryBuilder('w')
|
||||
->select('COUNT(w.id)')
|
||||
->andWhere('w.employee = :employee')
|
||||
->andWhere('w.workDate >= :from')
|
||||
->andWhere('w.workDate <= :to')
|
||||
->andWhere('w.isValid = :isValid')
|
||||
->setParameter('employee', $employee)
|
||||
->setParameter('from', $from)
|
||||
->setParameter('to', $to)
|
||||
->setParameter('isValid', true)
|
||||
->getQuery()
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
|
||||
if (0 === $validatedCount) {
|
||||
if ($totalCount < $expectedWeekdays) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// No non-validated day must exist in the range
|
||||
// All rows must be validated
|
||||
$nonValidatedCount = (int) $this->createQueryBuilder('w')
|
||||
->select('COUNT(w.id)')
|
||||
->andWhere('w.employee = :employee')
|
||||
|
||||
@@ -267,6 +267,6 @@ final readonly class EmployeeRttSummaryProvider implements ProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
return $weekEnd;
|
||||
return $today;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user