Resilliance und bessere erkennung ausgefüllte tage

This commit is contained in:
2026-02-12 13:38:27 +01:00
parent b6c8ca1df1
commit 03b4db8247
2 changed files with 14 additions and 4 deletions

View File

@@ -393,6 +393,7 @@ function registerUserRoutes(app) {
const endDate = new Date(week.week_end);
let workdays = 0;
let filledWorkdays = 0;
const fullDayHoursForCheck = wochenstunden > 0 && arbeitstage > 0 ? wochenstunden / arbeitstage : 8;
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
const day = d.getDay();
@@ -408,15 +409,18 @@ function registerUserRoutes(app) {
// Tag gilt als ausgefüllt wenn:
// - Ganzer Tag Urlaub (vacation_type = 'full')
// - Krank (sick_status = 1)
// - Ganzer Tag Überstunden (overtime_taken_hours = fullDayHours)
// - ODER Start- und End-Zeit vorhanden sind
if (entry) {
const isFullDayVacation = entry.vacation_type === 'full';
const isSick = entry.sick_status === 1 || entry.sick_status === true;
const overtimeValue = entry.overtime_taken_hours ? parseFloat(entry.overtime_taken_hours) : 0;
const isFullDayOvertime = overtimeValue > 0 && Math.abs(overtimeValue - fullDayHoursForCheck) < 0.01;
const hasStartAndEnd = entry.start_time && entry.end_time &&
entry.start_time.toString().trim() !== '' &&
entry.end_time.toString().trim() !== '';
if (isFullDayVacation || isSick || hasStartAndEnd) {
if (isFullDayVacation || isSick || isFullDayOvertime || hasStartAndEnd) {
filledWorkdays++;
}
}
@@ -462,7 +466,7 @@ function registerUserRoutes(app) {
const isFullDayOvertime = overtimeValue > 0 && Math.abs(overtimeValue - fullDayHours) < 0.01;
if (entry.overtime_taken_hours) {
weekOvertimeTaken += entry.overtime_taken_hours;
weekOvertimeTaken += parseFloat(entry.overtime_taken_hours) || 0;
}
// Wenn 8 Überstunden eingetragen sind, zählt der Tag als 0 Stunden
@@ -666,6 +670,7 @@ function registerUserRoutes(app) {
const endDate = new Date(week.week_end);
let workdays = 0;
let filledWorkdays = 0;
const fullDayHoursForCheck = wochenstunden > 0 && arbeitstage > 0 ? wochenstunden / arbeitstage : 8;
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
const day = d.getDay();
@@ -681,11 +686,13 @@ function registerUserRoutes(app) {
if (entry) {
const isFullDayVacation = entry.vacation_type === 'full';
const isSick = entry.sick_status === 1 || entry.sick_status === true;
const overtimeValue = entry.overtime_taken_hours ? parseFloat(entry.overtime_taken_hours) : 0;
const isFullDayOvertime = overtimeValue > 0 && Math.abs(overtimeValue - fullDayHoursForCheck) < 0.01;
const hasStartAndEnd = entry.start_time && entry.end_time &&
entry.start_time.toString().trim() !== '' &&
entry.end_time.toString().trim() !== '';
if (isFullDayVacation || isSick || hasStartAndEnd) {
if (isFullDayVacation || isSick || isFullDayOvertime || hasStartAndEnd) {
filledWorkdays++;
}
}

View File

@@ -94,6 +94,7 @@ function getCurrentOvertimeForUser(userId, db, callback) {
const endDate = new Date(week.week_end);
let workdays = 0;
let filledWorkdays = 0;
const fullDayHoursForCheck = wochenstunden > 0 && arbeitstage > 0 ? wochenstunden / arbeitstage : 8;
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
const day = d.getDay();
@@ -108,12 +109,14 @@ function getCurrentOvertimeForUser(userId, db, callback) {
if (entry) {
const isFullDayVacation = entry.vacation_type === 'full';
const isSick = entry.sick_status === 1 || entry.sick_status === true;
const overtimeValue = entry.overtime_taken_hours ? parseFloat(entry.overtime_taken_hours) : 0;
const isFullDayOvertime = overtimeValue > 0 && Math.abs(overtimeValue - fullDayHoursForCheck) < 0.01;
const hasStartAndEnd =
entry.start_time &&
entry.end_time &&
entry.start_time.toString().trim() !== '' &&
entry.end_time.toString().trim() !== '';
if (isFullDayVacation || isSick || hasStartAndEnd) {
if (isFullDayVacation || isSick || isFullDayOvertime || hasStartAndEnd) {
filledWorkdays++;
}
}