fix(employees): fix create employees
This commit is contained in:
parent
f8a70deed2
commit
b44577c595
|
|
@ -4,7 +4,7 @@ import { Type } from 'class-transformer';
|
||||||
export class EmployeeDetailedDto {
|
export class EmployeeDetailedDto {
|
||||||
@IsString() @IsNotEmpty() first_name: string;
|
@IsString() @IsNotEmpty() first_name: string;
|
||||||
@IsString() @IsNotEmpty() last_name: string;
|
@IsString() @IsNotEmpty() last_name: string;
|
||||||
@IsString() employee_full_name: string;
|
@IsString() @IsOptional() employee_full_name: string;
|
||||||
@IsString() @IsOptional() supervisor_full_name: string;
|
@IsString() @IsOptional() supervisor_full_name: string;
|
||||||
@IsOptional() @IsBoolean() is_supervisor: boolean;
|
@IsOptional() @IsBoolean() is_supervisor: boolean;
|
||||||
@IsString() company_name: string;
|
@IsString() company_name: string;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export class EmployeesCreateService {
|
||||||
const normalized_access = toBooleanFromString(dto.user_module_access);
|
const normalized_access = toBooleanFromString(dto.user_module_access);
|
||||||
const supervisor_id = await this.toIdFromFullName(dto.supervisor_full_name);
|
const supervisor_id = await this.toIdFromFullName(dto.supervisor_full_name);
|
||||||
const company_code = toCompanyCodeFromString(dto.company_name)
|
const company_code = toCompanyCodeFromString(dto.company_name)
|
||||||
|
|
||||||
await this.prisma.$transaction(async (tx) => {
|
await this.prisma.$transaction(async (tx) => {
|
||||||
const user: Users = await tx.users.create({
|
const user: Users = await tx.users.create({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -40,7 +41,6 @@ export class EmployeesCreateService {
|
||||||
company_code: company_code,
|
company_code: company_code,
|
||||||
job_title: dto.job_title,
|
job_title: dto.job_title,
|
||||||
first_work_day: dto.first_work_day,
|
first_work_day: dto.first_work_day,
|
||||||
last_work_day: dto.last_work_day,
|
|
||||||
is_supervisor: dto.is_supervisor,
|
is_supervisor: dto.is_supervisor,
|
||||||
supervisor_id: supervisor_id,
|
supervisor_id: supervisor_id,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Injectable } from "@nestjs/common";
|
||||||
import { Result } from "src/common/errors/result-error.factory";
|
import { Result } from "src/common/errors/result-error.factory";
|
||||||
import { EmailToIdResolver } from "src/common/mappers/email-id.mapper";
|
import { EmailToIdResolver } from "src/common/mappers/email-id.mapper";
|
||||||
import { toBooleanFromString } from "src/common/mappers/module-access.mapper";
|
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/dtos/employee-detailed.dto";
|
import { EmployeeDetailedDto } from "src/identity-and-account/employees/dtos/employee-detailed.dto";
|
||||||
import { toCompanyCodeFromString } from "src/identity-and-account/employees/utils/employee.utils";
|
import { toCompanyCodeFromString } from "src/identity-and-account/employees/utils/employee.utils";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
|
|
@ -58,7 +59,7 @@ export class EmployeesUpdateService {
|
||||||
data: {
|
data: {
|
||||||
company_code: company_code,
|
company_code: company_code,
|
||||||
job_title: dto.job_title,
|
job_title: dto.job_title,
|
||||||
first_work_day: dto.first_work_day,
|
first_work_day: toDateFromString(dto.first_work_day),
|
||||||
last_work_day: dto.last_work_day,
|
last_work_day: dto.last_work_day,
|
||||||
is_supervisor: dto.is_supervisor,
|
is_supervisor: dto.is_supervisor,
|
||||||
supervisor_id: supervisor_id,
|
supervisor_id: supervisor_id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user