From 473ab93eb75bea323ffcdae44ebdbe65903d2009 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 10 Sep 2026 13:25:35 +0200 Subject: [PATCH] =?UTF-8?q?Berechne=20die=20Wochensumme=20f=C3=BCr=20Arbei?= =?UTF-8?q?ts-=20und=20arbeitsfreie=20Zeit=20getrennt=20und=20passe=20die?= =?UTF-8?q?=20Ausgabe=20entsprechend=20an.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/services/TimeEntryService.js | 49 ++++++------------------ 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/backend/src/services/TimeEntryService.js b/backend/src/services/TimeEntryService.js index be85f4e..a1d1d6d 100755 --- a/backend/src/services/TimeEntryService.js +++ b/backend/src/services/TimeEntryService.js @@ -1886,36 +1886,8 @@ class TimeEntryService { } }); - // Berechne Wochensumme (Arbeit + Urlaub + Krankheit + Feiertage) - let totalMinutes = 0; - Object.values(dayData).forEach(day => { - // Krankheitsstunden (haben Vorrang) - if (day.sick) { - totalMinutes += day.sick.hours * 60; - } else { - // Nettoarbeitszeit - if (day.netWorkTime) { - const [hours, minutes] = day.netWorkTime.split(':').map(Number); - totalMinutes += hours * 60 + minutes; - } - - // Feiertagsstunden - if (day.holiday) { - totalMinutes += day.holiday.hours * 60; - } - - // Urlaubsstunden - if (day.vacation) { - totalMinutes += day.vacation.hours * 60; - } - } - }); - - const weekTotalHours = Math.floor(totalMinutes / 60); - const weekTotalMinutes = totalMinutes % 60; - const weekTotal = `${weekTotalHours}:${weekTotalMinutes.toString().padStart(2, '0')}`; - - // Berechne nur die Arbeitszeit (ohne arbeitsfreie Tage) + // Berechne die reguläre Arbeitszeit ohne arbeitsfreie Tage. Der + // Urlaubs-/Krankheits-/Feiertagsanteil wird weiter unten separat ergänzt. let workMinutes = 0; Object.values(dayData).forEach(day => { if (day.netWorkTime && !day.vacation && !day.sick && !day.holiday) { @@ -1924,10 +1896,6 @@ class TimeEntryService { } }); - const workHours = Math.floor(workMinutes / 60); - const workMins = workMinutes % 60; - const workTotal = `${workHours}:${workMins.toString().padStart(2, '0')}`; - // Berechne arbeitsfreie Stunden für die Woche (separat für Anzeige) let nonWorkingMinutes = 0; let nonWorkingDays = 0; @@ -1967,8 +1935,15 @@ class TimeEntryService { const nonWorkingMins = nonWorkingMinutes % 60; const nonWorkingTotal = `${nonWorkingHours}:${nonWorkingMins.toString().padStart(2, '0')}`; - // Gesamtsumme = Arbeitszeit + arbeitsfreie Zeit - const totalAllMinutes = workMinutes + nonWorkingMinutes; + // Die Wochensumme enthält die reguläre Arbeitszeit und die Gutschrift für + // arbeitsfreie Tage. Die Gesamtsumme weist den Anteil arbeitsfreier Tage + // zusätzlich aus. + const weekTotalMinutes = workMinutes + nonWorkingMinutes; + const weekTotalHours = Math.floor(weekTotalMinutes / 60); + const weekTotalMins = weekTotalMinutes % 60; + const weekTotal = `${weekTotalHours}:${weekTotalMins.toString().padStart(2, '0')}`; + + const totalAllMinutes = weekTotalMinutes + nonWorkingMinutes; const totalAllHours = Math.floor(totalAllMinutes / 60); const totalAllMins = totalAllMinutes % 60; const totalAll = `${totalAllHours}:${totalAllMins.toString().padStart(2, '0')}`; @@ -1978,7 +1953,7 @@ class TimeEntryService { weekEnd: weekEnd.toISOString().split('T')[0], weekOffset, days: Object.values(dayData).sort((a, b) => a.date.localeCompare(b.date)), - weekTotal: workTotal, // Nur Arbeitszeit + weekTotal, nonWorkingTotal, nonWorkingDays, nonWorkingDetails,