fix(pay-period): Fix issue where overviews would sometimes return approval false

Overviews would be flagged as not approved if there were no shifts nor expenses on the timesheets, but it needs to be approved not just for accounting purposes, but to lock the timesheets from retroactive modifications as well.
This commit is contained in:
Nic D 2026-03-09 09:28:22 -04:00
parent 9efe1aded7
commit 6df3aa944d

View File

@ -205,13 +205,12 @@ export class GetOverviewService {
const record = by_employee.get(employee.id); const record = by_employee.get(employee.id);
if (!record) continue; if (!record) continue;
const timesheets = employee.timesheet; const timesheets = employee.timesheet;
const has_data = timesheets.some(timesheet => timesheet.shift.length > 0 || timesheet.expense.length > 0);
const cutoff_date = new Date(); const cutoff_date = new Date();
cutoff_date.setDate(cutoff_date.getDate() + 14); cutoff_date.setDate(cutoff_date.getDate() + 14);
const is_active = employee.last_work_day ? employee.last_work_day.getTime() >= cutoff_date.getTime() : true; const is_active = employee.last_work_day ? employee.last_work_day.getTime() >= cutoff_date.getTime() : true;
record.is_approved = has_data && timesheets.every(timesheet => timesheet.is_approved === true); record.is_approved = timesheets.every(timesheet => timesheet.is_approved === true);
record.is_active = is_active; record.is_active = is_active;
} }