From 15cf60d19d3b31f8560517986ccb84ae4332fdb3 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 8 Mar 2024 16:15:18 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B8=9C=E0=B8=B1=E0=B8=87=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A?= =?UTF-8?q?=E0=B8=B5=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94?= =?UTF-8?q?=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryController.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index 31826c8..955e02b 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -137,9 +137,8 @@ export class Salary extends Controller { ); } - const chk_3fields = await this.salaryRepository.findOne({ + const chk_3fields = await this.salaryRepository.find({ where: { - name: requestBody.name, posTypeId: requestBody.posTypeId, posLevelId: requestBody.posLevelId, isActive: true, @@ -147,11 +146,14 @@ export class Salary extends Controller { }, }); - if (chk_3fields != null && requestBody.isActive) { - chk_3fields.isActive = false; - chk_3fields.lastUpdateUserId = request.user.sub; - chk_3fields.lastUpdateFullName = request.user.name; - chk_3fields.lastUpdatedAt = new Date(); + if (chk_3fields.length > 0 && requestBody.isActive) { + chk_3fields.forEach(async (item) => { + item.isActive = false; + item.lastUpdateUserId = request.user.sub; + item.lastUpdateFullName = request.user.name; + item.lastUpdatedAt = new Date(); + await this.salaryRepository.save(chk_3fields); + }); await this.salaryRepository.save(chk_3fields); }