Merge branch 'develop'

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2025-02-26 17:55:45 +07:00
commit 3db68cd99c

View file

@ -1090,64 +1090,13 @@ export class ReportController extends Controller {
},
});
}
const rootName = await this.salaryOrgRepository.findOne({
where: {
rootId: rootId,
},
select: ["root"],
});
//รอบปีก่อนๆ
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
where: {
period: "APR",
year: salaryPeriod.year - 2,
isActive: true,
},
});
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod.year - 2,
isActive: true,
},
});
// console.log(">>>>1",salaryPeriodIncrease1_APR);
let salaryOrg1_APR = null;
if (salaryPeriodIncrease1_APR) {
salaryOrg1_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
// rootId: rootId,
root: rootName?.root,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
// console.log(">>>>2",salaryOrg1_APR);
let salaryOrg1_OCT = null;
if (salaryPeriodIncrease1_OCT) {
salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
// rootId: rootId,
root: rootName?.root,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
const salaryProfile1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
type: Not(In(["NONE", "PENDING"])),
},
});
// console.log(">>>>3",salaryProfile1);
// const rootName = await this.salaryOrgRepository.findOne({
// where: {
// rootId: rootId,
// },
// select: ["root"],
// });
//รอบปีก่อนหน้า
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
where: {
@ -1163,14 +1112,14 @@ export class ReportController extends Controller {
isActive: true,
},
});
// console.log(">>>>3",salaryPeriodIncrease2_APR);
let salaryOrg2_APR = null;
if (salaryPeriodIncrease2_APR) {
salaryOrg2_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
// rootId: rootId,
root: rootName?.root,
// root: rootName?.root,
rootId:salaryOrg?.rootDnaId,
snapshot: "SNAP1",
group: convertGroup,
},
@ -1183,7 +1132,8 @@ export class ReportController extends Controller {
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
// rootId: rootId,
root: rootName?.root,
// root: rootName?.root,
rootId:salaryOrg?.rootDnaId,
snapshot: "SNAP1",
group: convertGroup,
},
@ -1197,6 +1147,56 @@ export class ReportController extends Controller {
},
});
//รอบปีก่อนๆ
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
where: {
period: "APR",
year: salaryPeriod.year - 2,
isActive: true,
},
});
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod.year - 2,
isActive: true,
},
});
let salaryOrg1_APR = null;
if (salaryPeriodIncrease1_APR) {
salaryOrg1_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
// rootId: rootId,
// root: rootName?.root,
rootId:salaryOrg2_APR?.rootDnaId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
let salaryOrg1_OCT = null;
if (salaryPeriodIncrease1_OCT) {
salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
// rootId: rootId,
// root: rootName?.root,
rootId:salaryOrg2_APR?.rootDnaId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
const salaryProfile1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
type: Not(In(["NONE", "PENDING"])),
},
});
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
const yearIncrease1 = Extension.ToThaiNumber(
String(Extension.ToThaiYear(salaryPeriod.year - 2)),
@ -2503,10 +2503,134 @@ export class ReportController extends Controller {
@Path() salaryPeriodId: string,
@Path() group: string,
) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
// period: "OCT",??
isActive: true,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
//ปีก่อนหน้า
const salaryOldPeriod = await this.salaryPeriodRepository.findOne({
where: {
year: salaryPeriod?.year - 1,
period: "OCT",
},
});
const convertGroup = group.toUpperCase();
const salaryOrg = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP2",
group: convertGroup,
},
relations: ["salaryProfiles"],
});
//ปีก่อนหน้า
let salaryOrgPrevious = null;
if (salaryOldPeriod) {
salaryOrgPrevious = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryOldPeriod?.id,
rootDnaId: salaryOrg?.rootDnaId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
const salaryProfile = await this.salaryProfileRepository.find({
relations: ["salaryOrg"],
where: {
salaryOrgId: In([salaryOrg?.id]),
// amountSpecial: MoreThan(0),
},
order: {
salaryOrg: {
group: "ASC",
},
posMasterNo: "ASC",
},
});
const salaryProfilePrevious = await this.salaryProfileRepository.find({
relations: ["salaryOrg"],
where: {
salaryOrgId: In([salaryOrgPrevious?.id]),
},
order: {
salaryOrg: {
group: "ASC",
},
posMasterNo: "ASC",
},
});
const formattedData = salaryProfile.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
root: item.root??"-",
position: item.position??"-",
posMasterNo:
Extension.ToThaiNumber(item.orgShortName) + Extension.ToThaiNumber(String(item.posMasterNo)),
posTypeCurrent: item.posType??"-",
posLevelCurrent: item.posLevel??"-",
amountCurrent: item.amount? Extension.ToThaiNumber(item.amount.toLocaleString()):"-",
posTypePrevious: salaryProfilePrevious.length > 0
? (() => {
const filteredType = salaryProfilePrevious
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.posType);
const posType = filteredType[0];
return posType
? posType : "-";
})()
: "-",
posLevelPrevious: salaryProfilePrevious.length > 0
? (() => {
const filteredLevel = salaryProfilePrevious
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.posLevel);
const posLevel = filteredLevel[0];
return posLevel
? posLevel : "-";
})()
: "-",
amountPrevious: salaryProfilePrevious.length > 0
? (() => {
const filteredAmount = salaryProfilePrevious
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const amount = filteredAmount[0];
return amount
? Extension.ToThaiNumber(amount.toLocaleString()):"-"
})()
: "-",
deduction: "-", //เงินปรับลด
promote: item.amountUse?Extension.ToThaiNumber(item.amountUse.toLocaleString()):"-", //เงินเลื่อนขั้น
qualification: "-", //เงินปรับวุฒิ
adjustRate: "-", //เงินปรับอัตรา
newRate: "-", //อัตราตั้งใหม่
specialPromote: "-", //ลำดับการเลื่อนกรณีพิเศษ
remark: item.remark??"-",
temporaryPayment: "-", //ถือจ่ายชั่วคราวขั้น
}))
return new HttpSuccess({
template: "gov2-10",
reportName: "gov2-10",
data: {},
data: {
data: formattedData,
},
});
}
@ -7817,6 +7941,8 @@ export class ReportController extends Controller {
body: {
refIds: {
refId: string;
// commandAffectDate: Date | null;//เก่า
commandDateAffect: Date | null; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandNo: string | null;
commandYear: number | null;
commandId: string | null;
@ -7827,7 +7953,6 @@ export class ReportController extends Controller {
mouthSalaryAmount: Double | null;
commandCode?: string | null;
commandName?: string | null;
commandDateAffect: Date | null;
commandDateSign: Date | null;
}[];
},
@ -7897,18 +8022,23 @@ export class ReportController extends Controller {
body: {
refIds: {
refId: string;
// commandAffectDate: Date | null;//เก่า
commandDateAffect: Date | null; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandDateSign?: Date | null
commandNo: string | null;
commandYear: number | null;
commandId: string | null;
remark: string | null;
commandCode?: string | null;
commandName?: string | null;
templateDoc?: string | null;
amount: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount: Double | null;
mouthSalaryAmount: Double | null;
commandCode?: string | null;
commandName?: string | null;
commandDateAffect: Date | null;
commandDateSign: Date | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
remark?: string | null;
}[];
},
@Request() request: RequestWithUser,
@ -7920,6 +8050,7 @@ export class ReportController extends Controller {
id: v.refId,
},
});
if (salary != null) {
await new CallAPI()
.PostData(request, "/org/profile-employee/salary/update", {
@ -7930,12 +8061,11 @@ export class ReportController extends Controller {
amountSpecial: v.amountSpecial,
positionSalaryAmount: v.positionSalaryAmount,
mouthSalaryAmount: v.mouthSalaryAmount,
posNo: salary.posMasterNo.toString(),
posNo: salary.posMasterNo != null?salary.posMasterNo.toString():null,
posNoAbb: salary.orgShortName,
positionName: salary.position,
positionType: salary.posType,
positionLevel: salary.posLevel,
commandId: v.commandId,
positionLevel: salary.posLevel != null?salary.posLevel.toString():null,
remark: v.remark,
orgRoot: salary.root,
orgChild1: salary.child1,
@ -7946,6 +8076,7 @@ export class ReportController extends Controller {
commandName: v.commandName,
commandNo: v.commandNo,
commandYear: v.commandYear,
commandId: v.commandId,
})
.then(async () => {
const before = null;