Icons, Footer, Stundenformel

This commit is contained in:
2026-02-05 13:27:39 +01:00
parent 7d6951334f
commit 3c282a0f3c
17 changed files with 100 additions and 28 deletions

View File

@@ -300,17 +300,33 @@ function registerVerwaltungRoutes(app) {
}
function processCurrentWeek(totalVacationDays) {
// Einträge für die Woche abrufen
db.all(`SELECT date, total_hours, overtime_taken_hours, vacation_type, sick_status
// Einträge für die Woche abrufen (id/updated_at für neuesten pro Tag)
db.all(`SELECT id, date, updated_at, total_hours, overtime_taken_hours, vacation_type, sick_status
FROM timesheet_entries
WHERE user_id = ? AND date >= ? AND date <= ?
ORDER BY date`,
ORDER BY date, updated_at DESC, id DESC`,
[userId, week_start, week_end],
(err, entries) => {
(err, allEntries) => {
if (err) {
return res.status(500).json({ error: 'Fehler beim Abrufen der Einträge' });
}
// Nur neuesten Eintrag pro Tag zählen (wie PDF/Submit), sonst Doppelzählung bei Duplikaten
const entriesByDate = {};
(allEntries || []).forEach(entry => {
const existing = entriesByDate[entry.date];
if (!existing) {
entriesByDate[entry.date] = entry;
} else {
const existingTime = existing.updated_at ? new Date(existing.updated_at).getTime() : 0;
const currentTime = entry.updated_at ? new Date(entry.updated_at).getTime() : 0;
if (currentTime > existingTime || (currentTime === existingTime && entry.id > existing.id)) {
entriesByDate[entry.date] = entry;
}
}
});
const entries = Object.values(entriesByDate);
// Berechnungen
let totalHours = 0;
let overtimeTaken = 0;
@@ -320,7 +336,7 @@ function registerVerwaltungRoutes(app) {
entries.forEach(entry => {
if (entry.overtime_taken_hours) {
overtimeTaken += entry.overtime_taken_hours;
overtimeTaken += parseFloat(entry.overtime_taken_hours) || 0;
}
// Krankheitstage zählen