From 8236caf458f162cf51f00a6c997a7290f8ba8f82 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 15 Jun 2026 11:52:20 +0700 Subject: [PATCH] fix #1594 --- src/controllers/ProfileChangeNameController.ts | 14 +++++++++----- .../ProfileChangeNameEmployeeController.ts | 12 ++++++++---- .../ProfileChangeNameEmployeeTempController.ts | 12 ++++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 3f61301f..8eea3a9e 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -111,10 +111,12 @@ export class ProfileChangeNameController extends Controller { setLogDataDiff(req, { before, after: history }); profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; - profile.prefix = body.prefix ?? profile.prefix; + // profile.prefix = body.prefix ?? profile.prefix; //old profile.rank = body.rank ?? profile.rank; - profile.prefixMain = profile.rank ?? profile.prefix; - + // profile.prefixMain = profile.rank ?? profile.prefix; // old + profile.prefixMain = profile.prefix; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; + await this.profileRepository.save(profile, { data: req }); setLogDataDiff(req, { before, after: profile }); @@ -185,9 +187,11 @@ export class ProfileChangeNameController extends Controller { if (profile && chkLastRecord.id === record.id) { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; - profile.prefix = body.prefix ?? profile.prefix; + // profile.prefix = body.prefix ?? profile.prefix; //old profile.rank = body.rank ?? profile.rank; - profile.prefixMain = profile.rank ?? profile.prefix; + // profile.prefixMain = profile.rank ?? profile.prefix; // old + profile.prefixMain = profile.prefix; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; await this.profileRepository.save(profile, { data: req }); setLogDataDiff(req, { before: before_profile, after: profile }); } diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index 91dd3d55..6e28c477 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -117,9 +117,11 @@ export class ProfileChangeNameEmployeeController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; - profile.prefix = body.prefix ?? profile.prefix; + // profile.prefix = body.prefix ?? profile.prefix; //old profile.rank = body.rank ?? profile.rank; - profile.prefixMain = profile.rank ?? profile.prefix; + // profile.prefixMain = profile.rank ?? profile.prefix; // old + profile.prefixMain = profile.prefix; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; await this.profileEmployeeRepo.save(profile, { data: req }); setLogDataDiff(req, { before, after: profile }); @@ -191,9 +193,11 @@ export class ProfileChangeNameEmployeeController extends Controller { if (profile && chkLastRecord.id === record.id) { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; - profile.prefix = body.prefix ?? profile.prefix; + // profile.prefix = body.prefix ?? profile.prefix; //old profile.rank = body.rank ?? profile.rank; - profile.prefixMain = profile.rank ?? profile.prefix; + // profile.prefixMain = profile.rank ?? profile.prefix; // old + profile.prefixMain = profile.prefix; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; await this.profileEmployeeRepo.save(profile); } diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index 7f7b39aa..05dd9312 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -108,9 +108,11 @@ export class ProfileChangeNameEmployeeTempController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; - profile.prefix = body.prefix ?? profile.prefix; + // profile.prefix = body.prefix ?? profile.prefix; //old profile.rank = body.rank ?? profile.rank; - profile.prefixMain = profile.rank ?? profile.prefix; + // profile.prefixMain = profile.rank ?? profile.prefix; // old + profile.prefixMain = profile.prefix; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; await this.profileEmployeeRepo.save(profile, { data: req }); setLogDataDiff(req, { before, after: profile }); @@ -179,9 +181,11 @@ export class ProfileChangeNameEmployeeTempController extends Controller { if (profile && chkLastRecord.id === record.id) { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; - profile.prefix = body.prefix ?? profile.prefix; + // profile.prefix = body.prefix ?? profile.prefix; //old profile.rank = body.rank ?? profile.rank; - profile.prefixMain = profile.rank ?? profile.prefix; + // profile.prefixMain = profile.rank ?? profile.prefix; // old + profile.prefixMain = profile.prefix; + profile.prefix = profile.rank && profile.rank.length > 0 ? profile.rank : profile.prefixMain; await this.profileEmployeeRepo.save(profile); }