From e05e6c625ed2bfc4a3f9a3316973d52aa06a7105 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 25 Mar 2024 15:57:38 +0700 Subject: [PATCH 1/7] emp1-09 --- src/controllers/ReportController.ts | 85 +++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 8fb9136..47afc2d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2487,33 +2487,73 @@ export class ReportController extends Controller { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, + period: "APR", + isActive: true }, }); if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } - const _salaryPeriod = await this.salaryProfileRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + + const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + year: salaryPeriod.year - 1, + period: "APR", + isActive: true + }, + }); + const salaryPeriodOCT = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + year: salaryPeriod.year - 1, + period: "OCT", + isActive: true + }, + }); + + const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg",], where: { salaryOrg: { - snapshot: "SNAP1", + snapshot: "SNAP2", rootId: rootId, salaryPeriodId: salaryPeriodId, }, + type: "NONE" }, order: { orgShortName: "ASC", posMasterNo: "ASC", }, }); - - if (!_salaryPeriod) { + if (!_salaryProfileEmp) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } + + const _salaryProfileEmpAPR = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg",], + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodAPR?.id, + } + } + }); + const _salaryProfileEmpOCT = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg",], + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodOCT?.id, + } + } + }); - const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; - - const formattedData = _salaryPeriod.map((profile, index) => { + const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; + const formattedData = _salaryProfileEmp.map((profile, index) => { const fullNameParts = [ profile.child4, profile.child3, @@ -2530,11 +2570,31 @@ export class ReportController extends Controller { return { no: Extension.ToThaiNumber((index + 1).toLocaleString()), fullName: fullName, - posLevel: profile.posLevel, + position: profile.position, posNumber: profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), - amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - reason: null, + amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "๐", + type1: _salaryProfileEmpAPR.length > 0 + ? (() => { + const type = _salaryProfileEmpAPR + .filter((profileAPR) => profileAPR.citizenId === profile.citizenId) + .map((profile) => profile.type); + const Type = type[0]; + return Type === "HALF" ? "0.5 ขั้น" : Type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; + })() + : null, //เมษา ปีก่อนหน้า + type2: _salaryProfileEmpOCT.length > 0 + ? (() => { + const type = _salaryProfileEmpOCT + .filter((profileOCT) => profileOCT.citizenId === profile.citizenId) + .map((profile) => profile.type); + const Type = type[0]; + return Type === "HALF" ? "0.5 ขั้น" : Type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; + })() + : null, //ตุลา ปีก่อนหน้า + type: profile.type === "HALF" ? "0.5 ขั้น" : profile.type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ", + score: null, //ผลการประเมิน + remark: null, //หมายเหตุ }; }); @@ -2543,11 +2603,14 @@ export class ReportController extends Controller { reportName: "emp1-09", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), + yearBeforeSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1)).slice(-2)), + yearSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2)), agency: agency, data: formattedData, }, }); } + // /** // * API 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น // * From b17a55da72619bb29076126a9f40542ba1759aaf Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 25 Mar 2024 16:28:48 +0700 Subject: [PATCH 2/7] isNext --- src/controllers/ReportController.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 47afc2d..6dfea32 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2479,7 +2479,7 @@ export class ReportController extends Controller { /** * API 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง * - * @summary 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง + * @summary 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง bright * */ @Get("emp1-09/{rootId}/{salaryPeriodId}") @@ -2576,23 +2576,29 @@ export class ReportController extends Controller { amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "๐", type1: _salaryProfileEmpAPR.length > 0 ? (() => { - const type = _salaryProfileEmpAPR + const _profile = _salaryProfileEmpAPR .filter((profileAPR) => profileAPR.citizenId === profile.citizenId) - .map((profile) => profile.type); - const Type = type[0]; - return Type === "HALF" ? "0.5 ขั้น" : Type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; + .map((profile) => ({ type: profile.type, isNext: profile.isNext, positionSalaryAmountPer: profile.positionSalaryAmountPer })); + if(_profile[0].isNext){ + return _profile[0].positionSalaryAmountPer === 0.02 ? "2%" : _profile[0].positionSalaryAmountPer === 0.04 ? "4%": "6%" + } + return _profile[0].type === "HALF" ? "0.5 ขั้น" : _profile[0].type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; })() : null, //เมษา ปีก่อนหน้า type2: _salaryProfileEmpOCT.length > 0 ? (() => { - const type = _salaryProfileEmpOCT + const _profile = _salaryProfileEmpOCT .filter((profileOCT) => profileOCT.citizenId === profile.citizenId) - .map((profile) => profile.type); - const Type = type[0]; - return Type === "HALF" ? "0.5 ขั้น" : Type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; + .map((profile) => ({ type: profile.type, isNext: profile.isNext, positionSalaryAmountPer: profile.positionSalaryAmountPer })); + if(_profile[0].isNext){ + return _profile[0].positionSalaryAmountPer === 0.02 ? "2%" : _profile[0].positionSalaryAmountPer === 0.04 ? "4%": "6%" + } + return _profile[0].type === "HALF" ? "0.5 ขั้น" : _profile[0].type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; })() : null, //ตุลา ปีก่อนหน้า - type: profile.type === "HALF" ? "0.5 ขั้น" : profile.type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ", + type: profile.isNext === true + ? profile.positionSalaryAmountPer === 0.02 ? "2%" : profile.positionSalaryAmountPer === 0.04 ? "4%" : "6%" + : profile.type === "HALF" ? "0.5 ขั้น" : profile.type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ", score: null, //ผลการประเมิน remark: null, //หมายเหตุ }; From 2e273262de0127da7c69e4c0764667efb79be1ca Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 25 Mar 2024 16:29:35 +0700 Subject: [PATCH 3/7] no message --- src/controllers/ReportController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6dfea32..0c8fe1a 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2479,7 +2479,7 @@ export class ReportController extends Controller { /** * API 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง * - * @summary 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง bright + * @summary 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง * */ @Get("emp1-09/{rootId}/{salaryPeriodId}") From 04d746bb1817cb0ac395d7e7c83d485b90c3ba51 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 25 Mar 2024 16:36:41 +0700 Subject: [PATCH 4/7] thai num --- src/controllers/ReportController.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 0c8fe1a..e295ae0 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2580,9 +2580,9 @@ export class ReportController extends Controller { .filter((profileAPR) => profileAPR.citizenId === profile.citizenId) .map((profile) => ({ type: profile.type, isNext: profile.isNext, positionSalaryAmountPer: profile.positionSalaryAmountPer })); if(_profile[0].isNext){ - return _profile[0].positionSalaryAmountPer === 0.02 ? "2%" : _profile[0].positionSalaryAmountPer === 0.04 ? "4%": "6%" + return _profile[0].positionSalaryAmountPer === 0.02 ? "๒%" : _profile[0].positionSalaryAmountPer === 0.04 ? "๔%": "๖%" } - return _profile[0].type === "HALF" ? "0.5 ขั้น" : _profile[0].type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; + return _profile[0].type === "HALF" ? "๐.๕ ขั้น" : _profile[0].type === "FULL" ? "๑ ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; })() : null, //เมษา ปีก่อนหน้า type2: _salaryProfileEmpOCT.length > 0 @@ -2591,14 +2591,14 @@ export class ReportController extends Controller { .filter((profileOCT) => profileOCT.citizenId === profile.citizenId) .map((profile) => ({ type: profile.type, isNext: profile.isNext, positionSalaryAmountPer: profile.positionSalaryAmountPer })); if(_profile[0].isNext){ - return _profile[0].positionSalaryAmountPer === 0.02 ? "2%" : _profile[0].positionSalaryAmountPer === 0.04 ? "4%": "6%" + return _profile[0].positionSalaryAmountPer === 0.02 ? "๒%" : _profile[0].positionSalaryAmountPer === 0.04 ? "๔%": "๖%" } - return _profile[0].type === "HALF" ? "0.5 ขั้น" : _profile[0].type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; + return _profile[0].type === "HALF" ? "๐.๕ ขั้น" : _profile[0].type === "FULL" ? "๑ ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; })() : null, //ตุลา ปีก่อนหน้า type: profile.isNext === true - ? profile.positionSalaryAmountPer === 0.02 ? "2%" : profile.positionSalaryAmountPer === 0.04 ? "4%" : "6%" - : profile.type === "HALF" ? "0.5 ขั้น" : profile.type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ", + ? profile.positionSalaryAmountPer === 0.02 ? "๒%" : profile.positionSalaryAmountPer === 0.04 ? "๔%" : "๖%" + : profile.type === "HALF" ? "๐.๕ ขั้น" : profile.type === "FULL" ? "๑ ขั้น" : "ไม่ได้เลื่อนขั้นฯ", score: null, //ผลการประเมิน remark: null, //หมายเหตุ }; From 53945853c978df5a7a6a6d73153412e1f74be459 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 26 Mar 2024 09:53:28 +0700 Subject: [PATCH 5/7] =?UTF-8?q?fix=20=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81=E0=B9=80=E0=B8=81=E0=B8=93?= =?UTF-8?q?=E0=B8=91=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryFormulaEmployeeController.ts | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/controllers/SalaryFormulaEmployeeController.ts b/src/controllers/SalaryFormulaEmployeeController.ts index 8a3fff2..c5545cf 100644 --- a/src/controllers/SalaryFormulaEmployeeController.ts +++ b/src/controllers/SalaryFormulaEmployeeController.ts @@ -227,16 +227,20 @@ export class SalaryFormulaEmployeeController extends Controller { @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, ) { + let whereClause: any = {}; + if (keyword != undefined && keyword !== "") { + whereClause = { + where: [ + { details: Like(`%${keyword}%`) }, + { position: Like(`%${keyword}%`) }, + { posType: { posTypeName: Like(`%${keyword}%`)} }, + { posLevel: { posLevelName: Like(`%${keyword}%`)} }, + ], + }; + } const [getFormula, total] = await this.salaryFormulaEmployeeRepository.findAndCount({ relations: ["salaryEmployee", "posType", "posLevel", "salaryEmployeeMins"], - where: { - details: Like(`%${keyword}%`), - position: Like(`%${keyword}%`), - // posLevel: { posLevelName: keyword }, - posType: { posTypeName: Like(`%${keyword}%`) }, - // salaryEmployeeMins: { group: keyword }, - // salaryEmployee: { group: keyword }, - }, + ...whereClause, order: { lastUpdatedAt: "DESC", }, @@ -245,16 +249,13 @@ export class SalaryFormulaEmployeeController extends Controller { const mapFormula = getFormula.map((item) => ({ id: item.id, - // posLevelId: item.posLevelId, posLevel: item.posLevel != null ? item.posLevel.posLevelName : null, - position: item.position, //// - // posTypeId: item.posTypeId, + position: item.position, posType: item.posType != null ? item.posType.posTypeName : null, - details: item.details, //// - salaryMin: item.salaryMin, // - salary: item.salary, // - salaryMax: item.salaryMax, // - // salaryEmployeeId: item.salaryEmployeeId, + details: item.details, + salaryMin: item.salaryMin, + salary: item.salary, + salaryMax: item.salaryMax, group: item.salaryEmployee != null ? item.salaryEmployee.group : null, salaryEmployeeMin: item.salaryEmployeeMins != null ? item.salaryEmployeeMins.map((x) => x.group) : null, From ec4cf9015f2909fc243dcd530f62a6fba725f798 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 26 Mar 2024 10:28:40 +0700 Subject: [PATCH 6/7] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=AD=E0=B8=9A=E0=B8=95=E0=B8=B2=E0=B8=A1?= =?UTF-8?q?=E0=B8=9B=E0=B8=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 02cea59..fdc1f50 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1418,6 +1418,40 @@ export class SalaryPeriodController extends Controller { return new HttpSuccess(salaryPeriod); } + /** + * API รายการรอบเงินเดือน by year + * + * @summary SLR_020 - รายการรอบเงินเดือน by year + * + */ + @Get("active/{year}") + async GetListsSalaryPeriodByYear( + @Path() year: number, + @Query("page") page: number = 1, + @Query("pageSize") pageSize: number = 10, + @Query("keyword") keyword?: string, + ) { + const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod) + .createQueryBuilder("salaryPeriod") + .andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` }) + .select([ + "salaryPeriod.id", + "salaryPeriod.period", + "salaryPeriod.isActive", + "salaryPeriod.isClose", + "salaryPeriod.effectiveDate", + "salaryPeriod.status", + "salaryPeriod.year", + "salaryPeriod.revisionId", + ]) + .orderBy("salaryPeriod.effectiveDate", "DESC") + .skip((page - 1) * pageSize) + .take(pageSize) + .getManyAndCount(); + + return new HttpSuccess({ data: salaryPeriod, total }); + } + /** * API รายการรอบเงินเดือน * From 43ae1b5b07d2fd33a40dfa5cb6db827e476f703f Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 26 Mar 2024 10:30:02 +0700 Subject: [PATCH 7/7] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=E0=B8=AA=E0=B8=96?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=B0=E0=B8=A3=E0=B8=AD=E0=B8=9A=E0=B8=97?= =?UTF-8?q?=E0=B8=B5=E0=B9=88active?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index fdc1f50..f5f4bcd 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1434,6 +1434,7 @@ export class SalaryPeriodController extends Controller { const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod) .createQueryBuilder("salaryPeriod") .andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` }) + .andWhere({ isActive: true }) .select([ "salaryPeriod.id", "salaryPeriod.period",