From e71988e0b7564162951d54369e3903ebac588227 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 20 Oct 2025 16:51:26 +0200 Subject: [PATCH] Enhance TimeEntryService with additional debug logging for better traceability of work time calculations. Added logs for netWorkTime and currentlyWorked to provide clearer insights into overtime and weekly totals, improving the debugging process while maintaining existing functionality. --- backend/src/services/TimeEntryService.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/services/TimeEntryService.js b/backend/src/services/TimeEntryService.js index 524aa8c..8744170 100644 --- a/backend/src/services/TimeEntryService.js +++ b/backend/src/services/TimeEntryService.js @@ -599,11 +599,15 @@ class TimeEntryService { if (day.netWorkTime) { const [h, m] = day.netWorkTime.split(':').map(Number); weekIstMinutes += h * 60 + m; + console.log(` Tag ${day.date}: netWorkTime=${day.netWorkTime}, Soll=${daySollHours}h, Ist=${h}:${m}`); } }); // Überstunden = Ist - Soll const overtimeMinutes = weekIstMinutes - weekSollMinutes; + + console.log(`🔍 Wochenüberstunden: weekIst=${weekIstMinutes}min (${Math.floor(weekIstMinutes/60)}:${weekIstMinutes%60}), weekSoll=${weekSollMinutes}min (${Math.floor(weekSollMinutes/60)}:${weekSollMinutes%60}), overtime=${overtimeMinutes}min`); + const overtimeHours = Math.floor(Math.abs(overtimeMinutes) / 60); const overtimeMins = Math.abs(overtimeMinutes) % 60; const overtimeSign = overtimeMinutes >= 0 ? '+' : '-'; @@ -685,14 +689,18 @@ class TimeEntryService { const [h, m, s] = currentlyWorked.split(':').map(Number); dayIstMinutes = h * 60 + m; weekIstMinutesTotal += dayIstMinutes; + console.log(` HEUTE ${day.date}: currentlyWorked=${currentlyWorked}, Soll=${daySollHours}h, Ist=${h}:${m}`); } else if (!isToday && day.netWorkTime) { // Für vergangene Tage: Verwende netWorkTime const [h, m] = day.netWorkTime.split(':').map(Number); dayIstMinutes = h * 60 + m; weekIstMinutesTotal += dayIstMinutes; + console.log(` Vergangener Tag ${day.date}: netWorkTime=${day.netWorkTime}, Soll=${daySollHours}h, Ist=${h}:${m}`); } }); + console.log(`🔍 Offen für Woche: weekIstTotal=${weekIstMinutesTotal}min, weekSollTotal=${weekSollMinutesTotal}min`); + // Offen für Woche = Wochensoll - Wochenist (bisher) const openForWeekMinutes = weekSollMinutesTotal - weekIstMinutesTotal;