From 9e2f87e7b3e3ff790b6f0dc747ce7520fd92495e Mon Sep 17 00:00:00 2001 From: Kittapath Date: Mon, 8 Jul 2024 09:21:24 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=AB=E0=B8=A1=E0=B8=B2=E0=B8=A2=E0=B9=80=E0=B8=AB=E0=B8=95?= =?UTF-8?q?=E0=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 248 ++++++++++-------- src/controllers/SalaryController.ts | 26 +- .../SalaryPeriodEmployeeController.ts | 42 +-- src/entities/SalaryProfile.ts | 10 +- src/entities/SalaryProfileEmployee.ts | 8 + .../1720153855533-add_table_salary1.ts | 16 -- ...1720405140572-add_table_kpi_add_salary1.ts | 16 ++ 7 files changed, 204 insertions(+), 162 deletions(-) delete mode 100644 src/migration/1720153855533-add_table_salary1.ts create mode 100644 src/migration/1720405140572-add_table_kpi_add_salary1.ts diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 972a29b..57da8a4 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1057,7 +1057,11 @@ export class ReportController extends Controller { * @param {string} salaryPeriodId Guid, *Id Period */ @Get("gov-03/{rootId}/{salaryPeriodId}/{group}") - async SalaryReport3(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { + async SalaryReport3( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -1112,7 +1116,7 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriodIncrease1_OCT?.id, @@ -1128,7 +1132,6 @@ export class ReportController extends Controller { // type: "FULL", }, }); - //รอบปีก่อนหน้า const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({ @@ -1153,7 +1156,7 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriodIncrease2_OCT?.id, @@ -1162,14 +1165,14 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryProfile2 = await this.salaryProfileRepository.find({ where: { salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]), // type: "FULL", }, }); - + const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))); const yearIncrease1 = Extension.ToThaiNumber( String(Extension.ToThaiYear(salaryPeriod.year - 2)), @@ -1252,8 +1255,8 @@ export class ReportController extends Controller { : "ไม่ได้เลื่อนขั้น"; })() : null, //การเลื่อนเงินเดือนปีก่อนหน้า - score: null, //ผลการประเมินฯ - remark: null, //หมายเหตุ + score: item.result, //ผลการประเมินฯ + remark: item.remark, //หมายเหตุ })) : null, profileGroup2: salaryProfileGroup2 @@ -1303,8 +1306,8 @@ export class ReportController extends Controller { : "ไม่ได้เลื่อนขั้น"; })() : null, //การเลื่อนเงินเดือนปีก่อนหน้า - score: null, //ผลการประเมินฯ - remark: null, //หมายเหตุ + score: item.result, //ผลการประเมินฯ + remark: item.remark, //หมายเหตุ })) : null, }, @@ -1326,14 +1329,14 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryProfile_APR = await this.salaryProfileRepository.find({ where: { salaryOrgId: salaryOrg_APR?.id, // type: In(["HAFT", "FULL"]), }, }); - + //end period APR const salaryProfileGroup1 = await this.salaryProfileRepository.find({ @@ -1372,7 +1375,7 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriodIncrease1_OCT?.id, @@ -1381,14 +1384,13 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryProfile1 = await this.salaryProfileRepository.find({ where: { salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]), // type: "FULL", }, }); - //รอบปีก่อนหน้า const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({ @@ -1413,7 +1415,7 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriodIncrease2_OCT?.id, @@ -1422,14 +1424,14 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + const salaryProfile2 = await this.salaryProfileRepository.find({ where: { salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]), // type: "FULL", }, }); - + const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))); const yearIncrease1 = Extension.ToThaiNumber( String(Extension.ToThaiYear(salaryPeriod.year - 2)), @@ -1541,7 +1543,7 @@ export class ReportController extends Controller { : item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : null, - score1: null, //ผลการประเมินฯ ครั้งที่ 1 + score1: item.result, //ผลการประเมินฯ ครั้งที่ 1 score2: null, //ผลการประเมินฯ ครั้งที่ 2 })) : null, @@ -1621,7 +1623,7 @@ export class ReportController extends Controller { : item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : null, - score1: null, //ผลการประเมินฯ ครั้งที่ 1 + score1: item.result, //ผลการประเมินฯ ครั้งที่ 1 score2: null, //ผลการประเมินฯ ครั้งที่ 2 })) : null, @@ -1725,7 +1727,7 @@ export class ReportController extends Controller { profile.amountSpecial == 0 ? "" : `(${Extension.ToThaiNumber(String(profile.amountSpecial.toLocaleString()))})`), - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน remark: `${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + `${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` + @@ -1755,7 +1757,11 @@ export class ReportController extends Controller { * @param {string} salaryPeriodId Guid, *Id Period */ @Get("gov-04-01/{rootId}/{salaryPeriodId}/{group}") - async SalaryReport4Retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { + async SalaryReport4Retire( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -1830,7 +1836,7 @@ export class ReportController extends Controller { profile.amountSpecial == 0 ? "" : `(${Extension.ToThaiNumber(String(profile.amountSpecial.toLocaleString()))})`), - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน remark: `${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + `${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` + @@ -1929,8 +1935,8 @@ export class ReportController extends Controller { Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, //เหตุผล - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - remark: null, //หมายเหตุ + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + remark: profile.remark, //หมายเหตุ }; }); @@ -1954,7 +1960,11 @@ export class ReportController extends Controller { * @param {string} salaryPeriodId Guid, *Id Period */ @Get("gov-05-01/{rootId}/{salaryPeriodId}/{group}") - async SalaryReport5retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { + async SalaryReport5retire( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2020,8 +2030,8 @@ export class ReportController extends Controller { Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, //เหตุผล - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - remark: null, //หมายเหตุ + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + remark: profile.remark, //หมายเหตุ }; }); @@ -2164,7 +2174,11 @@ export class ReportController extends Controller { * @param {string} salaryPeriodId Guid, *Id Period */ @Get("gov-07-01/{rootId}/{salaryPeriodId}/{group}") - async SalaryReport7retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { + async SalaryReport7retire( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2262,7 +2276,11 @@ export class ReportController extends Controller { * @param {string} salaryPeriodId Guid, *Id Period */ @Get("gov-08/{rootId}/{salaryPeriodId}/{group}") - async SalaryReport8(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { + async SalaryReport8( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2284,7 +2302,6 @@ export class ReportController extends Controller { }, relations: ["salaryProfiles"], }); - const salaryProfileSpecial = await this.salaryProfileRepository.find({ relations: ["salaryOrg"], @@ -2619,8 +2636,8 @@ export class ReportController extends Controller { Extension.ToThaiNumber(profile.orgShortName) + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - score: null, - reason: null, + score: profile.result, + reason: profile.remark, }; }); @@ -2706,8 +2723,8 @@ export class ReportController extends Controller { positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - reason: null, + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + reason: profile.remark, }; }); @@ -2793,8 +2810,8 @@ export class ReportController extends Controller { : "", amountSpecial: profile.amountSpecial > 0 ? Extension.ToThaiNumber(profile.amountSpecial.toString()) : "", - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - reason: null, + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + reason: profile.remark, }; }); @@ -2874,8 +2891,8 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, reasonSign: null, - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - reason: null, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + reason: profile.remark, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง }; }); @@ -2955,8 +2972,8 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, reasonSign: null, - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - reason: null, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + reason: profile.remark, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง }; }); @@ -3146,8 +3163,8 @@ export class ReportController extends Controller { : profile.type === "FULL" ? "๑ ขั้น" : "ไม่ได้เลื่อนขั้นฯ", - score: null, //ผลการประเมิน - remark: null, //หมายเหตุ + score: profile.result, //ผลการประเมิน + remark: profile.remark, //หมายเหตุ }; }); @@ -3378,7 +3395,7 @@ export class ReportController extends Controller { positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน remark: `${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + `${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` + @@ -3459,8 +3476,8 @@ export class ReportController extends Controller { Extension.ToThaiNumber(profile.orgShortName) + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - reason: null, // หมายเหตุ + score: profile.result, //สรุปผลการประเมินฯ ระดับและคะแนน + reason: profile.remark, // หมายเหตุ }; }); @@ -4380,7 +4397,7 @@ export class ReportController extends Controller { : profile.type === "FULLHAFT" ? "๑.๕ ขั้น" : "ไม่ได้เลื่อนขั้นฯ", - score1: null, + score1: profile.result, score2: null, }; }); @@ -4482,8 +4499,8 @@ export class ReportController extends Controller { positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, - score: null, - reason: null, + score: profile.result, + reason: profile.remark, }; }); @@ -4662,8 +4679,8 @@ export class ReportController extends Controller { positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, - score: null, - reason: null, + score: profile.result, + reason: profile.remark, }; }); @@ -4745,8 +4762,8 @@ export class ReportController extends Controller { Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, - score: null, - signature: null, + score: profile.result, + signature: profile.remark, }; }); @@ -5012,9 +5029,9 @@ export class ReportController extends Controller { : profile.type === "FULLHAFT" ? "๑.๕ ขั้น" : "ไม่ได้เลื่อนขั้นฯ", - score1: null, + score1: profile.result, score2: null, - reason: null, + reason: profile.remark, }; }); @@ -5115,8 +5132,8 @@ export class ReportController extends Controller { reason1: null, //เหตุผลที่ไม่ได้เลื่อนขั้น reason2: null, //เหตุผลที่ไม่ได้เลื่อนขั้น reason3: null, //เหตุผลที่ไม่ได้เลื่อนขั้น - score: null, - reason: null, + score: profile.result, + reason: profile.remark, }; }); const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))); @@ -6225,7 +6242,8 @@ export class ReportController extends Controller { */ @Post("command/33/resume") async SalaryReport33Resume( - @Body() body: { result: { id: string; personId: string }[] }, + @Body() + body: { result: { id: string; refCommandNo: string; templateDoc: string; personId: string }[] }, @Request() request: { user: Record }, ) { await Promise.all( @@ -6241,7 +6259,7 @@ export class ReportController extends Controller { profileId: salary.profileId, date: new Date(), amount: salary.positionSalaryAmount, - positionSalaryAmount: null, + positionSalaryAmount: salary.amountSpecial, mouthSalaryAmount: null, posNo: salary.orgShortName + salary.posMasterNo, position: salary.position, @@ -6250,8 +6268,8 @@ export class ReportController extends Controller { positionExecutive: salary.posExecutive, positionType: salary.posType, positionLevel: salary.posLevel, - refCommandNo: null, - templateDoc: null, + refCommandNo: v.refCommandNo, + templateDoc: v.templateDoc, }) .then(async (x) => { salary.status = "DONE"; @@ -6272,7 +6290,8 @@ export class ReportController extends Controller { */ @Post("command/34/resume") async SalaryReport34Resume( - @Body() body: { result: { id: string; personId: string }[] }, + @Body() + body: { result: { id: string; refCommandNo: string; templateDoc: string; personId: string }[] }, @Request() request: { user: Record }, ) { await Promise.all( @@ -6288,7 +6307,7 @@ export class ReportController extends Controller { profileId: salary.profileId, date: new Date(), amount: salary.positionSalaryAmount, - positionSalaryAmount: null, + positionSalaryAmount: salary.amountSpecial, mouthSalaryAmount: null, posNo: salary.orgShortName + salary.posMasterNo, position: salary.position, @@ -6297,8 +6316,8 @@ export class ReportController extends Controller { positionExecutive: salary.posExecutive, positionType: salary.posType, positionLevel: salary.posLevel, - refCommandNo: null, - templateDoc: null, + refCommandNo: v.refCommandNo, + templateDoc: v.templateDoc, }) .then(async (x) => { salary.status = "DONE"; @@ -6319,7 +6338,8 @@ export class ReportController extends Controller { */ @Post("command/35/resume") async SalaryReport35Resume( - @Body() body: { result: { id: string; personId: string }[] }, + @Body() + body: { result: { id: string; refCommandNo: string; templateDoc: string; personId: string }[] }, @Request() request: { user: Record }, ) { await Promise.all( @@ -6335,7 +6355,7 @@ export class ReportController extends Controller { profileId: salary.profileId, date: new Date(), amount: salary.positionSalaryAmount, - positionSalaryAmount: null, + positionSalaryAmount: salary.amountSpecial, mouthSalaryAmount: null, posNo: salary.orgShortName + salary.posMasterNo, position: salary.position, @@ -6344,8 +6364,8 @@ export class ReportController extends Controller { positionExecutive: salary.posExecutive, positionType: salary.posType, positionLevel: salary.posLevel, - refCommandNo: null, - templateDoc: null, + refCommandNo: v.refCommandNo, + templateDoc: v.templateDoc, }) .then(async (x) => { salary.status = "DONE"; @@ -6366,7 +6386,8 @@ export class ReportController extends Controller { */ @Post("command/36/resume") async SalaryReport36Resume( - @Body() body: { result: { id: string; personId: string }[] }, + @Body() + body: { result: { id: string; refCommandNo: string; templateDoc: string; personId: string }[] }, @Request() request: { user: Record }, ) { await Promise.all( @@ -6377,27 +6398,27 @@ export class ReportController extends Controller { }, }); if (salary != null) { - // await new CallAPI() - // .PostData(request, "org/profile/salary", { - // profileId: salary.profileId, - // date: new Date(), - // amount: salary.positionSalaryAmount, - // positionSalaryAmount: null, - // mouthSalaryAmount: null, - // posNo: salary.orgShortName + salary.posMasterNo, - // position: salary.position, - // positionLine: null, - // positionPathSide: null, - // positionExecutive: null, - // positionType: salary.posType, - // positionLevel: salary.posLevel, - // refCommandNo: null, - // templateDoc: null, - // }) - // .then(async (x) => { - salary.status = "DONE"; - await this.salaryProfileEmployeeRepository.save(salary); - // }); + await new CallAPI() + .PostData(request, "org/profile/salary", { + profileId: salary.profileId, + date: new Date(), + amount: salary.positionSalaryAmount, + positionSalaryAmount: salary.amountSpecial, + mouthSalaryAmount: null, + posNo: salary.orgShortName + salary.posMasterNo, + position: salary.position, + positionLine: null, + positionPathSide: null, + positionExecutive: null, + positionType: salary.posType, + positionLevel: salary.posLevel, + refCommandNo: v.refCommandNo, + templateDoc: v.templateDoc, + }) + .then(async (x) => { + salary.status = "DONE"; + await this.salaryProfileEmployeeRepository.save(salary); + }); } }), ); @@ -6413,7 +6434,8 @@ export class ReportController extends Controller { */ @Post("command/37/resume") async SalaryReport37Resume( - @Body() body: { result: { id: string; personId: string }[] }, + @Body() + body: { result: { id: string; refCommandNo: string; templateDoc: string; personId: string }[] }, @Request() request: { user: Record }, ) { await Promise.all( @@ -6424,27 +6446,27 @@ export class ReportController extends Controller { }, }); if (salary != null) { - // await new CallAPI() - // .PostData(request, "org/profile/salary", { - // profileId: salary.profileId, - // date: new Date(), - // amount: salary.positionSalaryAmount, - // positionSalaryAmount: null, - // mouthSalaryAmount: null, - // posNo: salary.orgShortName + salary.posMasterNo, - // position: salary.position, - // positionLine: null, - // positionPathSide: null, - // positionExecutive: null, - // positionType: salary.posType, - // positionLevel: salary.posLevel, - // refCommandNo: null, - // templateDoc: null, - // }) - // .then(async (x) => { - salary.status = "DONE"; - await this.salaryProfileEmployeeRepository.save(salary); - // }); + await new CallAPI() + .PostData(request, "org/profile-employee/salary", { + profileEmployeeId: salary.profileId, + date: new Date(), + amount: salary.positionSalaryAmount, + positionSalaryAmount: salary.amountSpecial, + mouthSalaryAmount: null, + posNo: salary.orgShortName + salary.posMasterNo, + position: salary.position, + positionLine: null, + positionPathSide: null, + positionExecutive: null, + positionType: salary.posType, + positionLevel: salary.posLevel, + refCommandNo: v.refCommandNo, + templateDoc: v.templateDoc, + }) + .then(async (x) => { + salary.status = "DONE"; + await this.salaryProfileEmployeeRepository.save(salary); + }); } }), ); diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index f619ad5..74bc80f 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -251,19 +251,19 @@ export class SalaryController extends Controller { where: { id: id }, }); - const formattedData = { - name: salary?.name ?? null, - isSpecial: salary?.isSpecial ?? null, - posTypeId: salary?.posTypeId ?? null, - posTypeName: salary?.posType_.posTypeName ?? null, - posLevelId: salary?.posLevelId ?? null, - posLevelName: salary?.posLevel_.posLevelName ?? null, - isActive: salary?.isActive ?? null, - date: salary?.date ?? null, - startDate: salary?.startDate ?? null, - endDate: salary?.endDate ?? null, - details: salary?.details ?? null, - }; + const formattedData = { + name: salary?.name ?? null, + isSpecial: salary?.isSpecial ?? null, + posTypeId: salary?.posTypeId ?? null, + posTypeName: salary?.posType_.posTypeName ?? null, + posLevelId: salary?.posLevelId ?? null, + posLevelName: salary?.posLevel_.posLevelName ?? null, + isActive: salary?.isActive ?? null, + date: salary?.date ?? null, + startDate: salary?.startDate ?? null, + endDate: salary?.endDate ?? null, + details: salary?.details ?? null, + }; if (!salary) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผังเงินเดือนนี้"); } diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index 089918f..4c092f7 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -615,19 +615,19 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.02; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.02); } else if (step - salaryRankAmountMax.step <= 1) { salaryProfile.positionSalaryAmountPer = 0.04; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.04; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.04); } else { salaryProfile.positionSalaryAmountPer = 0.06; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.06; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.06); } } else { salaryProfile.positionSalaryAmountPer = 0; @@ -674,19 +674,19 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.02; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.02); } else if (step - salaryRankAmountMax.step <= 1) { salaryProfile.positionSalaryAmountPer = 0.04; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.04; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.04); } else { salaryProfile.positionSalaryAmountPer = 0.06; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.06; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.06); } } else { salaryProfile.positionSalaryAmountPer = 0; @@ -929,7 +929,9 @@ export class SalaryPeriodEmployeeController extends Controller { * @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น */ @Post("change/type") - async changeType(@Body() body: { profileId: string; type: string; isReserve: boolean }) { + async changeType( + @Body() body: { profileId: string; type: string; isReserve: boolean; remark?: string | null }, + ) { const salaryProfile = await this.salaryProfileRepository.findOne({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { id: body.profileId }, @@ -989,6 +991,8 @@ export class SalaryPeriodEmployeeController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง"); } salaryProfile.type = body.type; + let _null: any = null; + salaryProfile.remark = body.remark == null ? _null : body.remark; let type = salaryProfile.type; if (type == "NONE") { @@ -1216,19 +1220,19 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.02; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.02); } else if (step - salaryRankAmountMax.step <= 1) { salaryProfile.positionSalaryAmountPer = 0.04; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.04; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.04); } else { salaryProfile.positionSalaryAmountPer = 0.06; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.06; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.06); } } else { salaryProfile.positionSalaryAmountPer = 0; @@ -1278,19 +1282,19 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.02; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.02); } else if (step - salaryRankAmountMax.step <= 1) { salaryProfile.positionSalaryAmountPer = 0.04; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.04; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.04); } else { salaryProfile.positionSalaryAmountPer = 0.06; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.06; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.06); } } else { salaryProfile.positionSalaryAmountPer = 0; @@ -1866,19 +1870,19 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.02; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.02); } else if (step - salaryRankAmountMax.step <= 1) { salaryProfile.positionSalaryAmountPer = 0.04; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.04; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.04); } else { salaryProfile.positionSalaryAmountPer = 0.06; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.06; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.06); } } else { salaryProfile.positionSalaryAmountPer = 0; @@ -1927,19 +1931,19 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.02; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.02); } else if (step - salaryRankAmountMax.step <= 1) { salaryProfile.positionSalaryAmountPer = 0.04; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.04; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.04); } else { salaryProfile.positionSalaryAmountPer = 0.06; salaryProfile.amountSpecial = salaryRankAmountMax == null || salaryRankAmountMax.salaryMonth == null ? 0 - : salaryRankAmountMax.salaryMonth * 0.06; + : Math.floor(salaryRankAmountMax.salaryMonth * 0.06); } } else { salaryProfile.positionSalaryAmountPer = 0; diff --git a/src/entities/SalaryProfile.ts b/src/entities/SalaryProfile.ts index 60def05..071657b 100644 --- a/src/entities/SalaryProfile.ts +++ b/src/entities/SalaryProfile.ts @@ -251,10 +251,18 @@ export class SalaryProfile extends EntityBase { nullable: true, default: null, length: 255, - comment: "ผลการประเมินผลการปฏิบัติราชการ",//คะแนนประเมิน + comment: "ผลการประเมินผลการปฏิบัติราชการ", //คะแนนประเมิน }) result: string; + @Column({ + nullable: true, + default: null, + type: "text", + comment: "หมายเหตุ", + }) + remark: string; + @Column({ nullable: true, comment: "ระยะเวลาการปฏิบัติราชการในรอบครึ่งปี", diff --git a/src/entities/SalaryProfileEmployee.ts b/src/entities/SalaryProfileEmployee.ts index d9657bc..e577734 100644 --- a/src/entities/SalaryProfileEmployee.ts +++ b/src/entities/SalaryProfileEmployee.ts @@ -306,6 +306,14 @@ export class SalaryProfileEmployee extends EntityBase { }) result: string; + @Column({ + nullable: true, + default: null, + type: "text", + comment: "หมายเหตุ", + }) + remark: string; + @Column({ nullable: true, comment: "ระยะเวลาการปฏิบัติราชการในรอบครึ่งปี", diff --git a/src/migration/1720153855533-add_table_salary1.ts b/src/migration/1720153855533-add_table_salary1.ts deleted file mode 100644 index bd4deb2..0000000 --- a/src/migration/1720153855533-add_table_salary1.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableSalary11720153855533 implements MigrationInterface { - name = 'AddTableSalary11720153855533' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`result\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`result\` varchar(255) NULL COMMENT 'ผลการประเมินผลการปฏิบัติราชการ'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`result\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`result\` double NULL COMMENT 'ผลการประเมินผลการปฏิบัติราชการ'`); - } - -} diff --git a/src/migration/1720405140572-add_table_kpi_add_salary1.ts b/src/migration/1720405140572-add_table_kpi_add_salary1.ts new file mode 100644 index 0000000..32b241f --- /dev/null +++ b/src/migration/1720405140572-add_table_kpi_add_salary1.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableKpiAddSalary11720405140572 implements MigrationInterface { + name = 'AddTableKpiAddSalary11720405140572' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`remark\` text NULL COMMENT 'หมายเหตุ'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`remark\` text NULL COMMENT 'หมายเหตุ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`remark\``); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`remark\``); + } + +}