fix(timesheet): removed validation/transformation from ensureTimesheet and use the param Date format inside the function

This commit is contained in:
Matthieu Haineault 2025-10-31 08:50:13 -04:00
parent c0fbad006d
commit 9f0da467ae

View File

@ -178,11 +178,10 @@ export class GetTimesheetsOverviewService {
}; };
} }
private ensureTimesheet = async (employee_id: number, start_date: Date | string) => { private ensureTimesheet = async (employee_id: number, start_date: Date) => {
const start = toDateFromString(start_date);
let row = await this.prisma.timesheets.findFirst({ let row = await this.prisma.timesheets.findFirst({
where: { employee_id, start_date: start }, where: { employee_id, start_date: start_date },
include: { include: {
employee: { include: { user: true } }, employee: { include: { user: true } },
shift: { include: { bank_code: true } }, shift: { include: { bank_code: true } },
@ -194,13 +193,13 @@ export class GetTimesheetsOverviewService {
await this.prisma.timesheets.create({ await this.prisma.timesheets.create({
data: { data: {
employee_id, employee_id,
start_date: start, start_date: start_date,
is_approved: false is_approved: false
}, },
}); });
row = await this.prisma.timesheets.findFirst({ row = await this.prisma.timesheets.findFirst({
where: { employee_id, start_date: start }, where: { employee_id, start_date: start_date },
include: { include: {
employee: { include: { user: true } }, employee: { include: { user: true } },
shift: { include: { bank_code: true } }, shift: { include: { bank_code: true } },