From 442f2f9a8626e4dc7ddda2e8f0c97a081adc2745 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 28 Feb 2024 16:04:09 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9F=E0=B8=B4?= =?UTF-8?q?=E0=B8=A7validate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 9 ++++++-- src/entities/SalaryProfile.ts | 28 +++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 7522dbe..c18f045 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -480,7 +480,8 @@ export class SalaryPeriodController extends Controller { ); } - const salaryProfile = Object.assign(new SalaryProfile(), requestBody); + let salaryProfile: any = Object.assign(new SalaryProfile(), requestBody); + delete salaryProfile.id; salaryProfile.type = salaryProfile.type.toUpperCase(); //Type & Level const type = await this.posTypeRepository.findOne({ @@ -557,7 +558,9 @@ export class SalaryPeriodController extends Controller { : salaryRanks.salaryFullHalf - salaryProfile.amount; salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFullHalf; } else { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง"); + salaryProfile.amountSpecial = 0; + salaryProfile.amountUse = 0; + salaryProfile.positionSalaryAmount = 0; } salaryProfile.salaryOrgId = salaryOrg.id; @@ -807,6 +810,7 @@ export class SalaryPeriodController extends Controller { await Promise.all( orgs.map(async (rootId: string) => { let salaryOrgNew = Object.assign(new SalaryOrg()); + delete salaryOrgNew.id; salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = rootId; @@ -857,6 +861,7 @@ export class SalaryPeriodController extends Controller { if (salaryOrgNew != null) { let salaryProfileNew = Object.assign(new SalaryProfile(), profile); + delete profile.id; salaryProfileNew.salaryOrgId = salaryOrgNew.id; salaryProfileNew.revisionId = salaryPeriod.revisionId; salaryProfileNew.createdUserId = request.user.sub; diff --git a/src/entities/SalaryProfile.ts b/src/entities/SalaryProfile.ts index ff93597..f93f68e 100644 --- a/src/entities/SalaryProfile.ts +++ b/src/entities/SalaryProfile.ts @@ -289,16 +289,16 @@ export class CreateSalaryProfile { citizenId: string; @Column() - posMasterNoPrefix: string; + posMasterNoPrefix: string | null; @Column() posMasterNo: number; @Column() - posMasterNoSuffix: string; + posMasterNoSuffix: string | null; @Column() - orgShortName: string; + orgShortName: string | null; @Column() position: string; @@ -310,40 +310,40 @@ export class CreateSalaryProfile { posLevel: string; @Column() - posExecutive: string; + posExecutive: string | null; @Column() amount: number; @Column("uuid") - rootId: string; + rootId: string | null; @Column() - root: string; + root: string | null; @Column("uuid") - child1Id: string; + child1Id: string | null; @Column() - child1: string; + child1: string | null; @Column("uuid") - child2Id: string; + child2Id: string | null; @Column() - child2: string; + child2: string | null; @Column("uuid") - child3Id: string; + child3Id: string | null; @Column() - child3: string; + child3: string | null; @Column("uuid") - child4Id: string; + child4Id: string | null; @Column() - child4: string; + child4: string | null; @Column() isResult: boolean;