ออกคำสั่งเงินเดือน

This commit is contained in:
Kittapath 2024-04-25 00:53:57 +07:00
parent a8a227e062
commit 9e749fbbcd
4 changed files with 476 additions and 164 deletions

View file

@ -245,7 +245,7 @@ export class ReportController extends Controller {
// },
// });
const _salaryPeriod1 = await this.salaryProfileRepository.find({
const _salaryPeriod1 = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
@ -254,14 +254,14 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
group: "GROUP1",
},
type: "HAFT"
type: "HAFT",
},
order: {
citizenId: "ASC",
isReserve: "ASC",
},
});
const _salaryPeriod2 = await this.salaryProfileRepository.find({
const _salaryPeriod2 = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
@ -270,14 +270,14 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
group: "GROUP1",
},
type: "FULL"
type: "FULL",
},
order: {
citizenId: "ASC",
isReserve: "ASC",
},
});
const _salaryPeriod3 = await this.salaryProfileRepository.find({
const _salaryPeriod3 = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
@ -286,14 +286,14 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
group: "GROUP1",
},
type: "NONE"
type: "NONE",
},
order: {
citizenId: "ASC",
isReserve: "ASC",
},
});
const _salaryPeriod4 = await this.salaryProfileRepository.find({
const _salaryPeriod4 = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
@ -302,14 +302,14 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
group: "GROUP2",
},
type: "HAFT"
type: "HAFT",
},
order: {
citizenId: "ASC",
isReserve: "ASC",
},
});
const _salaryPeriod5 = await this.salaryProfileRepository.find({
const _salaryPeriod5 = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
@ -318,14 +318,14 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
group: "GROUP2",
},
type: "FULL"
type: "FULL",
},
order: {
citizenId: "ASC",
isReserve: "ASC",
},
});
const _salaryPeriod6 = await this.salaryProfileRepository.find({
const _salaryPeriod6 = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
@ -334,7 +334,7 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
group: "GROUP2",
},
type: "NONE"
type: "NONE",
},
order: {
citizenId: "ASC",
@ -343,11 +343,11 @@ export class ReportController extends Controller {
});
const _salaryPeriod = _salaryPeriod1.concat(
_salaryPeriod2,
_salaryPeriod3,
_salaryPeriod4,
_salaryPeriod5,
_salaryPeriod6
_salaryPeriod2,
_salaryPeriod3,
_salaryPeriod4,
_salaryPeriod5,
_salaryPeriod6,
);
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
@ -557,10 +557,12 @@ export class ReportController extends Controller {
reportName: "gov1-02",
data: {
// date: Extension.ToThaiNumber(
// Extension.ToThaiFullDate2(new Date(`${salaryPeriod.year}-03-01`)),
// Extension.ToThaiFullDate2(new Date(`${salaryPeriod.year}-03-01`)),
// ),
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2)),
yearSlice: Extension.ToThaiNumber(
String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2),
),
// dateNow: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
agency: agency,
data1: formattedData1,
@ -1030,7 +1032,9 @@ export class ReportController extends Controller {
// Extension.ToThaiFullDate2(new Date(`${salaryPeriod.year}-03-01`)),
// ),
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2)),
yearSlice: Extension.ToThaiNumber(
String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2),
),
// dateNow: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
agency: agency,
data1: formattedData1,
@ -1276,7 +1280,11 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
@ -1286,7 +1294,11 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนหน้า
score: null, //ผลการประเมินฯ
@ -1320,7 +1332,11 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
@ -1330,7 +1346,11 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนหน้า
score: null, //ผลการประเมินฯ
@ -1572,7 +1592,13 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : Type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
@ -1582,20 +1608,37 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : Type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนหน้า
salaryIncreaseAPR:
salaryProfile_APR_Group1.length > 0
? (() => {
const filteredType = salaryProfile_APR_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : Type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "ไม่ได้เลื่อนขั้น"
})()
: null, //การเลื่อนเงินเดือนรอบเมษา
Type: item.type === "FULL" ? "หนึ่งขั้น" : item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : null,
? (() => {
const filteredType = salaryProfile_APR_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนรอบเมษา
Type:
item.type === "FULL"
? "หนึ่งขั้น"
: item.type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: null,
score1: null, //ผลการประเมินฯ ครั้งที่ 1
score2: null, //ผลการประเมินฯ ครั้งที่ 2
})),
@ -1627,7 +1670,13 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : Type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
@ -1637,20 +1686,37 @@ export class ReportController extends Controller {
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : Type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "ไม่ได้เลื่อนขั้น"
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนปีก่อนหน้า
salaryIncreaseAPR:
salaryProfile_APR_Group2.length > 0
? (() => {
const filteredType = salaryProfile_APR_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT" ? "ครึ่งขั้น" : Type === "FULL" ? "หนึ่งขั้น" : Type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "ไม่ได้เลื่อนขั้น"
})()
: null, //การเลื่อนเงินเดือนรอบเมษา
Type: item.type === "FULL" ? "หนึ่งขั้น" : item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : null,
? (() => {
const filteredType = salaryProfile_APR_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.type);
const Type = filteredType[0];
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น";
})()
: null, //การเลื่อนเงินเดือนรอบเมษา
Type:
item.type === "FULL"
? "หนึ่งขั้น"
: item.type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: null,
score1: null, //ผลการประเมินฯ ครั้งที่ 1
score2: null, //ผลการประเมินฯ ครั้งที่ 2
})),
@ -1896,7 +1962,7 @@ export class ReportController extends Controller {
salaryPeriodId: salaryPeriodId,
},
type: "NONE", //ไม่ได้เลื่อน
isRetired: salaryPeriod.period === 'APR' ? In([true, false]) : false, //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา
isRetired: salaryPeriod.period === "APR" ? In([true, false]) : false, //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา
},
order: {
salaryOrg: {
@ -2068,7 +2134,7 @@ export class ReportController extends Controller {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
isActive: true
isActive: true,
},
});
@ -2142,13 +2208,14 @@ export class ReportController extends Controller {
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearOld: Extension.ToThaiNumber((salaryPeriod.year + 542).toString()),
date: salaryPeriod.period === "APR"
? Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)),
)
: Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`)),
),
date:
salaryPeriod.period === "APR"
? Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)),
)
: Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`)),
),
agency: root,
data: formattedData,
},
@ -2184,10 +2251,10 @@ export class ReportController extends Controller {
rootId: rootId,
salaryPeriodId: salaryPeriodId,
salaryPeriod: {
period: salaryPeriod.period
period: salaryPeriod.period,
},
},
isRetired: true // เฉพาะคนที่เกษียณ
isRetired: true, // เฉพาะคนที่เกษียณ
},
order: {
type: "DESC",
@ -2243,7 +2310,9 @@ export class ReportController extends Controller {
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearOld: Extension.ToThaiNumber((salaryPeriod.year + 542).toString()),
date: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`))),
date: Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`)),
),
agency: root,
data: formattedData,
},
@ -2389,13 +2458,14 @@ export class ReportController extends Controller {
reportName: salaryPeriod.period === "APR" ? "gov1-08" : "gov2-09",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
date: salaryPeriod.period === "APR"
? Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)),
)
: Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`)),
),
date:
salaryPeriod.period === "APR"
? Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)),
)
: Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`)),
),
agency: salaryOrgGroup1?.root,
profileSpecial: profileSpecial,
profileNoAmount: profileNoAmount,
@ -2784,9 +2854,7 @@ export class ReportController extends Controller {
? "(" + Extension.ToThaiNumber(profile.amountSpecial.toString()) + ")"
: "",
amountSpecial:
profile.amountSpecial > 0
? Extension.ToThaiNumber(profile.amountSpecial.toString())
: "",
profile.amountSpecial > 0 ? Extension.ToThaiNumber(profile.amountSpecial.toString()) : "",
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
reason: null,
};
@ -3216,7 +3284,9 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel ? Extension.ToThaiNumber(String(profile.posLevel.toLocaleString())): null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(String(profile.posLevel.toLocaleString()))
: null,
};
});
@ -3466,83 +3536,83 @@ export class ReportController extends Controller {
},
});
}
/**
/**
* API 14-
*
* @summary 14-
*
*/
@Get("emp-14/{rootId}/{salaryPeriodId}")
async SalaryReportEmp1_14(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isNext: false,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
positionSalaryAmount: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
profile.child2,
profile.child1,
profile.root,
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
];
const fullName = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null, // หมายเหตุ
};
});
return new HttpSuccess({
template: "emp1-14",
reportName: "emp1-14",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
@Get("emp-14/{rootId}/{salaryPeriodId}")
async SalaryReportEmp1_14(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isNext: false,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
positionSalaryAmount: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
profile.child2,
profile.child1,
profile.root,
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
];
const fullName = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null, // หมายเหตุ
};
});
return new HttpSuccess({
template: "emp1-14",
reportName: "emp1-14",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
/**
* API 15-()
*
@ -3909,22 +3979,31 @@ export class ReportController extends Controller {
totalSalary:
octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.currentAmount.toLocaleString()),
sixPercent:
octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.sixPercentAmount.toLocaleString()),
octSnap1 == null
? ""
: Extension.ToThaiNumber(octSnap1.sixPercentAmount.toLocaleString()),
remainingAmountApr:
// aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.useAmount.toLocaleString()), //จำนวนเงินที่ใช้เลื่อนขั้นค่าจ้างไปแล้วในวันที่ 1 เม.ย.
aprSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.spentAmount.toLocaleString()),
remainingAmountOct:
//octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.spentAmount.toLocaleString()), //เหลือเงินใช้เลื่อนขั้นค่าจ้างในวันที่ 1 ต.ค.
octSnap2 == null ? "" : Extension.ToThaiNumber((octSnap2.sixPercentAmount - octSnap2.spentAmount).toLocaleString()),
octSnap2 == null
? ""
: Extension.ToThaiNumber(
(octSnap2.sixPercentAmount - octSnap2.spentAmount).toLocaleString(),
),
totalOld: aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.total.toLocaleString()), //จำนวน(คน)(โควตาเลื่อนขั้นค่าจ้าง)
fifteenPercentOld:
aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.fifteenPercent.toLocaleString()),
totalUseOld:
aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.quantityUsed.toLocaleString()), //พิจารณาให้(คน)(โควตาเลื่อนขั้นค่าจ้าง)
full2: totalEmp2step == null ? "" : Extension.ToThaiNumber(totalEmp2step.toLocaleString()), //เลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้นจำนวน(คน)
fullHaft: fullHaftCount == null ? "" : Extension.ToThaiNumber(fullHaftCount.toLocaleString()), //จำนวน(คน)(หนึ่งขั้นครึ่ง)
fullHaft:
fullHaftCount == null ? "" : Extension.ToThaiNumber(fullHaftCount.toLocaleString()), //จำนวน(คน)(หนึ่งขั้นครึ่ง)
fullHaftSalary:
fullHaftTotalAmount == null ? "" : Extension.ToThaiNumber(fullHaftTotalAmount.toLocaleString()), //ใช้เงิน(หนึ่งขั้นครึ่ง)
fullHaftTotalAmount == null
? ""
: Extension.ToThaiNumber(fullHaftTotalAmount.toLocaleString()), //ใช้เงิน(หนึ่งขั้นครึ่ง)
full: fullCount == null ? "" : Extension.ToThaiNumber(fullCount.toLocaleString()), //จำนวน(คน)(หนึ่งขั้น)
fullSalary:
fullTotalAmount == null ? "" : Extension.ToThaiNumber(fullTotalAmount.toLocaleString()), //ใช้เงิน(หนึ่งขั้น)
@ -5174,7 +5253,9 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel ? Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
};
});
@ -5451,7 +5532,9 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -5562,7 +5645,9 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -5651,7 +5736,9 @@ 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),
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -5738,7 +5825,9 @@ 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),
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -5829,7 +5918,9 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -5936,7 +6027,9 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -6018,29 +6111,28 @@ export class ReportController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
let perviousYearAPR:any;
let perviousYearOCT:any;
let salaryProfilePerviousAPR:any;
let salaryProfilePerviousOCT:any;
let perviousYearAPR: any;
let perviousYearOCT: any;
let salaryProfilePerviousAPR: any;
let salaryProfilePerviousOCT: any;
//งวดปีก่อนหน้า
perviousYearAPR = await this.salaryPeriodRepository.findOne({
perviousYearAPR = await this.salaryPeriodRepository.findOne({
where: {
period: "APR",
year: salaryPeriodOCT.year - 1,
},
});
perviousYearOCT = await this.salaryPeriodRepository.findOne({
perviousYearOCT = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriodOCT.year - 1,
},
});
//ปีก่อนหน้า
if(perviousYearAPR){
if (perviousYearAPR) {
salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
@ -6055,7 +6147,7 @@ export class ReportController extends Controller {
},
});
}
if(perviousYearOCT){
if (perviousYearOCT) {
salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
@ -6120,7 +6212,7 @@ export class ReportController extends Controller {
(aprProfile_old: SalaryProfile) => aprProfile_old.citizenId === profile.citizenId,
);
}
if (salaryProfilePerviousOCT && salaryProfilePerviousOCT.length > 0) {
matchedOCTProfileOld = salaryProfilePerviousOCT.find(
(octProfile_old: SalaryProfile) => octProfile_old.citizenId === profile.citizenId,
@ -6159,7 +6251,9 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel?Extension.ToThaiNumber(profile.posLevel.toLocaleString()):null,
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
@ -6183,4 +6277,184 @@ export class ReportController extends Controller {
},
});
}
/**
* API 33
*
* @summary 33
*
* @param {string} id Guid, *Id
*/
@Get("command/33/{id}")
async SalaryReport33(@Path() id: string) {
const salary = await this.salaryPeriodRepository.findOne({
where: { id: id },
});
if (!salary) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const salaryOrgs = await this.salaryOrgRepository.find({
where: { id: salary.id },
});
const salaryRank = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
},
});
const _salaryRank = salaryRank.map((item) => ({
id: item.id,
citizenId: item.citizenId,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
}));
return new HttpSuccess(_salaryRank);
}
/**
* API 34
*
* @summary 34
*
* @param {string} id Guid, *Id
*/
@Get("command/34/{id}")
async SalaryReport34(@Path() id: string) {
const salary = await this.salaryPeriodRepository.findOne({
where: { id: id },
});
if (!salary) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const salaryOrgs = await this.salaryOrgRepository.find({
where: { id: salary.id },
});
const salaryRank = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
},
});
const _salaryRank = salaryRank.map((item) => ({
id: item.id,
citizenId: item.citizenId,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
}));
return new HttpSuccess(_salaryRank);
}
/**
* API 35
*
* @summary 35
*
* @param {string} id Guid, *Id
*/
@Get("command/35/{id}")
async SalaryReport35(@Path() id: string) {
const salary = await this.salaryPeriodRepository.findOne({
where: { id: id },
});
if (!salary) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const salaryOrgs = await this.salaryOrgRepository.find({
where: { id: salary.id },
});
const salaryRank = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
},
});
const _salaryRank = salaryRank.map((item) => ({
id: item.id,
citizenId: item.citizenId,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
}));
return new HttpSuccess(_salaryRank);
}
/**
* API 36
*
* @summary 36
*
* @param {string} id Guid, *Id
*/
@Get("command/36/{id}")
async SalaryReport36(@Path() id: string) {
const salary = await this.salaryPeriodRepository.findOne({
where: { id: id },
});
if (!salary) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const salaryOrgs = await this.salaryOrgRepository.find({
where: { id: salary.id },
});
const salaryRank = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
},
});
const _salaryRank = salaryRank.map((item) => ({
id: item.id,
citizenId: item.citizenId,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
}));
return new HttpSuccess(_salaryRank);
}
/**
* API 37
*
* @summary 37
*
* @param {string} id Guid, *Id
*/
@Get("command/37/{id}")
async SalaryReport37(@Path() id: string) {
const salary = await this.salaryPeriodRepository.findOne({
where: { id: id },
});
if (!salary) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const salaryOrgs = await this.salaryOrgRepository.find({
where: { id: salary.id },
});
const salaryRank = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
},
});
const _salaryRank = salaryRank.map((item) => ({
id: item.id,
citizenId: item.citizenId,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
}));
return new HttpSuccess(_salaryRank);
}
}