This commit is contained in:
parent
a76bda34b4
commit
9f9fd612d3
3 changed files with 66 additions and 102 deletions
|
|
@ -1493,8 +1493,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
const position_raw = await this.salaryRepo.find({
|
||||
where: {
|
||||
profileEmployeeId: id,
|
||||
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16", "20"]),
|
||||
isEntry: false,
|
||||
commandCode: In(["0","1","2","3","4","8","9","10","11","12","13","14","15","16","20"]),
|
||||
// isEntry: false,
|
||||
},
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
|
|
@ -1523,7 +1523,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
positionSalaryAmount: item.positionSalaryAmount
|
||||
? Extension.ToThaiNumber(Number(item.positionSalaryAmount).toLocaleString())
|
||||
: "",
|
||||
refDoc: Extension.ToThaiNumber(`คำสั่ง ${item.posNumCodeSitAbb} ที่ ${item.commandNo}/${item.commandYear>2500?item.commandYear:item.commandYear+543} ลว. ${(Extension.ToThaiFullDate2(item.commandDateAffect))}`)
|
||||
refDoc: Extension.ToThaiNumber(`คำสั่ง ${item.posNumCodeSitAbb ?? "-"} ที่ ${item.commandNo ?? "-"}/${item.commandYear>2500?item.commandYear:item.commandYear+543} ลว. ${(Extension.ToThaiFullDate2(item.commandDateAffect))}`)
|
||||
}))
|
||||
: [
|
||||
{
|
||||
|
|
@ -1734,7 +1734,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
? Extension.ToThaiNumber(item.positionCee)
|
||||
: null,
|
||||
amount: item.amount ? Extension.ToThaiNumber(Number(item.amount).toLocaleString()) : "",
|
||||
refDoc: Extension.ToThaiNumber(`คำสั่ง ${item.posNumCodeSitAbb} ที่ ${item.commandNo}/${item.commandYear>2500?item.commandYear:item.commandYear+543} ลว. ${(Extension.ToThaiFullDate2(item.commandDateAffect))}`)
|
||||
refDoc: Extension.ToThaiNumber(`คำสั่ง ${item.posNumCodeSitAbb ?? "-"} ที่ ${item.commandNo ?? "-"}/${item.commandYear>2500?item.commandYear:item.commandYear+543} ลว. ${(Extension.ToThaiFullDate2(item.commandDateAffect))}`)
|
||||
}))
|
||||
: [
|
||||
{
|
||||
|
|
@ -1750,50 +1750,35 @@ export class ProfileEmployeeController extends Controller {
|
|||
];
|
||||
|
||||
// ประวัติพ้นจากราชการ
|
||||
const retireCodes = ['C-PM-12','C-PM-13','C-PM-17','C-PM-18','C-PM-19','C-PM-20','C-PM-23','C-PM-43'];
|
||||
|
||||
let retires = [];
|
||||
let inRetirePeriod = false;
|
||||
let currentRetire = null;
|
||||
const currentDate = new Date();
|
||||
const retire_raw = await this.salaryRepo.findOne({
|
||||
where: {
|
||||
profileEmployeeId: id,
|
||||
commandCode: In(["16"]),
|
||||
},
|
||||
order: { order: "desc" },
|
||||
});
|
||||
|
||||
for (let i = 0; i < position_raw.length; i++) {
|
||||
const item = position_raw[i];
|
||||
if (retire_raw) {
|
||||
const startDate = retire_raw.commandDateAffect;
|
||||
|
||||
if (retireCodes.includes(item.commandCode)) {
|
||||
// เริ่มพ้นจากราชการ
|
||||
currentRetire = {
|
||||
commandName: item.commandName ?? "-",
|
||||
startDate: item.commandDateAffect
|
||||
};
|
||||
inRetirePeriod = true;
|
||||
// คำนวณจำนวนวันจากวันพ้นสภาพถึงปัจจุบัน
|
||||
let daysCount = 0;
|
||||
if (startDate) {
|
||||
const start = new Date(startDate);
|
||||
daysCount = Math.ceil((currentDate.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
else if (inRetirePeriod && currentRetire) {
|
||||
// เจอคำสั่งถัดไปที่ไม่ใช่การพ้นจากราชการ = วันกลับเข้า
|
||||
const endDate = item.commandDateAffect;
|
||||
let daysCount = 0;
|
||||
|
||||
if (currentRetire.startDate && endDate) {
|
||||
const start = new Date(currentRetire.startDate);
|
||||
const end = new Date(endDate);
|
||||
daysCount = Math.ceil((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
const startDateStr = startDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(startDate))
|
||||
: "-";
|
||||
|
||||
const startDateStr = currentRetire.startDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(currentRetire.startDate))
|
||||
: "-";
|
||||
const endDateStr = endDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(endDate))
|
||||
: "-";
|
||||
|
||||
retires.push({
|
||||
date: `${startDateStr} - ${endDateStr}`,
|
||||
detail: currentRetire.commandName,
|
||||
day: daysCount > 0 ? Extension.ToThaiNumber(daysCount.toLocaleString()) : "-"
|
||||
});
|
||||
|
||||
inRetirePeriod = false;
|
||||
currentRetire = null;
|
||||
}
|
||||
retires.push({
|
||||
date: `${startDateStr} - ปัจจุบัน`,
|
||||
detail: retire_raw.commandName ?? "-",
|
||||
day: daysCount > 0 ? Extension.ToThaiNumber(daysCount.toLocaleString()) : "-"
|
||||
});
|
||||
}
|
||||
|
||||
// กรณีไม่มีข้อมูล
|
||||
|
|
@ -1865,6 +1850,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
)
|
||||
: "";
|
||||
const data = {
|
||||
currentDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(currentDate)),
|
||||
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
prefix: profiles?.prefix != null ? profiles.prefix : "",
|
||||
firstName: profiles?.firstName != null ? profiles.firstName : "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue