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