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,8 +2145,15 @@ async function bulkExportPDF() {
totalNetHours += entry.netHours; totalNetHours += entry.netHours;
} else if (entry.entryType === 'flextime') { } else if (entry.entryType === 'flextime') {
flextimeDays++; flextimeDays++;
// 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; 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 flextimeDays = 0;
let workEntriesCount = 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 => { entries.forEach(entry => {
const entryDate = new Date(entry.date); const entryDate = new Date(entry.date);
if (entryDate <= today) { if (entryDate <= today) {
@@ -3027,11 +3043,19 @@ async function handleExportPDF() {
workEntriesCount++; workEntriesCount++;
} else if (entry.entryType === 'vacation') { } else if (entry.entryType === 'vacation') {
vacationDays++; vacationDays++;
// Vacation hours are already included in netHours (8h per day typically)
totalNetHours += entry.netHours; totalNetHours += entry.netHours;
} else if (entry.entryType === 'flextime') { } else if (entry.entryType === 'flextime') {
flextimeDays++; flextimeDays++;
// 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; totalNetHours += entry.netHours;
} }
// If flextime on regular workday, hours are already counted in work entries
}
} }
}); });