feat: update bulk export logic to correctly handle flextime hours on weekends/holidays

This commit is contained in:
Felix Schlusche
2025-10-23 19:13:48 +02:00
parent 90666a246c
commit 426859ea0d

View File

@@ -2145,7 +2145,14 @@ async function bulkExportPDF() {
totalNetHours += entry.netHours;
} else if (entry.entryType === 'flextime') {
flextimeDays++;
totalNetHours += entry.netHours;
// Only add flextime hours if it's on a weekend/holiday
// (otherwise it's already counted as workday hours)
const dateObj = new Date(entry.date);
const isWeekendHoliday = isWeekendOrHoliday(dateObj);
if (isWeekendHoliday) {
totalNetHours += entry.netHours;
}
// If flextime on regular workday, don't add hours (already in work entries)
}
}
});
@@ -3019,6 +3026,15 @@ async function handleExportPDF() {
let flextimeDays = 0;
let workEntriesCount = 0;
// Create map of entries by date for proper handling
const entriesByDate = new Map();
entries.forEach(entry => {
if (!entriesByDate.has(entry.date)) {
entriesByDate.set(entry.date, []);
}
entriesByDate.get(entry.date).push(entry);
});
entries.forEach(entry => {
const entryDate = new Date(entry.date);
if (entryDate <= today) {
@@ -3027,10 +3043,18 @@ async function handleExportPDF() {
workEntriesCount++;
} else if (entry.entryType === 'vacation') {
vacationDays++;
// Vacation hours are already included in netHours (8h per day typically)
totalNetHours += entry.netHours;
} else if (entry.entryType === 'flextime') {
flextimeDays++;
totalNetHours += entry.netHours;
// Only add flextime hours if it's on a weekend/holiday
// (otherwise it's already counted as workday hours)
const dateObj = new Date(entry.date);
const isWeekendHoliday = isWeekendOrHoliday(dateObj);
if (isWeekendHoliday) {
totalNetHours += entry.netHours;
}
// If flextime on regular workday, hours are already counted in work entries
}
}
});