feat: update bulk export logic to correctly handle flextime hours on weekends/holidays
This commit is contained in:
@@ -2145,8 +2145,15 @@ async function bulkExportPDF() {
|
||||
totalNetHours += entry.netHours;
|
||||
} else if (entry.entryType === 'flextime') {
|
||||
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;
|
||||
}
|
||||
// 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,11 +3043,19 @@ 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++;
|
||||
// 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
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user