From 750c3a089b6b2a0ef4dbd19b730d14978b15d2a6 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 21 Jul 2025 11:38:35 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=E0=B8=84=E0=B8=B9=E0=B9=88=E0=B8=AA=E0=B8=A1=E0=B8=A3=E0=B8=AA?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B9=89=E0=B8=A7=E0=B9=84=E0=B8=A1=E0=B9=88?= =?UTF-8?q?=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=20#1637,=20=20#1645?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileFamilyCoupleController.ts | 6 +++++- src/controllers/ProfileFamilyCoupleEmployeeController.ts | 6 +++++- .../ProfileFamilyCoupleEmployeeTempController.ts | 5 +++++ src/controllers/ProfileSalaryTempController.ts | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileFamilyCoupleController.ts b/src/controllers/ProfileFamilyCoupleController.ts index eb4c27fe..6da38a00 100644 --- a/src/controllers/ProfileFamilyCoupleController.ts +++ b/src/controllers/ProfileFamilyCoupleController.ts @@ -170,6 +170,10 @@ export class ProfileFamilyCoupleController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); + await this.ProfileFamilyCouple.update( + { profileId: profile.id }, + { couple: false }, + ); const before = null; familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId)); familyCouple.createdUserId = req.user.sub; @@ -178,7 +182,7 @@ export class ProfileFamilyCoupleController extends Controller { familyCouple.lastUpdateFullName = req.user.name; familyCouple.createdAt = new Date(); familyCouple.lastUpdatedAt = new Date(); - + familyCouple.couple = true; profile.relationship = familyCouple.relationship; //update profileEmployee.relationship const history = new ProfileFamilyCoupleHistory(); Object.assign(history, { ...familyCouple, id: undefined }); diff --git a/src/controllers/ProfileFamilyCoupleEmployeeController.ts b/src/controllers/ProfileFamilyCoupleEmployeeController.ts index 723ef57f..3e021d09 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeController.ts @@ -161,6 +161,10 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id); + await this.ProfileFamilyCouple.update( + { profileEmployeeId: profile.id }, + { couple: false }, + ); const before = null; familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId)); familyCouple.createdUserId = req.user.sub; @@ -169,7 +173,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { familyCouple.lastUpdateFullName = req.user.name; familyCouple.createdAt = new Date(); familyCouple.lastUpdatedAt = new Date(); - + familyCouple.couple = true; profile.relationship = familyCouple.relationship; //update profileEmployee.relationship const history = new ProfileFamilyCoupleHistory(); Object.assign(history, { ...familyCouple, id: undefined }); diff --git a/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts b/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts index 7eb5ee44..c44aa8e9 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts @@ -161,6 +161,10 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } + await this.ProfileFamilyCouple.update( + { profileEmployeeId: profile.id }, + { couple: false }, + ); familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId)); familyCouple.createdUserId = req.user.sub; familyCouple.createdFullName = req.user.name; @@ -168,6 +172,7 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller { familyCouple.lastUpdateFullName = req.user.name; familyCouple.createdAt = new Date(); familyCouple.lastUpdatedAt = new Date(); + familyCouple.couple = true; await this.ProfileFamilyCouple.save(familyCouple); profile.relationship = familyCouple.relationship; //update profileEmployee.relationship diff --git a/src/controllers/ProfileSalaryTempController.ts b/src/controllers/ProfileSalaryTempController.ts index c853524c..81cc1751 100644 --- a/src/controllers/ProfileSalaryTempController.ts +++ b/src/controllers/ProfileSalaryTempController.ts @@ -1005,7 +1005,7 @@ export class ProfileSalaryTempController extends Controller { ...rest, isDelete: false, isEdit: false, - isEntry: rest.isEntry, + isEntry: rest.isEntry ?? false, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -1045,7 +1045,7 @@ export class ProfileSalaryTempController extends Controller { ...rest, isDelete: false, isEdit: false, - isEntry: rest.isEntry, + isEntry: rest.isEntry ?? false, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub,