fix report kk1
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m4s

This commit is contained in:
harid 2026-03-25 15:53:26 +07:00
parent 702eb13782
commit effc782460
2 changed files with 332 additions and 187 deletions

View file

@ -87,6 +87,7 @@ import { OrgChild4 } from "../entities/OrgChild4";
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
import { ProfileAssistance } from "../entities/ProfileAssistance";
import { CommandRecive } from "../entities/CommandRecive";
import { CommandCode } from "../entities/CommandCode";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { CreatePosMasterHistoryOfficer, getTopDegrees } from "../services/PositionService";
import { ProfileLeaveService } from "../services/ProfileLeaveService";
@ -146,6 +147,7 @@ export class ProfileController extends Controller {
private permissionProflileRepository = AppDataSource.getRepository(PermissionProfile);
private profileAssistanceRepository = AppDataSource.getRepository(ProfileAssistance);
private commandReciveRepository = AppDataSource.getRepository(CommandRecive);
private commandCodeRepository = AppDataSource.getRepository(CommandCode);
// Services
private profileLeaveService = new ProfileLeaveService();
@ -1370,26 +1372,26 @@ export class ProfileController extends Controller {
yearData = { year };
for (let i = 1; i <= 11; i++) {
yearData[`leaveTypeCodeLv${i}`] = "-";
yearData[`totalLeaveDaysLv${i}`] = "-";
yearData[`leaveTypeNameLv${i}`] = "-";
yearData[`leaveTypeCodeLv${i}`] = "";
yearData[`totalLeaveDaysLv${i}`] = "";
yearData[`leaveTypeNameLv${i}`] = "";
}
leaves.push(yearData);
}
yearData[leaveTypeCodeKey] = item.code ? item.code : "-";
yearData[leaveTypeCodeKey] = item.code ? item.code : "";
yearData[totalLeaveDaysKey] = item.totalLeaveDays
? Extension.ToThaiNumber(item.totalLeaveDays.toString())
: "-";
yearData[leaveTypeNameKey] = item.name ? item.name : "-";
yearData[leaveTypeNameKey] = item.name ? item.name : "";
}
}
});
if (leaves.length === 0) {
leaves.push({year:""});
}
// if (leaves.length === 0) {
// leaves.push({year:""});
// }
// Query มาสาย/ขาดราชการ และ merge ตามปี
const absentLate_raw = await this.profileAbsentLateRepo
@ -1417,9 +1419,9 @@ export class ProfileController extends Controller {
if (!yearData) {
yearData = { year };
for (let i = 1; i <= 11; i++) {
yearData[`leaveTypeCodeLv${i}`] = "-";
yearData[`totalLeaveDaysLv${i}`] = "-";
yearData[`leaveTypeNameLv${i}`] = "-";
yearData[`leaveTypeCodeLv${i}`] = "";
yearData[`totalLeaveDaysLv${i}`] = "";
yearData[`leaveTypeNameLv${i}`] = "";
}
leaves.push(yearData);
}
@ -1428,18 +1430,18 @@ export class ProfileController extends Controller {
if (item.status === "LATE") {
yearData.late = item.totalAmount
? Extension.ToThaiNumber(parseFloat(item.totalAmount).toFixed(1))
: "-";
: "";
} else if (item.status === "ABSENT") {
yearData.absent = item.totalAmount
? Extension.ToThaiNumber(parseFloat(item.totalAmount).toFixed(1))
: "-";
: "";
}
});
// เติมค่า "-" ถ้าไม่มีข้อมูลมาสาย/ขาดราชการ
// เติมค่า "" ถ้าไม่มีข้อมูลมาสาย/ขาดราชการ
leaves.forEach((yearData) => {
if (!yearData.late) yearData.late = "-";
if (!yearData.absent) yearData.absent = "-";
if (!yearData.late) yearData.late = "";
if (!yearData.absent) yearData.absent = "";
});
const leave2_raw = await this.profileLeaveRepository
@ -1568,39 +1570,78 @@ export class ProfileController extends Controller {
];
const position_raw = await this.salaryRepo.find({
where: {
where: [{
profileId: id,
commandCode: In(["0","1","2","3","4","8","9","10","11","12","13","14","15","16","20"]),
// isEntry: false,
},
{ profileId: id, commandCode: IsNull() }],
order: { order: "ASC" },
});
let _commandName:any = "";
let _commandDateAffect:any = ""
const positionList =
position_raw.length > 0
? position_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect
? await Promise.all(position_raw.map(async(item, idx, arr) => {
const isLast = idx === arr.length - 1;
if (isLast) {
_commandDateAffect = item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "",
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
posNo:
item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb} ${item.posNo}`)
: "";
}
const _code = item.commandCode ? Number(item.commandCode) : null;
if (_code != null) {
_commandName = await this.commandCodeRepository.findOne({
select: { name: true, code: true },
where: { code: _code }
});
}
const codeSitAbb = item.posNumCodeSitAbb ?? "-"
const commandNo = item.commandNo && item.commandYear
? item.commandNo+"/"+(item.commandYear > 2500 ? item.commandYear : item.commandYear + 543)
: "-"
const dateAffect = item.commandDateAffect
? `${Extension.ToThaiFullDate2(item.commandDateAffect)}`
: "-"
return {
commandName: _commandName && _commandName.name
? _commandName.name
: item.commandName,
commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(
Extension.ToThaiFullDate2(item.commandDateAffect)
)
: "",
position: item.positionName,
posType: item.positionType,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(
Extension.ToThaiFullDate2(item.commandDateSign)
)
: "",
posNo:
item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb} ${item.posNo}`)
: "",
position: item.positionName,
posType: item.positionType,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
? Extension.ToThaiNumber(item.positionCee)
: null,
amount: item.amount ? Extension.ToThaiNumber(Number(item.amount).toLocaleString()) : "",
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))}`)
amount: item.amount
? Extension.ToThaiNumber(
Number(item.amount).toLocaleString()
)
: "",
positionSalaryAmount: item.positionSalaryAmount
? Extension.ToThaiNumber(
Number(item.positionSalaryAmount).toLocaleString()
)
: "",
refDoc: Extension.ToThaiNumber(
`คำสั่ง ${codeSitAbb} ที่ ${commandNo} ลว. ${dateAffect}`
),
};
}))
: [
{
@ -1620,34 +1661,35 @@ export class ProfileController extends Controller {
// ประวัติพ้นจากราชการ
let retires = [];
const currentDate = new Date();
const retire_raw = await this.salaryRepo.findOne({
where: {
profileId: id,
commandCode: In(["12", "15", "16"]),
},
order: { order: "desc" },
});
// todo: รอข้อสรุป
// const retire_raw = await this.salaryRepo.findOne({
// where: {
// profileId: id,
// commandCode: In(["12", "15", "16"]),
// },
// order: { order: "desc" },
// });
if (retire_raw) {
const startDate = retire_raw.commandDateAffect;
// if (retire_raw) {
// const startDate = retire_raw.commandDateAffect;
// คำนวณจำนวนวันจากวันพ้นสภาพถึงปัจจุบัน
let daysCount = 0;
if (startDate) {
const start = new Date(startDate);
daysCount = Math.ceil((currentDate.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
}
// // คำนวณจำนวนวันจากวันพ้นสภาพถึงปัจจุบัน
// let daysCount = 0;
// if (startDate) {
// const start = new Date(startDate);
// daysCount = Math.ceil((currentDate.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
// }
const startDateStr = startDate
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(startDate))
: "-";
// const startDateStr = startDate
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(startDate))
// : "-";
retires.push({
date: `${startDateStr}`,
detail: retire_raw.commandName ?? "-",
day: daysCount > 0 ? Extension.ToThaiNumber(daysCount.toLocaleString()) : "-"
});
}
// retires.push({
// date: `${startDateStr}`,
// detail: retire_raw.commandName ?? "-",
// day: daysCount > 0 ? Extension.ToThaiNumber(daysCount.toLocaleString()) : "-"
// });
// }
// กรณีไม่มีข้อมูล
if (retires.length === 0) {
@ -1782,7 +1824,7 @@ export class ProfileController extends Controller {
});
}
}
// Merge รักษาการ และ ช่วยราชาร
// Merge รักษาการ และ ช่วยราชาร
const actposition = [..._actpositions, ..._assistances];
const duty_raw = await this.dutyRepository.find({
@ -1892,23 +1934,33 @@ export class ProfileController extends Controller {
});
const otherIncome =
otherIncome_raw.length > 0
? otherIncome_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "",
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
commandNo: item.commandNo ? Extension.ToThaiNumber(item.commandNo) : "",
position: item.positionName,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
? 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))}`)
? await Promise.all(
otherIncome_raw.map(async(item) => {
const codeSitAbb = item.posNumCodeSitAbb ?? "-"
const commandNo = item.commandNo && item.commandYear
? item.commandNo+"/"+(item.commandYear > 2500 ? item.commandYear : item.commandYear + 543)
: "-"
const dateAffect = item.commandDateAffect
? `${Extension.ToThaiFullDate2(item.commandDateAffect)}`
: "-"
return {
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "",
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
commandNo: item.commandNo ? Extension.ToThaiNumber(item.commandNo) : "",
position: item.positionName,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
? Extension.ToThaiNumber(item.positionCee)
: null,
amount: item.amount ? Extension.ToThaiNumber(Number(item.amount).toLocaleString()) : "",
refDoc: Extension.ToThaiNumber(`คำสั่ง ${codeSitAbb} ที่ ${commandNo} ลว. ${dateAffect}`)
}
}))
: [
{
@ -2042,8 +2094,7 @@ export class ProfileController extends Controller {
appointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "",
positionDate:
positionList.length > 0 ? positionList[positionList.length - 1].commandDateAffect : "",
positionDate: _commandDateAffect ?? "",
citizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
fatherFullName:

View file

@ -84,6 +84,7 @@ import { ProfileDuty } from "../entities/ProfileDuty";
import { getTopDegrees } from "../services/PositionService";
import { ProfileLeaveService } from "../services/ProfileLeaveService";
import { PostRetireToExprofile } from "./ExRetirementController";
import { CommandCode } from "../entities/CommandCode";
@Route("api/v1/org/profile-employee")
@Tags("ProfileEmployee")
@Security("bearerAuth")
@ -136,6 +137,7 @@ export class ProfileEmployeeController extends Controller {
private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment);
private profileAbilityRepo = AppDataSource.getRepository(ProfileAbility);
private profileAssistanceRepository = AppDataSource.getRepository(ProfileAssistance);
private commandCodeRepository = AppDataSource.getRepository(CommandCode);
// Services
private profileLeaveService = new ProfileLeaveService();
@ -808,27 +810,68 @@ export class ProfileEmployeeController extends Controller {
},
];
const leave_raw = await this.profileLeaveRepository.find({
relations: { leaveType: true },
where: { profileEmployeeId: id, isDeleted: false },
order: { dateLeaveStart: "ASC" },
const leave_raw = await this.profileLeaveRepository
.createQueryBuilder("profileLeave")
.leftJoinAndSelect("profileLeave.leaveType", "leaveType")
.select([
"profileLeave.isDeleted",
"profileLeave.leaveTypeId",
"leaveType.name as name",
"leaveType.code as code",
"profileLeave.status",
"profileLeave.profileEmployeeId",
"MAX(profileLeave.dateLeaveStart) as maxDateLeaveStart",
])
.addSelect("SUM(profileLeave.leaveDays)", "totalLeaveDays")
.where("profileLeave.profileEmployeeId = :profileId", { profileId: id })
.andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false })
.andWhere("profileLeave.status = :status", { status: "approve" })
.groupBy("profileLeave.leaveTypeId")
.orderBy("code", "ASC")
.addOrderBy("maxDateLeaveStart", "ASC")
.getRawMany();
const leaves: any[] = [];
leave_raw.forEach((item) => {
const leaveTypeCode = item.code ? item.code.trim().toUpperCase() : "";
if (leaveTypeCode.startsWith("LV-")) {
const lvIndex = parseInt(leaveTypeCode.split("-")[1], 10);
if (lvIndex >= 1 && lvIndex <= 11) {
const leaveTypeCodeKey = `leaveTypeCodeLv${lvIndex}`;
const totalLeaveDaysKey = `totalLeaveDaysLv${lvIndex}`;
const leaveTypeNameKey = `leaveTypeNameLv${lvIndex}`;
const leaveDate = item.maxDateLeaveStart ? new Date(item.maxDateLeaveStart) : null;
const year = leaveDate
? Extension.ToThaiNumber(Extension.ToThaiShortYear(leaveDate))
: "";
let yearData = leaves.find((data) => data.year === year);
if (!yearData) {
yearData = { year };
for (let i = 1; i <= 11; i++) {
yearData[`leaveTypeCodeLv${i}`] = "-";
yearData[`totalLeaveDaysLv${i}`] = "-";
yearData[`leaveTypeNameLv${i}`] = "-";
}
leaves.push(yearData);
}
yearData[leaveTypeCodeKey] = item.code ? item.code : "-";
yearData[totalLeaveDaysKey] = item.totalLeaveDays
? Extension.ToThaiNumber(item.totalLeaveDays.toString())
: "-";
yearData[leaveTypeNameKey] = item.name ? item.name : "-";
}
}
});
const leaves =
leave_raw.length > 0
? leave_raw.map((item) => ({
LeaveTypeName: item.leaveType.name,
DateLeaveStart: item.dateLeaveStart
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
: "",
LeaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "",
}))
: [
{
LeaveTypeName: "-",
DateLeaveStart: "-",
LeaveDays: "-",
},
];
// กรองเอา object ที่ไม่มี year ออก
const filteredLeaves = leaves.filter(item => item.year && item.year !== "");
const data = {
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
@ -917,7 +960,7 @@ export class ProfileEmployeeController extends Controller {
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt))
: null,
insignias,
leaves,
leaves: filteredLeaves,
certs,
trainings,
disciplines,
@ -943,6 +986,7 @@ export class ProfileEmployeeController extends Controller {
public async getKk1new(@Path() id: string, @Request() req: RequestWithUser) {
const profiles = await this.profileRepo.findOne({
relations: [
"posType",
"posLevel",
"currentSubDistrict",
"currentDistrict",
@ -1364,26 +1408,26 @@ export class ProfileEmployeeController extends Controller {
yearData = { year };
for (let i = 1; i <= 11; i++) {
yearData[`leaveTypeCodeLv${i}`] = "-";
yearData[`totalLeaveDaysLv${i}`] = "-";
yearData[`leaveTypeNameLv${i}`] = "-";
yearData[`leaveTypeCodeLv${i}`] = "";
yearData[`totalLeaveDaysLv${i}`] = "";
yearData[`leaveTypeNameLv${i}`] = "";
}
leaves.push(yearData);
}
yearData[leaveTypeCodeKey] = item.code ? item.code : "-";
yearData[leaveTypeCodeKey] = item.code ? item.code : "";
yearData[totalLeaveDaysKey] = item.totalLeaveDays
? Extension.ToThaiNumber(item.totalLeaveDays.toString())
: "-";
yearData[leaveTypeNameKey] = item.name ? item.name : "-";
: "";
yearData[leaveTypeNameKey] = item.name ? item.name : "";
}
}
});
if (leaves.length === 0) {
leaves.push({year:""});
}
// if (leaves.length === 0) {
// leaves.push({year:""});
// }
// Query มาสาย/ขาดราชการ และ merge ตามปี
const absentLate_raw = await this.profileEmployeeAbsentLateRepo
@ -1411,9 +1455,9 @@ export class ProfileEmployeeController extends Controller {
if (!yearData) {
yearData = { year };
for (let i = 1; i <= 11; i++) {
yearData[`leaveTypeCodeLv${i}`] = "-";
yearData[`totalLeaveDaysLv${i}`] = "-";
yearData[`leaveTypeNameLv${i}`] = "-";
yearData[`leaveTypeCodeLv${i}`] = "";
yearData[`totalLeaveDaysLv${i}`] = "";
yearData[`leaveTypeNameLv${i}`] = "";
}
leaves.push(yearData);
}
@ -1422,18 +1466,18 @@ export class ProfileEmployeeController extends Controller {
if (item.status === "LATE") {
yearData.lateAmount = item.totalAmount
? Extension.ToThaiNumber(parseFloat(item.totalAmount).toFixed(1))
: "-";
: "";
} else if (item.status === "ABSENT") {
yearData.absentAmount = item.totalAmount
? Extension.ToThaiNumber(parseFloat(item.totalAmount).toFixed(1))
: "-";
: "";
}
});
// เติมค่า "-" ถ้าไม่มีข้อมูลมาสาย/ขาดราชการ
// เติมค่า "" ถ้าไม่มีข้อมูลมาสาย/ขาดราชการ
leaves.forEach((yearData) => {
if (!yearData.lateAmount) yearData.lateAmount = "-";
if (!yearData.absentAmount) yearData.absentAmount = "-";
if (!yearData.lateAmount) yearData.lateAmount = "";
if (!yearData.absentAmount) yearData.absentAmount = "";
});
const leave2_raw = await this.profileLeaveRepository
@ -1562,39 +1606,78 @@ export class ProfileEmployeeController extends Controller {
];
const position_raw = await this.salaryRepo.find({
where: {
where: [{
profileEmployeeId: id,
commandCode: In(["0","1","2","3","4","8","9","10","11","12","13","14","15","16","20"]),
// isEntry: false,
},
{ profileEmployeeId: id, commandCode: IsNull() }],
order: { order: "ASC" },
});
let _commandName:any = "";
let _commandDateAffect:any = ""
const positionList =
position_raw.length > 0
? position_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect
? await Promise.all(position_raw.map(async(item, idx, arr) => {
const isLast = idx === arr.length - 1;
if (isLast) {
_commandDateAffect = item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "",
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
posNo:
item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb} ${item.posNo}`)
: "";
}
const _code = item.commandCode ? Number(item.commandCode) : null;
if (_code != null) {
_commandName = await this.commandCodeRepository.findOne({
select: { name: true, code: true },
where: { code: _code }
});
}
const codeSitAbb = item.posNumCodeSitAbb ?? "-"
const commandNo = item.commandNo && item.commandYear
? item.commandNo+"/"+(item.commandYear > 2500 ? item.commandYear : item.commandYear + 543)
: "-"
const dateAffect = item.commandDateAffect
? `${Extension.ToThaiFullDate2(item.commandDateAffect)}`
: "-"
return {
commandName: _commandName && _commandName.name
? _commandName.name
: item.commandName,
commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(
Extension.ToThaiFullDate2(item.commandDateAffect)
)
: "",
position: item.positionName,
posType: item.positionType,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(
Extension.ToThaiFullDate2(item.commandDateSign)
)
: "",
posNo:
item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb} ${item.posNo}`)
: "",
position: item.positionName,
posType: item.positionType,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
? Extension.ToThaiNumber(item.positionCee)
: null,
amount: item.amount ? Extension.ToThaiNumber(Number(item.amount).toLocaleString()) : "",
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))}`)
amount: item.amount
? Extension.ToThaiNumber(
Number(item.amount).toLocaleString()
)
: "",
positionSalaryAmount: item.positionSalaryAmount
? Extension.ToThaiNumber(
Number(item.positionSalaryAmount).toLocaleString()
)
: "",
refDoc: Extension.ToThaiNumber(
`คำสั่ง ${codeSitAbb} ที่ ${commandNo} ลว. ${dateAffect}`
),
};
}))
: [
{
@ -1610,6 +1693,7 @@ export class ProfileEmployeeController extends Controller {
refDoc: ""
},
];
// ลูกจ้างยังไม่มีรักษาการและช่วยราชการ
// const actposition_raw = await this.profileActpositionRepo.find({
// select: ["dateStart", "dateEnd", "position", "isDeleted"],
@ -1789,23 +1873,33 @@ export class ProfileEmployeeController extends Controller {
});
const otherIncome =
otherIncome_raw.length > 0
? otherIncome_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "",
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
commandNo: item.commandNo ? Extension.ToThaiNumber(item.commandNo) : "",
position: item.positionName,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
? 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))}`)
? await Promise.all(
otherIncome_raw.map(async(item) => {
const codeSitAbb = item.posNumCodeSitAbb ?? "-"
const commandNo = item.commandNo && item.commandYear
? item.commandNo+"/"+(item.commandYear > 2500 ? item.commandYear : item.commandYear + 543)
: "-"
const dateAffect = item.commandDateAffect
? `${Extension.ToThaiFullDate2(item.commandDateAffect)}`
: "-"
return {
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "",
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
commandNo: item.commandNo ? Extension.ToThaiNumber(item.commandNo) : "",
position: item.positionName,
posLevel: item.positionLevel
? Extension.ToThaiNumber(item.positionLevel)
: item.positionCee
? Extension.ToThaiNumber(item.positionCee)
: null,
amount: item.amount ? Extension.ToThaiNumber(Number(item.amount).toLocaleString()) : "",
refDoc: Extension.ToThaiNumber(`คำสั่ง ${codeSitAbb} ที่ ${commandNo} ลว. ${dateAffect}`)
}
}))
: [
{
@ -1823,34 +1917,35 @@ export class ProfileEmployeeController extends Controller {
// ประวัติพ้นจากราชการ
let retires = [];
const currentDate = new Date();
const retire_raw = await this.salaryRepo.findOne({
where: {
profileEmployeeId: id,
commandCode: In(["12", "15", "16"]),
},
order: { order: "desc" },
});
// todo: รอข้อสรุป
// const retire_raw = await this.salaryRepo.findOne({
// where: {
// profileEmployeeId: id,
// commandCode: In(["12", "15", "16"]),
// },
// order: { order: "desc" },
// });
if (retire_raw) {
const startDate = retire_raw.commandDateAffect;
// if (retire_raw) {
// const startDate = retire_raw.commandDateAffect;
// คำนวณจำนวนวันจากวันพ้นสภาพถึงปัจจุบัน
let daysCount = 0;
if (startDate) {
const start = new Date(startDate);
daysCount = Math.ceil((currentDate.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
}
// // คำนวณจำนวนวันจากวันพ้นสภาพถึงปัจจุบัน
// let daysCount = 0;
// if (startDate) {
// const start = new Date(startDate);
// daysCount = Math.ceil((currentDate.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
// }
const startDateStr = startDate
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(startDate))
: "-";
// const startDateStr = startDate
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(startDate))
// : "-";
retires.push({
date: `${startDateStr} - ปัจจุบัน`,
detail: retire_raw.commandName ?? "-",
day: daysCount > 0 ? Extension.ToThaiNumber(daysCount.toLocaleString()) : "-"
});
}
// retires.push({
// date: `${startDateStr} - ปัจจุบัน`,
// detail: retire_raw.commandName ?? "-",
// day: daysCount > 0 ? Extension.ToThaiNumber(daysCount.toLocaleString()) : "-"
// });
// }
// กรณีไม่มีข้อมูล
if (retires.length === 0) {
@ -1863,11 +1958,11 @@ export class ProfileEmployeeController extends Controller {
(_child2 == null ? "" : _child2 + " ") +
(_child1 == null ? "" : _child1 + " ") +
(_root == null ? "" : _root).trim()
const _position = profiles?.position != null ?
profiles?.posLevel != null
? Extension.ToThaiNumber(`${profiles.position}${profiles.posLevel.posLevelName}`)
const _position = (profiles?.position != null ?
profiles.posType != null && profiles?.posLevel != null
? Extension.ToThaiNumber(`${profiles.position} ${profiles.posType.posTypeShortName} ${profiles.posLevel.posLevelName}`)
: profiles.position
: ""
: "").trim()
const ocAssistance = await this.profileAssistanceRepository.findOne({
select: ["agency", "profileEmployeeId", "commandName", "status", "isDeleted"],
where: {
@ -1960,8 +2055,7 @@ export class ProfileEmployeeController extends Controller {
appointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "",
positionDate:
positionList.length > 0 ? positionList[positionList.length - 1].commandDateAffect : "",
positionDate: _commandDateAffect ?? "",
citizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
fatherFullName: