fixes
This commit is contained in:
@@ -221,15 +221,21 @@ function generatePDF(timesheetId, req, res) {
|
||||
doc.fontSize(10);
|
||||
}
|
||||
|
||||
if (entry.total_hours) {
|
||||
totalHours += entry.total_hours;
|
||||
}
|
||||
|
||||
// Urlaubsstunden für Überstunden-Berechnung sammeln
|
||||
// Urlaub hat Priorität - wenn Urlaub, zähle nur Urlaubsstunden, nicht zusätzlich Arbeitsstunden
|
||||
if (entry.vacation_type === 'full') {
|
||||
vacationHours += 8; // Ganzer Tag = 8 Stunden
|
||||
// Bei vollem Tag Urlaub werden keine Arbeitsstunden gezählt
|
||||
} else if (entry.vacation_type === 'half') {
|
||||
vacationHours += 4; // Halber Tag = 4 Stunden
|
||||
// Bei halbem Tag Urlaub können noch Arbeitsstunden vorhanden sein
|
||||
if (entry.total_hours) {
|
||||
totalHours += entry.total_hours;
|
||||
}
|
||||
} else {
|
||||
// Kein Urlaub - zähle nur Arbeitsstunden
|
||||
if (entry.total_hours) {
|
||||
totalHours += entry.total_hours;
|
||||
}
|
||||
}
|
||||
|
||||
doc.moveDown(0.5);
|
||||
@@ -249,9 +255,9 @@ function generatePDF(timesheetId, req, res) {
|
||||
|
||||
// Überstunden berechnen und anzeigen
|
||||
const wochenstunden = timesheet.wochenstunden || 0;
|
||||
// Überstunden = Gesamtstunden - Wochenstunden
|
||||
// Urlaub zählt als normale Arbeitszeit, daher sind Urlaubsstunden bereits in totalHours enthalten
|
||||
const overtimeHours = totalHours - wochenstunden;
|
||||
// Überstunden = (Tatsächliche Stunden + Urlaubsstunden) - Wochenstunden
|
||||
const totalHoursWithVacation = totalHours + vacationHours;
|
||||
const overtimeHours = totalHoursWithVacation - wochenstunden;
|
||||
|
||||
doc.moveDown(0.3);
|
||||
doc.font('Helvetica-Bold');
|
||||
@@ -432,14 +438,21 @@ function generatePDFToBuffer(timesheetId, req) {
|
||||
doc.fontSize(10);
|
||||
}
|
||||
|
||||
if (entry.total_hours) {
|
||||
totalHours += entry.total_hours;
|
||||
}
|
||||
|
||||
// Urlaub hat Priorität - wenn Urlaub, zähle nur Urlaubsstunden, nicht zusätzlich Arbeitsstunden
|
||||
if (entry.vacation_type === 'full') {
|
||||
vacationHours += 8;
|
||||
vacationHours += 8; // Ganzer Tag = 8 Stunden
|
||||
// Bei vollem Tag Urlaub werden keine Arbeitsstunden gezählt
|
||||
} else if (entry.vacation_type === 'half') {
|
||||
vacationHours += 4;
|
||||
vacationHours += 4; // Halber Tag = 4 Stunden
|
||||
// Bei halbem Tag Urlaub können noch Arbeitsstunden vorhanden sein
|
||||
if (entry.total_hours) {
|
||||
totalHours += entry.total_hours;
|
||||
}
|
||||
} else {
|
||||
// Kein Urlaub - zähle nur Arbeitsstunden
|
||||
if (entry.total_hours) {
|
||||
totalHours += entry.total_hours;
|
||||
}
|
||||
}
|
||||
|
||||
doc.moveDown(0.5);
|
||||
@@ -457,7 +470,9 @@ function generatePDFToBuffer(timesheetId, req) {
|
||||
doc.text(`Gesamtstunden: ${totalHours.toFixed(2)} h`, 50, doc.y);
|
||||
|
||||
const wochenstunden = timesheet.wochenstunden || 0;
|
||||
const overtimeHours = totalHours - wochenstunden;
|
||||
// Überstunden = (Tatsächliche Stunden + Urlaubsstunden) - Wochenstunden
|
||||
const totalHoursWithVacation = totalHours + vacationHours;
|
||||
const overtimeHours = totalHoursWithVacation - wochenstunden;
|
||||
|
||||
doc.moveDown(0.3);
|
||||
doc.font('Helvetica-Bold');
|
||||
|
||||
Reference in New Issue
Block a user