From 4d2ed4714f3b825e7878786f9df89337dfa3863a Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Mon, 18 Aug 2025 10:57:35 -0400 Subject: [PATCH] fix(timesheet): removed magic number --- src/modules/timesheets/services/timesheets-query.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/timesheets/services/timesheets-query.service.ts b/src/modules/timesheets/services/timesheets-query.service.ts index 82e0fae..39e71c8 100644 --- a/src/modules/timesheets/services/timesheets-query.service.ts +++ b/src/modules/timesheets/services/timesheets-query.service.ts @@ -8,6 +8,8 @@ import { computeHours } from 'src/common/utils/date-utils'; import { buildPrismaWhere } from 'src/common/shared/build-prisma-where'; import { SearchTimesheetDto } from '../dtos/search-timesheet.dto'; +const ROUND_TO = 5; + @Injectable() export class TimesheetsQueryService { constructor( @@ -15,6 +17,8 @@ export class TimesheetsQueryService { private readonly overtime: OvertimeService, ) {} + + async create(dto : CreateTimesheetDto): Promise { const { employee_id, is_approved } = dto; return this.prisma.timesheets.create({ @@ -42,7 +46,7 @@ export class TimesheetsQueryService { rawlist.map(async timesheet => { //detailed shifts const detailedShifts = timesheet.shift.map(shift => { - const totalhours = computeHours(shift.start_time, shift.end_time,5); + const totalhours = computeHours(shift.start_time, shift.end_time, ROUND_TO); const regularHours = Math.min(8, totalhours); const dailyOvertime = this.overtime.getDailyOvertimeHours(shift.start_time, shift.end_time); const payRegular = regularHours * shift.bank_code.modifier;