fix: fix employee logged in when only one attendance registration is found

This commit is contained in:
Marcel Arndt 2025-07-02 15:26:45 +02:00
parent 8ec8d481b8
commit b4ccd1ed76
1 changed files with 4 additions and 2 deletions

View File

@ -10,7 +10,7 @@ import {
isBefore, isBefore,
isWithinInterval, isWithinInterval,
set, set,
subMilliseconds subMilliseconds,
} from 'date-fns'; } from 'date-fns';
import { getTimezoneOffset, toZonedTime } from 'date-fns-tz'; import { getTimezoneOffset, toZonedTime } from 'date-fns-tz';
@ -303,7 +303,8 @@ export class EmployeesLoggedInDetector extends AnomalyDetector {
isBefore(lastClockedOut.dateTime, firstClockedIn.dateTime) isBefore(lastClockedOut.dateTime, firstClockedIn.dateTime)
) { ) {
return [ return [
false, isBefore(firstClockedIn.dateTime, datetimeToCheckWithBuffer) ||
isBefore(firstClockedIn.dateTime, datetimeToCheck),
{ {
start: firstClockedIn.dateTime, start: firstClockedIn.dateTime,
end: undefined, end: undefined,
@ -320,6 +321,7 @@ export class EmployeesLoggedInDetector extends AnomalyDetector {
start: new Date(firstClockedIn.dateTime), start: new Date(firstClockedIn.dateTime),
end: new Date(lastClockedOut.dateTime), end: new Date(lastClockedOut.dateTime),
}; };
return [ return [
isWithinInterval(datetimeToCheckWithBuffer, interval) || isWithinInterval(datetimeToCheckWithBuffer, interval) ||
isWithinInterval(datetimeToCheck, interval), isWithinInterval(datetimeToCheck, interval),