diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 81004807..09283b90 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,8 @@ env: REGISTRY: docker.frappet.com IMAGE_NAME: ehr/bma-ehr-org-service DEPLOY_HOST: frappet.com - COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-org + COMPOSE_PATH: /home/frappet/docker/bma-ehr + # COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-org jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 release-test: diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index b9d84df5..d12c6002 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1166,50 +1166,27 @@ export class ProfileController extends Controller { refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, //profile.position, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1266,50 +1243,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1362,50 +1314,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1458,50 +1385,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1568,50 +1470,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1664,50 +1541,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1760,50 +1612,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1856,50 +1683,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -1952,50 +1754,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -2048,50 +1825,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub, @@ -2134,68 +1886,44 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = body.date; - profile.isLeave = true; - profile.leaveReason = "ได้รับโทษทางวินัย ยุติเรื่อง"; - profile.dateLeave = dateLeave_; + let null_: any = null; + profile.isLeave = false; + profile.leaveReason = null_; + profile.dateLeave = null_; profile.lastUpdateUserId = req.user.sub; profile.lastUpdateFullName = req.user.name; - const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { - profileId: body.profileId, - date: body.date, - refCommandNo: body.refCommandNo, - templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, - positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, - positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, - positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, - positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, - order: - profile.profileSalary.length >= 0 - ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 - : 1 - : null, - createdUserId: req.user.sub, - createdFullName: req.user.name, - lastUpdateUserId: req.user.sub, - lastUpdateFullName: req.user.name, - }); - await Promise.all([this.profileRepo.save(profile), this.salaryRepository.save(profileSalary)]); + // const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { + // profileId: body.profileId, + // date: body.date, + // refCommandNo: body.refCommandNo, + // templateDoc: body.salaryRef, + // position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + // positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, + // positionLevel: + // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + // posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + // positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, + // positionPathSide: + // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, + // positionExecutive: + // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + // amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, + // positionSalaryAmount: + // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, + // mouthSalaryAmount: + // profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + // order: + // profile.profileSalary.length >= 0 + // ? profile.profileSalary.length > 0 + // ? profile.profileSalary[0].order + 1 + // : 1 + // : null, + // createdUserId: req.user.sub, + // createdFullName: req.user.name, + // lastUpdateUserId: req.user.sub, + // lastUpdateFullName: req.user.name, + // }); + await Promise.all([this.profileRepo.save(profile)]); return new HttpSuccess(); } @@ -2240,50 +1968,25 @@ export class ProfileController extends Controller { date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].position - : null, - positionType: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionType - : null, + position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, + positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, positionLevel: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLevel - : null, - posNo: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].posNo - : null, - positionLine: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionLine - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, + posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, + positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, positionPathSide: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive - : null, - amount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].amount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, positionSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].positionSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, mouthSalaryAmount: - profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].mouthSalaryAmount - : null, + profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 - ? profile.profileSalary[profile.profileSalary.length - 1].order + 1 + ? profile.profileSalary[0].order + 1 : 1 : null, createdUserId: req.user.sub,