sort order

This commit is contained in:
moss 2025-04-05 18:12:02 +07:00
parent bf85af7e0d
commit 230b552f6d
15 changed files with 951 additions and 145 deletions

View file

@ -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,

View file

@ -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();
}
}

View file

@ -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<SalaryProfileEmployee> {
async calSalary(
type: string,
salaryProfile: SalaryProfileEmployee,
): Promise<SalaryProfileEmployee> {
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();
}
}