fix(create-employee): date was passed directly as string, fixed to pass date object.

This commit is contained in:
Nic D. 2025-12-11 17:00:20 -05:00
parent acc128e5ea
commit 3b01aa3748

View File

@ -2,6 +2,7 @@ import { Injectable } from "@nestjs/common";
import { Users } from "@prisma/client";
import { Result } from "src/common/errors/result-error.factory";
import { toBooleanFromString } from "src/common/mappers/module-access.mapper";
import { toDateFromString } from "src/common/utils/date-utils";
import { EmployeeDetailedDto } from "src/identity-and-account/employees/employee-detailed.dto";
import { toCompanyCodeFromString } from "src/identity-and-account/employees/employee.utils";
import { PrismaService } from "src/prisma/prisma.service";
@ -13,7 +14,8 @@ export class EmployeesCreateService {
async createEmployee(dto: EmployeeDetailedDto): Promise<Result<boolean, string>> {
const normalized_access = toBooleanFromString(dto.user_module_access);
const supervisor_id = await this.toIdFromFullName(dto.supervisor_full_name);
const company_code = toCompanyCodeFromString(dto.company_name)
const company_code = toCompanyCodeFromString(dto.company_name);
const first_work_day = toDateFromString(dto.first_work_day);
await this.prisma.$transaction(async (tx) => {
const user: Users = await tx.users.create({
@ -41,7 +43,7 @@ export class EmployeesCreateService {
external_payroll_id: dto.external_payroll_id,
company_code: company_code,
job_title: dto.job_title,
first_work_day: dto.first_work_day,
first_work_day: first_work_day,
is_supervisor: dto.is_supervisor,
supervisor_id: supervisor_id,
schedule_preset_id: dto.preset_id,