diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 553d7a9..a0c508a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,7 +12,7 @@ env: COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-salary jobs: - # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=version-1.0.36 -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 + # 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: runs-on: ubuntu-latest steps: diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index d7c8ac0..3c9ff90 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -380,6 +380,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -432,7 +433,9 @@ export class ReportController extends Controller { if (data1 != null) { formattedData1 = { total: Extension.ToThaiNumber(data1.total.toLocaleString()), - fifteenPercent: Extension.ToThaiNumber(`${data1.fifteenPercent.toLocaleString()}.${data1.fifteenPoint.toLocaleString()}`), + fifteenPercent: Extension.ToThaiNumber( + `${data1.fifteenPercent.toLocaleString()}.${data1.fifteenPoint.toLocaleString()}`, + ), full: Extension.ToThaiNumber( data1.salaryProfiles.filter((x) => x.type == "FULL").length.toLocaleString(), ), @@ -450,7 +453,9 @@ export class ReportController extends Controller { if (data2 != null) { formattedData2 = { total: Extension.ToThaiNumber(data2.total.toLocaleString()), - fifteenPercent: Extension.ToThaiNumber(`${data2.fifteenPercent.toLocaleString()}.${data2.fifteenPoint.toLocaleString()}`), + fifteenPercent: Extension.ToThaiNumber( + `${data2.fifteenPercent.toLocaleString()}.${data2.fifteenPoint.toLocaleString()}`, + ), full: Extension.ToThaiNumber( data2.salaryProfiles .filter( @@ -492,7 +497,9 @@ export class ReportController extends Controller { if (data3 != null) { formattedData3 = { total: Extension.ToThaiNumber(data3.total.toLocaleString()), - fifteenPercent: Extension.ToThaiNumber(`${data3.fifteenPercent.toLocaleString()}.${data3.fifteenPoint.toLocaleString()}`), + fifteenPercent: Extension.ToThaiNumber( + `${data3.fifteenPercent.toLocaleString()}.${data3.fifteenPoint.toLocaleString()}`, + ), full: Extension.ToThaiNumber( data3.salaryProfiles .filter( @@ -537,7 +544,9 @@ export class ReportController extends Controller { if (data4 != null) { formattedData4 = { total: Extension.ToThaiNumber(data4.total.toLocaleString()), - fifteenPercent: Extension.ToThaiNumber(`${data4.fifteenPercent.toLocaleString()}.${data4.fifteenPoint.toLocaleString()}`), + fifteenPercent: Extension.ToThaiNumber( + `${data4.fifteenPercent.toLocaleString()}.${data4.fifteenPoint.toLocaleString()}`, + ), full: Extension.ToThaiNumber( data4.salaryProfiles.filter((x) => x.type == "FULL").length.toLocaleString(), ), @@ -632,8 +641,10 @@ export class ReportController extends Controller { sixPercentAmount: Extension.ToThaiNumber(data1.sixPercentAmount.toLocaleString()), spentAmount: Extension.ToThaiNumber(data1.spentAmount.toLocaleString()), remainingAmount: Extension.ToThaiNumber(data1.remainingAmount.toLocaleString()), - fifteenPercentOld: Extension.ToThaiNumber(`${_salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR2 == null ? 0: _salaryPeriodAPR2.fifteenPoint.toLocaleString()}`), - totalOld: Extension.ToThaiNumber( + fifteenPercentOld: Extension.ToThaiNumber( + `${_salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.fifteenPoint.toLocaleString()}`, + ), + totalOld: Extension.ToThaiNumber( (_salaryPeriodAPR2 == null || _salaryPeriodAPR2.salaryProfiles.length == 0 ? 0 : _salaryPeriodAPR2.salaryProfiles.filter((x) => x.type == "FULL").length @@ -725,7 +736,9 @@ export class ReportController extends Controller { sixPercentAmount: Extension.ToThaiNumber(data2.sixPercentAmount.toLocaleString()), spentAmount: Extension.ToThaiNumber(data2.spentAmount.toLocaleString()), remainingAmount: Extension.ToThaiNumber(data2.remainingAmount.toLocaleString()), - fifteenPercentOld: Extension.ToThaiNumber(`${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR1 == null ? 0: _salaryPeriodAPR1.fifteenPoint.toLocaleString()}`), + fifteenPercentOld: Extension.ToThaiNumber( + `${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPoint.toLocaleString()}`, + ), totalOld: Extension.ToThaiNumber( (_salaryPeriodAPR1 == null || _salaryPeriodAPR1.salaryProfiles.length == 0 ? 0 @@ -859,7 +872,9 @@ export class ReportController extends Controller { sixPercentAmount: Extension.ToThaiNumber(data3.sixPercentAmount.toLocaleString()), spentAmount: Extension.ToThaiNumber(data3.spentAmount.toLocaleString()), remainingAmount: Extension.ToThaiNumber(data3.remainingAmount.toLocaleString()), - fifteenPercentOld: Extension.ToThaiNumber(`${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR1 == null ? 0: _salaryPeriodAPR1.fifteenPoint.toLocaleString()}`), + fifteenPercentOld: Extension.ToThaiNumber( + `${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPoint.toLocaleString()}`, + ), totalOld: Extension.ToThaiNumber( (_salaryPeriodAPR1 == null || _salaryPeriodAPR1.salaryProfiles.length == 0 ? 0 @@ -977,7 +992,9 @@ export class ReportController extends Controller { sixPercentAmount: Extension.ToThaiNumber(data4.sixPercentAmount.toLocaleString()), spentAmount: Extension.ToThaiNumber(data4.spentAmount.toLocaleString()), remainingAmount: Extension.ToThaiNumber(data4.remainingAmount.toLocaleString()), - fifteenPercentOld: Extension.ToThaiNumber(`${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR1 == null ? 0: _salaryPeriodAPR1.fifteenPoint.toLocaleString()}`), + fifteenPercentOld: Extension.ToThaiNumber( + `${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString()}.${_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPoint.toLocaleString()}`, + ), totalOld: Extension.ToThaiNumber( (_salaryPeriodAPR1 == null || _salaryPeriodAPR1.salaryProfiles.length == 0 ? 0 @@ -1238,6 +1255,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -1289,6 +1307,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -1517,6 +1536,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -1597,6 +1617,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -1734,7 +1755,11 @@ export class ReportController extends Controller { // (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") + // (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") + // (profile.root == undefined && profile.root == null ? "" : profile.root), - position: (profile.position?profile.position : "-") + (profile.posExecutive != null && profile.posExecutive != "" ? "\n" + profile.posExecutive : ""), + position: + (profile.position ? profile.position : "-") + + (profile.posExecutive != null && profile.posExecutive != "" + ? "\n" + profile.posExecutive + : ""), affiliation: (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "\n") + (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "\n") + @@ -1744,6 +1769,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, orgShortName: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(String(profile.posMasterNo.toLocaleString())), amount: profile.amount == undefined || profile.amount == null || profile.amount == 0 @@ -1843,7 +1869,11 @@ export class ReportController extends Controller { log_group: profile.salaryOrg.group, log_type: profile.type, log_isNext: profile.isNext, - position: (profile.position?profile.position : "-") + (profile.posExecutive != null && profile.posExecutive != "" ? "\n" + profile.posExecutive : ""), + position: + (profile.position ? profile.position : "-") + + (profile.posExecutive != null && profile.posExecutive != "" + ? "\n" + profile.posExecutive + : ""), affiliation: (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "\n") + (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "\n") + @@ -1853,6 +1883,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, orgShortName: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(String(profile.posMasterNo.toLocaleString())), amount: profile.amount == undefined || profile.amount == null || profile.amount == 0 @@ -1959,11 +1990,16 @@ export class ReportController extends Controller { return { no: Extension.ToThaiNumber((index + 1).toLocaleString()), fullname: profile.prefix + profile.firstName + " " + profile.lastName, - position: (profile.position?profile.position : "-") + (profile.posExecutive != null && profile.posExecutive != "" ? "\n" + profile.posExecutive : ""), + position: + (profile.position ? profile.position : "-") + + (profile.posExecutive != null && profile.posExecutive != "" + ? "\n" + profile.posExecutive + : ""), affiliation: affiliation, posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: profile.remark, //เหตุผล @@ -2053,12 +2089,17 @@ export class ReportController extends Controller { return { no: Extension.ToThaiNumber((index + 1).toLocaleString()), fullname: profile.prefix + profile.firstName + " " + profile.lastName, - position: (profile.position?profile.position : "-") + (profile.posExecutive != null && profile.posExecutive != "" ? "\n" + profile.posExecutive : ""), + position: + (profile.position ? profile.position : "-") + + (profile.posExecutive != null && profile.posExecutive != "" + ? "\n" + profile.posExecutive + : ""), affiliation: affiliation, posLevel: profile.posLevel, posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -2150,7 +2191,9 @@ export class ReportController extends Controller { const formattedData = salaryProfile.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: (item.position?item.position : "-") + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), + position: + (item.position ? item.position : "-") + + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), affiliation: (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + @@ -2165,6 +2208,7 @@ export class ReportController extends Controller { : item.position || "-", posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -2265,7 +2309,9 @@ export class ReportController extends Controller { const formattedData = salaryProfile.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: (item.position?item.position : "-") + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), + position: + (item.position ? item.position : "-") + + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), affiliation: (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + @@ -2276,6 +2322,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -2416,7 +2463,9 @@ export class ReportController extends Controller { const profileSpecial = salaryProfileSpecial.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: (item.position?item.position : "-") + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), + position: + (item.position ? item.position : "-") + + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), affiliation: (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + @@ -2427,6 +2476,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -2442,7 +2492,9 @@ export class ReportController extends Controller { const profileNoAmount = salaryProfileNoAmount.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: (item.position?item.position : "-") + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), + position: + (item.position ? item.position : "-") + + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), affiliation: (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + @@ -2453,6 +2505,7 @@ export class ReportController extends Controller { posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), amount: item.amount == undefined || item.amount == null @@ -2569,9 +2622,12 @@ export class ReportController extends Controller { no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, root: item.root ?? "-", - position: (item.position?item.position : "-") + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), + position: + (item.position ? item.position : "-") + + (item.posExecutive != null && item.posExecutive != "" ? "\n" + item.posExecutive : ""), posMasterNo: Extension.ToThaiNumber(item.orgShortName) + + " " + Extension.ToThaiNumber(String(item.posMasterNo)), posTypeCurrent: item.posType ?? "-", posLevelCurrent: item.posLevel ?? "-", @@ -2666,7 +2722,9 @@ export class ReportController extends Controller { fifteenPercent: _salaryPeriod == null ? "" - : Extension.ToThaiNumber(`${_salaryPeriod.fifteenPercent.toLocaleString()}.${_salaryPeriod.fifteenPoint.toLocaleString()}`), + : Extension.ToThaiNumber( + `${_salaryPeriod.fifteenPercent.toLocaleString()}.${_salaryPeriod.fifteenPoint.toLocaleString()}`, + ), full: _salaryPeriod == null ? "" @@ -2749,6 +2807,7 @@ export class ReportController extends Controller { : null, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -2847,6 +2906,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -2932,8 +2992,9 @@ export class ReportController extends Controller { ? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}` : "-", posNumber: - profile.orgShortName || profile.amount + profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3019,6 +3080,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3109,6 +3171,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3193,6 +3256,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3330,6 +3394,7 @@ export class ReportController extends Controller { position: profile.position ?? "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "๐", type1: @@ -3548,6 +3613,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -3627,6 +3693,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3714,6 +3781,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3795,6 +3863,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -3874,6 +3943,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.positionSalaryAmount @@ -3963,6 +4033,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -4036,6 +4107,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -4199,8 +4271,9 @@ export class ReportController extends Controller { (octSnap2.sixPercentAmount - octSnap2.spentAmount).toLocaleString(), ), totalOld: aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.total.toLocaleString()), //จำนวน(คน)(โควตาเลื่อนขั้นค่าจ้าง) - fifteenPercentOld: - Extension.ToThaiNumber(`${aprSnap2.fifteenPercent.toLocaleString()}.${aprSnap2.fifteenPoint.toLocaleString()}`), + fifteenPercentOld: Extension.ToThaiNumber( + `${aprSnap2.fifteenPercent.toLocaleString()}.${aprSnap2.fifteenPoint.toLocaleString()}`, + ), totalUseOld: aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.quantityUsed.toLocaleString()), //พิจารณาให้(คน)(โควตาเลื่อนขั้นค่าจ้าง) full2: totalEmp2step == null ? "" : Extension.ToThaiNumber(totalEmp2step.toLocaleString()), //เลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้นจำนวน(คน) @@ -4364,6 +4437,7 @@ export class ReportController extends Controller { position: profile.position ?? "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", yearOld2: @@ -4621,6 +4695,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(String(profile.posMasterNo.toLocaleString())) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -4792,6 +4867,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -4887,6 +4963,7 @@ export class ReportController extends Controller { : "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) @@ -4980,6 +5057,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -5071,6 +5149,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -5153,6 +5232,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -5279,6 +5359,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, typeOld2: @@ -5443,6 +5524,7 @@ export class ReportController extends Controller { : "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", positionSalaryAmount: profile.positionSalaryAmount @@ -5642,6 +5724,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, positionSalaryAmount: profile.positionSalaryAmount @@ -5733,6 +5816,7 @@ export class ReportController extends Controller { posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, positionSalaryAmount: profile.positionSalaryAmount @@ -5816,6 +5900,7 @@ export class ReportController extends Controller { : null, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -5932,6 +6017,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -6027,6 +6113,7 @@ export class ReportController extends Controller { : "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", positionSalaryAmount: profile.positionSalaryAmount @@ -6127,6 +6214,7 @@ export class ReportController extends Controller { : "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) @@ -6223,6 +6311,7 @@ export class ReportController extends Controller { posNumber: profile.orgShortName || profile.posMasterNo ? Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()) : "-", amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", @@ -6333,6 +6422,7 @@ export class ReportController extends Controller { : null, posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, @@ -6558,6 +6648,7 @@ export class ReportController extends Controller { : "-", posNumber: Extension.ToThaiNumber(profile.orgShortName) + + " " + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", positionSalaryAmount: profile.positionSalaryAmount @@ -6931,7 +7022,7 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: item.posLevel, @@ -6981,7 +7072,7 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: item.posLevel, @@ -7025,7 +7116,7 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: item.posLevel, @@ -7068,7 +7159,7 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: `${item.posTypeShort}${item.posLevel}`, @@ -7111,7 +7202,7 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: `${item.posTypeShort}${item.posLevel}`, @@ -7197,11 +7288,17 @@ export class ReportController extends Controller { "salaryProfile.amountUse", "salaryProfile.positionSalaryAmount", ]) + .orderBy("salaryProfile.rootOrder", "ASC") + .addOrderBy("salaryProfile.child1Order", "ASC") + .addOrderBy("salaryProfile.child2Order", "ASC") + .addOrderBy("salaryProfile.child3Order", "ASC") + .addOrderBy("salaryProfile.child4Order", "ASC") + .addOrderBy("salaryProfile.posMasterNo", "ASC") .getMany(); const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: item.posLevel, @@ -7300,11 +7397,17 @@ export class ReportController extends Controller { "salaryProfile.amountUse", "salaryProfile.positionSalaryAmount", ]) + .orderBy("salaryProfile.rootOrder", "ASC") + .addOrderBy("salaryProfile.child1Order", "ASC") + .addOrderBy("salaryProfile.child2Order", "ASC") + .addOrderBy("salaryProfile.child3Order", "ASC") + .addOrderBy("salaryProfile.child4Order", "ASC") + .addOrderBy("salaryProfile.posMasterNo", "ASC") .getMany(); const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: item.posLevel, @@ -7395,11 +7498,17 @@ export class ReportController extends Controller { "salaryProfile.amountUse", "salaryProfile.positionSalaryAmount", ]) + .orderBy("salaryProfile.rootOrder", "ASC") + .addOrderBy("salaryProfile.child1Order", "ASC") + .addOrderBy("salaryProfile.child2Order", "ASC") + .addOrderBy("salaryProfile.child3Order", "ASC") + .addOrderBy("salaryProfile.child4Order", "ASC") + .addOrderBy("salaryProfile.posMasterNo", "ASC") .getMany(); const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: item.posLevel, @@ -7490,11 +7599,17 @@ export class ReportController extends Controller { "salaryProfileEmployee.amountUse", "salaryProfileEmployee.positionSalaryAmount", ]) + .orderBy("salaryProfile.rootOrder", "ASC") + .addOrderBy("salaryProfile.child1Order", "ASC") + .addOrderBy("salaryProfile.child2Order", "ASC") + .addOrderBy("salaryProfile.child3Order", "ASC") + .addOrderBy("salaryProfile.child4Order", "ASC") + .addOrderBy("salaryProfile.posMasterNo", "ASC") .getMany(); const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: `${item.posTypeShort ?? ""} ${item.posLevel ?? ""}`, @@ -7585,11 +7700,17 @@ export class ReportController extends Controller { "salaryProfileEmployee.amountUse", "salaryProfileEmployee.positionSalaryAmount", ]) + .orderBy("salaryProfile.rootOrder", "ASC") + .addOrderBy("salaryProfile.child1Order", "ASC") + .addOrderBy("salaryProfile.child2Order", "ASC") + .addOrderBy("salaryProfile.child3Order", "ASC") + .addOrderBy("salaryProfile.child4Order", "ASC") + .addOrderBy("salaryProfile.posMasterNo", "ASC") .getMany(); const _salaryRank = salaryRank.map((item) => ({ id: item.id, - posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + posMasterNo: `${item.orgShortName} ${item.posMasterNo}`, positionName: item.position, posType: item.posType, posLevel: `${item.posTypeShort ?? ""} ${item.posLevel ?? ""}`, @@ -7854,7 +7975,7 @@ export class ReportController extends Controller { : "-", positionNumber: salary.orgShortName != null && salary.posMasterNo != null - ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + ? Extension.ToThaiNumber(salary.orgShortName + " " + salary.posMasterNo) : "-", amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", positionSalaryAmount: salary.positionSalaryAmount @@ -7984,7 +8105,7 @@ export class ReportController extends Controller { : "-", positionNumber: salary.orgShortName != null && salary.posMasterNo != null - ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + ? Extension.ToThaiNumber(salary.orgShortName + " " + salary.posMasterNo) : "-", amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", positionSalaryAmount: salary.positionSalaryAmount @@ -8114,7 +8235,7 @@ export class ReportController extends Controller { : "-", positionNumber: salary.orgShortName != null && salary.posMasterNo != null - ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + ? Extension.ToThaiNumber(salary.orgShortName + " " + salary.posMasterNo) : "-", amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", positionSalaryAmount: salary.positionSalaryAmount @@ -8244,7 +8365,7 @@ export class ReportController extends Controller { : "-", positionNumber: salary.orgShortName != null && salary.posMasterNo != null - ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + ? Extension.ToThaiNumber(salary.orgShortName + " " + salary.posMasterNo) : "-", amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", positionSalaryAmount: salary.positionSalaryAmount @@ -8374,7 +8495,7 @@ export class ReportController extends Controller { : "-", positionNumber: salary.orgShortName != null && salary.posMasterNo != null - ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + ? Extension.ToThaiNumber(salary.orgShortName + " " + salary.posMasterNo) : "-", amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", positionSalaryAmount: salary.positionSalaryAmount @@ -8678,7 +8799,7 @@ export class ReportController extends Controller { id: v.refId, }, }); - + if (salary != null) { await new CallAPI() .PostData(request, "/org/profile-employee/salary/update", { @@ -8693,7 +8814,9 @@ export class ReportController extends Controller { posNoAbb: salary.orgShortName, positionName: salary.position, positionType: salary.posType, - positionLevel: (salary.posTypeShort != null ? salary.posTypeShort + " " : '') + (salary.posLevel != null ? salary.posLevel.toString() : ''), + positionLevel: + (salary.posTypeShort != null ? salary.posTypeShort + " " : "") + + (salary.posLevel != null ? salary.posLevel.toString() : ""), remark: v.remark, orgRoot: salary.root, orgChild1: salary.child1, @@ -8778,7 +8901,9 @@ export class ReportController extends Controller { posNoAbb: salary.orgShortName, positionName: salary.position, positionType: salary.posType, - positionLevel: (salary.posTypeShort != null ? salary.posTypeShort + " " : '') + (salary.posLevel != null ? salary.posLevel.toString() : ''), + positionLevel: + (salary.posTypeShort != null ? salary.posTypeShort + " " : "") + + (salary.posLevel != null ? salary.posLevel.toString() : ""), remark: v.remark, orgRoot: salary.root, orgChild1: salary.child1, diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index e9b669d..720075f 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -83,6 +83,20 @@ export class SalaryPeriodController extends Controller { x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, + group1IsClose: + salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP1" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + ) == null + ? null + : salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP1" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + )?.isClose, group2id: salaryPeriod.salaryOrgs.find( (x) => @@ -97,6 +111,20 @@ export class SalaryPeriodController extends Controller { x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, + group2IsClose: + salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP2" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + ) == null + ? null + : salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP2" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + )?.isClose, effectiveDate: salaryPeriod.effectiveDate, period: salaryPeriod.period, }; @@ -263,7 +291,7 @@ export class SalaryPeriodController extends Controller { }, 0); const data = { total: salaryOrg.total, - fifteenPercent: salaryOrg.fifteenPercent + (salaryOrg.fifteenPoint / 100), + fifteenPercent: salaryOrg.fifteenPercent + salaryOrg.fifteenPoint / 100, chosen: salaryOrg.quantityUsed, remaining: salaryOrg.remainQuota, currentAmount: salaryOrg.currentAmount, @@ -1163,6 +1191,349 @@ export class SalaryPeriodController extends Controller { return new HttpSuccess(); } + /** + * API แก้ไขขั้น + * + * @summary SLR_025 - แก้ไขขั้น #24 + * + * @param {string} id profile Id + * @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น + */ + @Post("change/type-multi") + async changeTypeMulti( + @Body() body: { profileId: string[]; type: string; isReserve: boolean; remark?: string | null }, + @Request() req: RequestWithUser, + ) { + await new permission().PermissionCreate(req, "SYS_SALARY_OFFICER"); + + for await (const profile of body.profileId) { + const salaryProfile = await this.salaryProfileRepository.findOne({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { id: profile }, + }); + if (!salaryProfile) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ", + ); + } + body.type = body.type.toUpperCase(); + + //ตรวจสอบงวดเมษาว่าเลื่อนกี่ขั้น + if (body.type == "FULLHAFT") { + if (salaryProfile?.salaryOrg?.salaryPeriod?.period === "OCT") { + const checkPreviousType = await this.salaryProfileRepository.findOne({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + citizenId: salaryProfile?.citizenId, + salaryOrg: { + salaryPeriod: { + period: "APR", + year: salaryProfile?.salaryOrg?.salaryPeriod?.year, //ปีที่ตรงกันด้วย + }, + snapshot: "SNAP2", + }, + type: "FULL", + }, + }); + if (checkPreviousType) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถเลื่อนขั้นบุคลากรเกิน 2 ขั้นต่อปีได้", + ); + } + } + } + if (body.type == "FULL") { + salaryProfile.isReserve = body.isReserve; + } else { + salaryProfile.isReserve = false; + } + + //Type & Level + const Type = await this.posTypeRepository.findOne({ + where: { + posTypeName: salaryProfile.posType, + }, + }); + if (!Type) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทตำแหน่ง"); + } + const Level = await this.posLevelRepository.findOne({ + where: { + posTypeId: Type.id, + posLevelName: salaryProfile.posLevel, + }, + }); + if (!Level) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง"); + } + //Salary + const salarys = await this.salaryRepository.findOne({ + where: { + posTypeId: Level.posTypeId, + posLevelId: Level.id, + isSpecial: salaryProfile.isSpecial == true ? true : false, + isActive: true, + }, + }); + if (!salarys) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง"); + } + salaryProfile.type = body.type; + let _null: any = null; + salaryProfile.remark = body.remark == null ? _null : body.remark; + let type = salaryProfile.type; + //SalaryRank + let salaryRanks: any = null; + if (salaryProfile.amount != null) { + salaryRanks = await this.salaryRankRepository.findOne({ + where: { + salaryId: salarys.id, + salary: MoreThanOrEqual(salaryProfile.amount), + isNext: false, + }, + order: { salary: "ASC" }, + }); + if (salaryRanks != null) { + if (salaryProfile.type == "HAFT") { + if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) { + const _salaryRanks = await this.salaryRankRepository.findOne({ + where: { + salaryId: salarys.id, + salary: salaryRanks.salaryHalf, + isNext: true, + }, + }); + salaryRanks = _salaryRanks == null ? salaryRanks : _salaryRanks; + } + } else if (salaryProfile.type == "FULL") { + if (salaryRanks.salaryFullSpecial != null && salaryRanks.salaryFullSpecial > 0) { + if (salaryRanks.salaryHalfSpecial == null || salaryRanks.salaryHalfSpecial == 0) { + type = "HAFT"; + } + const _salaryRanks = await this.salaryRankRepository.findOne({ + where: { + salaryId: salarys.id, + salary: salaryRanks.salaryFull, + isNext: true, + }, + }); + salaryRanks = _salaryRanks == null ? salaryRanks : _salaryRanks; + } + } else if (salaryProfile.type == "FULLHAFT") { + if ( + salaryRanks.salaryFullHalfSpecial != null && + salaryRanks.salaryFullHalfSpecial > 0 + ) { + if (salaryRanks.salaryFullSpecial == null || salaryRanks.salaryFullSpecial == 0) { + type = "HAFT"; + } else if ( + salaryRanks.salaryHalfSpecial == null || + salaryRanks.salaryHalfSpecial == 0 + ) { + type = "FULL"; + } + const _salaryRanks = await this.salaryRankRepository.findOne({ + where: { + salaryId: salarys.id, + salary: salaryRanks.salaryFullHalf, + isNext: true, + }, + }); + salaryRanks = _salaryRanks == null ? salaryRanks : _salaryRanks; + } + } + } else { + salaryRanks = await this.salaryRankRepository.findOne({ + where: { + salaryId: salarys.id, + salary: salaryProfile.amount, + isNext: true, + }, + }); + if (salaryRanks == null) { + salaryRanks = await this.salaryRankRepository.findOne({ + where: { + salaryId: salarys.id, + salary: MoreThan(salaryProfile.amount), + isNext: true, + }, + order: { salary: "ASC" }, + }); + } + } + } + + salaryProfile.isNext = false; + if (type == "NONE") { + salaryProfile.amountSpecial = 0; + salaryProfile.amountUse = 0; + salaryProfile.positionSalaryAmount = + salaryProfile.amount == null ? 0 : salaryProfile.amount; + } else if (type == "PENDING") { + salaryProfile.amountSpecial = 0; + salaryProfile.amountUse = 0; + salaryProfile.positionSalaryAmount = 0; + } else if (type == "HAFT") { + salaryProfile.amountSpecial = + salaryRanks == null || salaryRanks.salaryHalfSpecial == null + ? 0 + : salaryRanks.salaryHalfSpecial; + salaryProfile.amountUse = + salaryRanks == null || + salaryProfile == null || + salaryRanks.salaryHalf == null || + salaryProfile.amount == null + ? 0 + : salaryRanks.salaryHalf - salaryProfile.amount; + salaryProfile.positionSalaryAmount = + salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf; + salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext; + } else if (type == "FULL") { + salaryProfile.amountSpecial = + salaryRanks == null || salaryRanks.salaryFullSpecial == null + ? 0 + : salaryRanks.salaryFullSpecial; + salaryProfile.amountUse = + salaryRanks == null || + salaryProfile == null || + salaryRanks.salaryFull == null || + salaryProfile.amount == null + ? 0 + : salaryRanks.salaryFull - salaryProfile.amount; + salaryProfile.positionSalaryAmount = + salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull; + salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext; + } else if (type == "FULLHAFT") { + salaryProfile.amountSpecial = + salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null + ? 0 + : salaryRanks.salaryFullHalfSpecial; + salaryProfile.amountUse = + salaryRanks == null || + salaryProfile == null || + salaryRanks.salaryFullHalf == null || + salaryProfile.amount == null + ? 0 + : salaryRanks.salaryFullHalf - salaryProfile.amount; + salaryProfile.positionSalaryAmount = + salaryRanks == null || salaryRanks.salaryFullHalf == null + ? 0 + : salaryRanks.salaryFullHalf; + salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext; + } else { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง"); + } + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); + const before = structuredClone(salaryProfile); + await this.salaryProfileRepository.save(salaryProfile, { data: req }); + setLogDataDiff(req, { before, after: salaryProfile }); + + const _salaryProfile = await this.salaryProfileRepository.findOne({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { id: salaryProfile.id }, + }); + + // หาจำนวน Quota คงเหลือ + if (_salaryProfile != null) { + if (_salaryProfile.salaryOrg.snapshot == "SNAP1") { + if (_salaryProfile.salaryOrg.salaryPeriod.period == "APR") { + if (_salaryProfile != null) { + const salaryOrg = await this.salaryOrgRepository.findOne({ + where: { + id: _salaryProfile.salaryOrg.id, + }, + relations: { salaryProfiles: true }, + }); + if (salaryOrg != null) { + const amountFullType = await this.salaryProfileRepository.count({ + where: { + salaryOrgId: salaryOrg.id, + type: "FULL", + }, + }); + salaryOrg.total = salaryOrg.salaryProfiles.length; + salaryOrg.fifteenPercent = Math.floor((salaryOrg.salaryProfiles.length * 15) / 100); + salaryOrg.fifteenPoint = (salaryOrg.salaryProfiles.length * 15) % 100; + salaryOrg.quantityUsed = amountFullType; + const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; + salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); + await this.salaryOrgRepository.save(salaryOrg, { data: req }); + setLogDataDiff(req, { before, after: salaryOrg }); + } + } + } else if (_salaryProfile.salaryOrg.salaryPeriod.period == "OCT") { + if (_salaryProfile != null) { + const salaryOrg = await this.salaryOrgRepository.findOne({ + where: { + id: _salaryProfile.salaryOrg.id, + }, + relations: { salaryProfiles: true }, + }); + if (salaryOrg != null) { + const totalProfile = Extension.sumObjectValues(salaryOrg.salaryProfiles, "amount"); + salaryOrg.currentAmount = totalProfile; + salaryOrg.total = salaryOrg.salaryProfiles.length; + salaryOrg.sixPercentAmount = totalProfile * 0.06; + let totalAmount = 0; + const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({ + where: { + year: _salaryProfile.salaryOrg.salaryPeriod.year, + period: "APR", + }, + }); + if (salaryPeriodAPROld != null) { + const salaryOrgSnap2Old: any = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodAPROld.id, + rootId: salaryOrg.rootId, + group: salaryOrg.group, + snapshot: "SNAP2", + }, + relations: ["salaryProfiles"], + }); + totalAmount = + salaryOrgSnap2Old == null + ? 0 + : Extension.sumObjectValues(salaryOrgSnap2Old.salaryProfiles, "amountUse"); + } + salaryOrg.spentAmount = totalAmount; + const sumAmountUse = await AppDataSource.getRepository(SalaryProfile) + .createQueryBuilder("salaryProfile") + .select("SUM(salaryProfile.amountUse)", "totalAmount") + .where({ + salaryOrgId: salaryOrg.id, + type: In(["HAFT", "FULL", "FULLHAFT"]), + }) + .getRawOne(); + const calRemainAmount = + salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount; + salaryOrg.useAmount = + sumAmountUse == null || sumAmountUse.totalAmount == null + ? 0 + : sumAmountUse.totalAmount; + salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); + await this.salaryOrgRepository.save(salaryOrg, { data: req }); + setLogDataDiff(req, { before, after: salaryOrg }); + } + } + } + } + // return new HttpSuccess(); + } + } + return new HttpSuccess(); + } + /** * API รายการอัตราเงินเดือน * @@ -1243,13 +1614,17 @@ export class SalaryPeriodController extends Controller { .orWhere("profile.child1 LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.child2 LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.child3 LIKE :keyword", { keyword: `%${body.keyword}%` }) - .orWhere("profile.child4 LIKE :keyword", { keyword: `%${body.keyword}%` }) + .orWhere("profile.child4 LIKE :keyword", { keyword: `%${body.keyword}%` }); }), ); }), ) - .orderBy("profile.citizenId", "ASC") - .addOrderBy("profile.isReserve", "ASC") + .orderBy("profile.rootOrder", "ASC") + .addOrderBy("profile.child1Order", "ASC") + .addOrderBy("profile.child2Order", "ASC") + .addOrderBy("profile.child3Order", "ASC") + .addOrderBy("profile.child4Order", "ASC") + .addOrderBy("profile.posMasterNo", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize) .getManyAndCount(); @@ -3327,4 +3702,31 @@ export class SalaryPeriodController extends Controller { ); return new HttpSuccess(); } + + /** + * API แก้ไขรอบเงินเดือน + * + * + */ + @Put("change/isclose/{snapShot}/{salaryPeriodId}") + async ChangeIsClose( + @Request() request: RequestWithUser, + @Path() snapShot: string, + salaryPeriodId: string, + @Body() + body: { + isClose: boolean; + }, + ) { + await new permission().PermissionUpdate(request, "SYS_SALARY_ROUND"); + const salaryPeriod = await this.salaryOrgRepository.find({ + where: { salaryPeriodId: salaryPeriodId, snapshot: snapShot }, + }); + + for await (const item of salaryPeriod) { + item.isClose = body.isClose; + await this.salaryOrgRepository.save(item); + } + return new HttpSuccess(); + } } diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index a92333c..6860b13 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -83,6 +83,20 @@ export class SalaryPeriodEmployeeController extends Controller { x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, + group1IsClose: + salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP1" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + ) == null + ? null + : salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP1" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + )?.isClose, group2id: salaryPeriod.salaryOrgEmployees.find( (x) => @@ -97,6 +111,20 @@ export class SalaryPeriodEmployeeController extends Controller { x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, + group2IsClose: + salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP2" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + ) == null + ? null + : salaryPeriod.salaryOrgs.find( + (x) => + x.group == "GROUP2" && + x.rootId == body.rootId && + x.snapshot == body.snapshot.toLocaleUpperCase(), + )?.isClose, effectiveDate: salaryPeriod.effectiveDate, period: salaryPeriod.period, }; @@ -224,7 +252,7 @@ export class SalaryPeriodEmployeeController extends Controller { }, 0); const data = { total: salaryOrg.total, - fifteenPercent: salaryOrg.fifteenPercent + (salaryOrg.fifteenPoint / 100), + fifteenPercent: salaryOrg.fifteenPercent + salaryOrg.fifteenPoint / 100, chosen: salaryOrg.quantityUsed, remaining: salaryOrg.remainQuota, currentAmount: salaryOrg.currentAmount, @@ -835,6 +863,198 @@ export class SalaryPeriodEmployeeController extends Controller { return new HttpSuccess(); } + /** + * API แก้ไขขั้น + * + * @summary SLR_025 - แก้ไขขั้น #24 + * + * @param {string} id profile Id + * @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น + */ + @Post("change/type-multi") + async changeTypeMulti( + @Body() body: { profileId: string[]; type: string; isReserve: boolean; remark?: string | null }, + @Request() req: RequestWithUser, + ) { + await new permission().PermissionCreate(req, "SYS_WAGE"); + for await (const profile of body.profileId) { + let salaryProfile = await this.salaryProfileRepository.findOne({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { id: profile }, + }); + if (!salaryProfile) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ", + ); + } + body.type = body.type.toUpperCase(); + + //ตรวจสอบงวดเมษาว่าเลื่อนกี่ขั้น + if (body.type == "FULLHAFT") { + if (salaryProfile?.salaryOrg?.salaryPeriod?.period === "OCT") { + const checkPreviousType = await this.salaryProfileRepository.findOne({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + citizenId: salaryProfile?.citizenId, + salaryOrg: { + salaryPeriod: { + period: "APR", + year: salaryProfile?.salaryOrg?.salaryPeriod?.year, //ปีที่ตรงกันด้วย + }, + snapshot: "SNAP2", + }, + type: "FULL", + }, + }); + if (checkPreviousType) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถเลื่อนขั้นบุคลากรเกิน 2 ขั้นต่อปีได้", + ); + } + } + } + if (body.type == "FULL") { + salaryProfile.isReserve = body.isReserve; + } else { + salaryProfile.isReserve = false; + } + + //Type & Level + const Type = await this.posTypeRepository.findOne({ + where: { + posTypeName: salaryProfile.posType, + }, + }); + if (!Type) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทตำแหน่ง"); + } + const Level = await this.posLevelRepository.findOne({ + where: { + posTypeId: Type.id, + posLevelName: salaryProfile.posLevel, + }, + }); + if (!Level) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง"); + } + salaryProfile.type = body.type; + let _null: any = null; + salaryProfile.remark = body.remark == null ? _null : body.remark; + let type = salaryProfile.type; + + salaryProfile = await this.calSalary(type, salaryProfile); + + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); + const before = structuredClone(salaryProfile); + await this.salaryProfileRepository.save(salaryProfile, { data: req }); + setLogDataDiff(req, { before, after: salaryProfile }); + + const _salaryProfile = await this.salaryProfileRepository.findOne({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { id: salaryProfile.id }, + }); + + // หาจำนวน Quota คงเหลือ + if (_salaryProfile != null) { + if (_salaryProfile.salaryOrg.snapshot == "SNAP1") { + if (_salaryProfile.salaryOrg.salaryPeriod.period == "APR") { + if (_salaryProfile != null) { + const salaryOrg = await this.salaryOrgRepository.findOne({ + where: { + id: _salaryProfile.salaryOrg.id, + }, + relations: { salaryProfiles: true }, + }); + if (salaryOrg != null) { + const amountFullType = await this.salaryProfileRepository.count({ + where: { + salaryOrgId: salaryOrg.id, + type: "FULL", + }, + }); + salaryOrg.total = salaryOrg.salaryProfiles.length; + salaryOrg.fifteenPercent = Math.floor((salaryOrg.salaryProfiles.length * 15) / 100); + salaryOrg.fifteenPoint = (salaryOrg.salaryProfiles.length * 15) % 100; + salaryOrg.quantityUsed = amountFullType; + const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; + salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); + await this.salaryOrgRepository.save(salaryOrg, { data: req }); + setLogDataDiff(req, { before, after: salaryOrg }); + } + } + } else if (_salaryProfile.salaryOrg.salaryPeriod.period == "OCT") { + if (_salaryProfile != null) { + const salaryOrg = await this.salaryOrgRepository.findOne({ + where: { + id: _salaryProfile.salaryOrg.id, + }, + relations: { salaryProfiles: true }, + }); + if (salaryOrg != null) { + const totalProfile = Extension.sumObjectValues(salaryOrg.salaryProfiles, "amount"); + salaryOrg.currentAmount = totalProfile; + salaryOrg.total = salaryOrg.salaryProfiles.length; + salaryOrg.sixPercentAmount = totalProfile * 0.06; + let totalAmount = 0; + const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({ + where: { + year: _salaryProfile.salaryOrg.salaryPeriod.year, + period: "APR", + }, + }); + if (salaryPeriodAPROld != null) { + const salaryOrgSnap2Old: any = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodAPROld.id, + rootId: salaryOrg.rootId, + group: salaryOrg.group, + snapshot: "SNAP2", + }, + relations: ["salaryProfiles"], + }); + totalAmount = + salaryOrgSnap2Old == null + ? 0 + : Extension.sumObjectValues(salaryOrgSnap2Old.salaryProfiles, "amountUse"); + } + salaryOrg.spentAmount = totalAmount; + const sumAmountUse = await AppDataSource.getRepository(SalaryProfileEmployee) + .createQueryBuilder("salaryProfileEmployee") + .select("SUM(salaryProfileEmployee.amountUse)", "totalAmount") + .where({ + salaryOrgId: salaryOrg.id, + type: In(["HAFT", "FULL", "FULLHAFT"]), + }) + .getRawOne(); + const calRemainAmount = + salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount; + salaryOrg.useAmount = + sumAmountUse == null || sumAmountUse.totalAmount == null + ? 0 + : sumAmountUse.totalAmount; + salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); + await this.salaryOrgRepository.save(salaryOrg, { data: req }); + setLogDataDiff(req, { before, after: salaryOrg }); + } + } + } + } + // return new HttpSuccess(); + } + } + return new HttpSuccess(); + } + /** * API รายการอัตราเงินเดือน * @@ -893,8 +1113,13 @@ export class SalaryPeriodEmployeeController extends Controller { .orWhere("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` }) - .orWhere("CONCAT(profile.prefix,profile.firstName,' ',profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }) - .orWhere("CONCAT(profile.orgShortName,profile.posMasterNo) LIKE :keyword", { keyword: `%${body.keyword}%` }) + .orWhere( + "CONCAT(profile.prefix,profile.firstName,' ',profile.lastName) LIKE :keyword", + { keyword: `%${body.keyword}%` }, + ) + .orWhere("CONCAT(profile.orgShortName,profile.posMasterNo) LIKE :keyword", { + keyword: `%${body.keyword}%`, + }) // .orWhere("profile.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` }) // .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` }) @@ -1724,7 +1949,10 @@ export class SalaryPeriodEmployeeController extends Controller { return new HttpSuccess(); } - async calSalary(type: string, salaryProfile: SalaryProfileEmployee): Promise { + async calSalary( + type: string, + salaryProfile: SalaryProfileEmployee, + ): Promise { if (type == "NONE") { salaryProfile.isNext = false; salaryProfile.amountSpecial = 0; @@ -2048,4 +2276,31 @@ export class SalaryPeriodEmployeeController extends Controller { return salaryProfile; } + + /** + * API แก้ไขรอบเงินเดือน + * + * + */ + @Put("change/isclose/{snapShot}/{salaryPeriodId}") + async ChangeIsClose( + @Request() request: RequestWithUser, + @Path() snapShot: string, + salaryPeriodId: string, + @Body() + body: { + isClose: boolean; + }, + ) { + await new permission().PermissionUpdate(request, "SYS_SALARY_ROUND"); + const salaryPeriod = await this.salaryOrgRepository.find({ + where: { salaryPeriodId: salaryPeriodId, snapshot: snapShot }, + }); + + for await (const item of salaryPeriod) { + item.isClose = body.isClose; + await this.salaryOrgRepository.save(item); + } + return new HttpSuccess(); + } } diff --git a/src/entities/SalaryOrg.ts b/src/entities/SalaryOrg.ts index 6fa0a89..a0cda44 100644 --- a/src/entities/SalaryOrg.ts +++ b/src/entities/SalaryOrg.ts @@ -11,6 +11,12 @@ export class SalaryOrg extends EntityBase { }) salaryPeriodId: string; + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isClose: boolean; + @Column({ comment: "สถานะ", }) diff --git a/src/entities/SalaryOrgEmployee.ts b/src/entities/SalaryOrgEmployee.ts index 8433ef9..7bc6a1a 100644 --- a/src/entities/SalaryOrgEmployee.ts +++ b/src/entities/SalaryOrgEmployee.ts @@ -11,6 +11,12 @@ export class SalaryOrgEmployee extends EntityBase { }) salaryPeriodId: string; + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isClose: boolean; + @Column({ comment: "สถานะ", }) diff --git a/src/entities/SalaryProfile.ts b/src/entities/SalaryProfile.ts index 54100dd..a9948fe 100644 --- a/src/entities/SalaryProfile.ts +++ b/src/entities/SalaryProfile.ts @@ -193,6 +193,13 @@ export class SalaryProfile extends EntityBase { }) revisionId: string; + @Column({ + nullable: true, + comment: "order orgRoot", + length: 40, + }) + rootOrder: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgRoot", @@ -208,6 +215,13 @@ export class SalaryProfile extends EntityBase { }) root: string; + @Column({ + nullable: true, + comment: "Order orgChild1", + length: 40, + }) + child1Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild1", @@ -223,6 +237,13 @@ export class SalaryProfile extends EntityBase { }) child1: string; + @Column({ + nullable: true, + comment: "Order orgChild2", + length: 40, + }) + child2Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild2", @@ -238,6 +259,13 @@ export class SalaryProfile extends EntityBase { }) child2: string; + @Column({ + nullable: true, + comment: "Order orgChild3", + length: 40, + }) + child3Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild3", @@ -253,6 +281,13 @@ export class SalaryProfile extends EntityBase { }) child3: string; + @Column({ + nullable: true, + comment: "Order orgChild4", + length: 40, + }) + child4Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild4", diff --git a/src/entities/SalaryProfileEmployee.ts b/src/entities/SalaryProfileEmployee.ts index 1645792..32ea450 100644 --- a/src/entities/SalaryProfileEmployee.ts +++ b/src/entities/SalaryProfileEmployee.ts @@ -238,6 +238,13 @@ export class SalaryProfileEmployee extends EntityBase { }) revisionId: string; + @Column({ + nullable: true, + comment: "Order orgRoot", + length: 40, + }) + rootOrder: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgRoot", @@ -253,6 +260,13 @@ export class SalaryProfileEmployee extends EntityBase { }) root: string; + @Column({ + nullable: true, + comment: "Order orgChild1", + length: 40, + }) + child1Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild1", @@ -268,6 +282,13 @@ export class SalaryProfileEmployee extends EntityBase { }) child1: string; + @Column({ + nullable: true, + comment: "Order orgChild2", + length: 40, + }) + child2Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild2", @@ -283,6 +304,13 @@ export class SalaryProfileEmployee extends EntityBase { }) child2: string; + @Column({ + nullable: true, + comment: "Order orgChild3", + length: 40, + }) + child3Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild3", @@ -298,6 +326,13 @@ export class SalaryProfileEmployee extends EntityBase { }) child3: string; + @Column({ + nullable: true, + comment: "Order orgChild4", + length: 40, + }) + child4Order: string; + @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgChild4", diff --git a/src/migration/1720153794237-add_table_salary1.ts b/src/migration/1720153794237-add_table_salary1.ts deleted file mode 100644 index 3c5ee54..0000000 --- a/src/migration/1720153794237-add_table_salary1.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableSalary11720153794237 implements MigrationInterface { - name = 'AddTableSalary11720153794237' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`result\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`result\` varchar(255) NULL COMMENT 'ผลการประเมินผลการปฏิบัติราชการ'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`result\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`result\` double NULL COMMENT 'ผลการประเมินผลการปฏิบัติราชการ'`); - } - -} diff --git a/src/migration/1720405140572-add_table_kpi_add_salary1.ts b/src/migration/1720405140572-add_table_kpi_add_salary1.ts deleted file mode 100644 index 32b241f..0000000 --- a/src/migration/1720405140572-add_table_kpi_add_salary1.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableKpiAddSalary11720405140572 implements MigrationInterface { - name = 'AddTableKpiAddSalary11720405140572' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`remark\` text NULL COMMENT 'หมายเหตุ'`); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`remark\` text NULL COMMENT 'หมายเหตุ'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`remark\``); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`remark\``); - } - -} diff --git a/src/migration/1738665794932-updateroleadddnanull.ts b/src/migration/1738665794932-updateroleadddnanull.ts deleted file mode 100644 index 238b042..0000000 --- a/src/migration/1738665794932-updateroleadddnanull.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Updateroleadddnanull1738665794932 implements MigrationInterface { - name = 'Updateroleadddnanull1738665794932' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`rootDnaId\` \`rootDnaId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot Dna'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`rootDnaId\` \`rootDnaId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot Dna'`); - } - -} diff --git a/src/migration/1742293654061-update_profileSalary_and_profileSalaryEmp.ts b/src/migration/1742293654061-update_profileSalary_and_profileSalaryEmp.ts deleted file mode 100644 index 2d1a0dd..0000000 --- a/src/migration/1742293654061-update_profileSalary_and_profileSalaryEmp.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateProfileSalaryAndProfileSalaryEmp1742293654061 implements MigrationInterface { - name = 'UpdateProfileSalaryAndProfileSalaryEmp1742293654061' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status33\` varchar(20) NULL COMMENT 'สถานะออกคำสั่ง33'`); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status34\` varchar(20) NULL COMMENT 'สถานะออกคำสั่ง34'`); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status35\` varchar(20) NULL COMMENT 'สถานะออกคำสั่ง35'`); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`status36\` varchar(20) NULL COMMENT 'สถานะออกคำสั่ง36'`); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`status37\` varchar(20) NULL COMMENT 'สถานะออกคำสั่ง37'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`status37\``); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`status36\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status35\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status34\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status33\``); - } - -} diff --git a/src/migration/1742297168141-update_profileSalary_and_profileSalaryEmp.ts b/src/migration/1742297168141-update_profileSalary_and_profileSalaryEmp.ts deleted file mode 100644 index b9e1969..0000000 --- a/src/migration/1742297168141-update_profileSalary_and_profileSalaryEmp.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateProfileSalaryAndProfileSalaryEmp1742297168141 implements MigrationInterface { - name = 'UpdateProfileSalaryAndProfileSalaryEmp1742297168141' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`status36\` varchar(20) NOT NULL COMMENT 'สถานะออกคำสั่ง36' DEFAULT 'PENDING'`); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`status37\` varchar(20) NOT NULL COMMENT 'สถานะออกคำสั่ง37' DEFAULT 'PENDING'`); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status33\` varchar(20) NOT NULL COMMENT 'สถานะออกคำสั่ง33' DEFAULT 'PENDING'`); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status34\` varchar(20) NOT NULL COMMENT 'สถานะออกคำสั่ง34' DEFAULT 'PENDING'`); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status35\` varchar(20) NOT NULL COMMENT 'สถานะออกคำสั่ง35' DEFAULT 'PENDING'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status35\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status34\``); - await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status33\``); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`status37\``); - await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`status36\``); - } - -} diff --git a/src/migration/1738657968680-updateroleadddna1.ts b/src/migration/1743787344650-update_table_salaryorg_add_isclose.ts similarity index 53% rename from src/migration/1738657968680-updateroleadddna1.ts rename to src/migration/1743787344650-update_table_salaryorg_add_isclose.ts index e1cef91..0adae74 100644 --- a/src/migration/1738657968680-updateroleadddna1.ts +++ b/src/migration/1743787344650-update_table_salaryorg_add_isclose.ts @@ -1,16 +1,16 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class Updateroleadddna11738657968680 implements MigrationInterface { - name = 'Updateroleadddna11738657968680' +export class UpdateTableSalaryorgAddIsclose1743787344650 implements MigrationInterface { + name = 'UpdateTableSalaryorgAddIsclose1743787344650' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryOrgEmployee\` ADD \`rootDnaId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot Dna'`); - await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD \`rootDnaId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot Dna'`); + await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD \`isClose\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`salaryOrgEmployee\` ADD \`isClose\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0`); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP COLUMN \`rootDnaId\``); - await queryRunner.query(`ALTER TABLE \`salaryOrgEmployee\` DROP COLUMN \`rootDnaId\``); + await queryRunner.query(`ALTER TABLE \`salaryOrgEmployee\` DROP COLUMN \`isClose\``); + await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP COLUMN \`isClose\``); } } diff --git a/src/migration/1743847173845-update_table_salaryorg_add_order.ts b/src/migration/1743847173845-update_table_salaryorg_add_order.ts new file mode 100644 index 0000000..1a6bcba --- /dev/null +++ b/src/migration/1743847173845-update_table_salaryorg_add_order.ts @@ -0,0 +1,32 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableSalaryorgAddOrder1743847173845 implements MigrationInterface { + name = 'UpdateTableSalaryorgAddOrder1743847173845' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`rootOrder\` varchar(40) NULL COMMENT 'order orgRoot'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`child1Order\` varchar(40) NULL COMMENT 'Order orgChild1'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`child2Order\` varchar(40) NULL COMMENT 'Order orgChild2'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`child3Order\` varchar(40) NULL COMMENT 'Order orgChild3'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`child4Order\` varchar(40) NULL COMMENT 'Order orgChild4'`); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`rootOrder\` varchar(40) NULL COMMENT 'Order orgRoot'`); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`child1Order\` varchar(40) NULL COMMENT 'Order orgChild1'`); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`child2Order\` varchar(40) NULL COMMENT 'Order orgChild2'`); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`child3Order\` varchar(40) NULL COMMENT 'Order orgChild3'`); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD \`child4Order\` varchar(40) NULL COMMENT 'Order orgChild4'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`child4Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`child3Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`child2Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`child1Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP COLUMN \`rootOrder\``); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`child4Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`child3Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`child2Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`child1Order\``); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`rootOrder\``); + } + +}