Merge branch 'main' of git.targo.ca:Targo/targo_backend

This commit is contained in:
Matthieu Haineault 2025-10-07 10:28:16 -04:00
commit 4d905c905e
2 changed files with 15 additions and 3 deletions

View File

@ -252,6 +252,7 @@ export class PayPeriodsQueryService {
record.total_hours += hours; record.total_hours += hours;
break; break;
} }
record.is_approved = record.is_approved && shift.timesheet.is_approved; record.is_approved = record.is_approved && shift.timesheet.is_approved;
record.is_remote = record.is_remote || !!shift.is_remote; record.is_remote = record.is_remote || !!shift.is_remote;
} }
@ -267,7 +268,7 @@ export class PayPeriodsQueryService {
const type = (expense.bank_code?.type || "").toUpperCase(); const type = (expense.bank_code?.type || "").toUpperCase();
const rate = expense.bank_code?.modifier ?? 0; const rate = expense.bank_code?.modifier ?? 0;
if (type === "MILEAGE" && rate > 0) { if (type === "MILEAGE" && rate > 0) {
record.mileage += Math.round((amount / rate)/100)*100; record.mileage += Math.round((amount / rate) * 100) / 100;
} }
record.is_approved = record.is_approved && expense.timesheet.is_approved; record.is_approved = record.is_approved && expense.timesheet.is_approved;
} }

View File

@ -23,10 +23,21 @@ export class TimesheetsQueryService {
user: { is: { email } } user: { is: { email } }
}, },
select: { select: {
id: true id: true,
user_id: true,
}, },
}); });
if(!employee) throw new NotFoundException(`no employee with email ${email} found`); if(!employee) throw new NotFoundException(`no employee with email ${email} found`);
//gets the employee's full name
const user = await this.prisma.users.findFirst({
where: { id: employee.user_id },
select: {
first_name: true,
last_name: true,
}
});
const employee_full_name: string = ( user?.first_name + " " + user?.last_name ) || " ";
//finds the period //finds the period
const period = await this.prisma.payPeriods.findFirst({ const period = await this.prisma.payPeriods.findFirst({
@ -104,7 +115,7 @@ export class TimesheetsQueryService {
supervisor_comment: expense.supervisor_comment ?? '', supervisor_comment: expense.supervisor_comment ?? '',
})); }));
return buildPeriod(period.period_start, period.period_end, shifts , expenses); return buildPeriod(period.period_start, period.period_end, shifts , expenses, employee_full_name);
} }
async getTimesheetByEmail(email: string, week_offset = 0): Promise<TimesheetDto> { async getTimesheetByEmail(email: string, week_offset = 0): Promise<TimesheetDto> {