no message

This commit is contained in:
Bright 2024-03-29 11:27:56 +07:00
parent 79f9c1637d
commit fbe018c211
2 changed files with 650 additions and 823 deletions

View file

@ -3831,28 +3831,95 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
const fifteenPoint = await this.salaryOrgEmployeeRepository.findOne({
where:{
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP1",
} ,
select:[
"fifteenPoint",
"fifteenPercent"
]
})
if (!_salaryPeriod) {
const fifteenPercentData =
fifteenPoint?.fifteenPercent == undefined || fifteenPoint?.fifteenPercent == null
? ""
: Extension.ToThaiNumber(String(fifteenPoint?.fifteenPercent));
const fifteenPointData =
fifteenPoint?.fifteenPoint == undefined || fifteenPoint?.fifteenPoint == null
? "."
: "." + Extension.ToThaiNumber(String(fifteenPoint?.fifteenPoint));
const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
type: "FULL",
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriodTarget) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const octPreviousYear = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 1,
},
});
const formattedData = _salaryPeriod.map((profile, index) => {
const octPreviousYear2 = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 2,
},
});
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
if (octPreviousYear) {
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
type: "FULL",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: octPreviousYear?.id,
},
},
});
}
let octPreviousYearProfile2: SalaryProfileEmployee[] = [];
if (octPreviousYear2) {
octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
type: "FULL",
salaryOrg: {
snapshot: "SNAP2",
salaryPeriodId: octPreviousYear2?.id,
rootId: rootId,
},
},
});
}
const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root;
const formattedData = _salaryPeriodTarget.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
@ -3869,19 +3936,82 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
typeOld2:
octPreviousYear2 && octPreviousYearProfile2.length > 0 ? (() => {
const _profile = octPreviousYearProfile2
.filter((profileOCT2) => profileOCT2.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
yearOld: octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()),
typeOld1:
octPreviousYear && octPreviousYearProfile.length > 0 ? (() => {
const _profile = octPreviousYearProfile
.filter((profileOCT) => profileOCT.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
typeOld:
_salaryPeriodTarget.length > 0
? (() => {
const _profile = _salaryPeriodTarget
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
.map((profile) => ({
type: profile.type,
}));
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
})()
: null, //เมษา ปีเดียวกัน
type:
profile.type === "HAFT"
? ".๕ ขั้น"
: profile.type === "FULL"
? "๑ ขั้น"
: profile.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ",
score1: null,
score2: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
template: "emp2-03",
reportName: "emp2-03",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(-2,),
yearShortOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))).slice(-2,),
fifteenPercent: fifteenPercentData + fifteenPointData,
agency: agency,
data: formattedData,
},
@ -3990,21 +4120,24 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
amountSpecial: Not(IsNull()),
type: Not("NONE"),
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
@ -4028,17 +4161,19 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null,
amountSpecial: profile.amountSpecial ? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
template: "emp2-05",
reportName: "emp2-05",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
@ -4149,21 +4284,23 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
type: "NONE",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
@ -4187,17 +4324,20 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
score: null,
signature: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
template: "emp2-07",
reportName: "emp2-07",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
@ -4293,28 +4433,75 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isRetired: true,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriodTarget) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const octPreviousYear = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 1,
},
});
const formattedData = _salaryPeriod.map((profile, index) => {
const octPreviousYear2 = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 2,
},
});
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
if (octPreviousYear) {
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
isRetired: true,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: octPreviousYear?.id,
},
},
});
}
let octPreviousYearProfile2: SalaryProfileEmployee[] = [];
if (octPreviousYear2) {
octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
isRetired: true,
salaryOrg: {
snapshot: "SNAP2",
salaryPeriodId: octPreviousYear2?.id,
rootId: rootId,
},
},
});
}
const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root;
const formattedData = _salaryPeriodTarget.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
@ -4331,19 +4518,82 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
typeOld2:
octPreviousYear2 && octPreviousYearProfile2.length > 0 ? (() => {
const _profile = octPreviousYearProfile2
.filter((profileOCT2) => profileOCT2.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
yearOld: octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()),
typeOld1:
octPreviousYear && octPreviousYearProfile.length > 0 ? (() => {
const _profile = octPreviousYearProfile
.filter((profileOCT) => profileOCT.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
typeOld:
_salaryPeriodTarget.length > 0
? (() => {
const _profile = _salaryPeriodTarget
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
.map((profile) => ({
type: profile.type,
}));
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
})()
: null, //เมษา ปีเดียวกัน
type:
profile.type === "HAFT"
? ".๕ ขั้น"
: profile.type === "FULL"
? "๑ ขั้น"
: profile.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ",
score1: null,
score2: null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
template: "emp2-09",
reportName: "emp2-09",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(-2,),
yearShortOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))).slice(-2,),
agency: agency,
data: formattedData,
},
@ -4442,6 +4692,7 @@ export class ReportController extends Controller {
},
});
}
/**
* API 11-
*
@ -4514,6 +4765,7 @@ export class ReportController extends Controller {
},
});
}
/**
* API 12-
*
@ -4548,6 +4800,7 @@ export class ReportController extends Controller {
reportName: "emp2-12",
});
}
/**
* API 13-
*
@ -4620,6 +4873,7 @@ export class ReportController extends Controller {
},
});
}
/**
* API 14-
*
@ -4723,21 +4977,24 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isRetired: true,
type: "NONE",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
@ -4761,17 +5018,18 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
template: "emp2-15",
reportName: "emp2-15",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
@ -4813,6 +5071,7 @@ export class ReportController extends Controller {
reportName: "emp2-16",
});
}
/**
* API 17- ()
*
@ -4885,6 +5144,7 @@ export class ReportController extends Controller {
},
});
}
/**
* API 18-
*
@ -4972,40 +5232,7 @@ export class ReportController extends Controller {
},
});
}
/**
* API 19-
*
* @summary 19-
*
*/
@Get("emp2-19/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_19(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
period: "OCT",
isActive: true
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const salaryOrg = await this.salaryOrgEmployeeRepository.findOne({
where: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
}
});
if (!salaryOrg) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess({
template: "emp2-19",
reportName: "emp2-19",
});
}
/**
* API 20- ()
*
@ -5119,21 +5346,23 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
type: "NONE",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
@ -5157,17 +5386,18 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
template: "emp2-21",
reportName: "emp2-21",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
@ -5315,6 +5545,7 @@ export class ReportController extends Controller {
reportName: "emp2-24",
});
}
/**
* API 25-
*

View file

@ -57,701 +57,297 @@ import {
private salaryOrgEmployeeRepository = AppDataSource.getRepository(SalaryOrgEmployee);
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
private salaryProfileEmployeeRepository = AppDataSource.getRepository(SalaryProfileEmployee);
/**
* API 03-
*
* @summary 03-
*
*/
@Get("emp2-03/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_3(@Path() rootId: string='b43e886b-008c-49d3-8df3-97a5b0f3cd2a', @Path() salaryPeriodId: string='2ec16330-ea28-4f51-8ac5-4f60295288a5') {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const fifteenPoint = await this.salaryOrgEmployeeRepository.findOne({
where:{
salaryPeriodId: salaryPeriodId,
rootId: rootId,
* API 11-
*
* @summary 11-
*
*/
@Get("emp2-11/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_11(@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.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
} ,
select:[
"fifteenPoint",
"fifteenPercent"
]
})
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
const fifteenPercentData =
fifteenPoint?.fifteenPercent == undefined || fifteenPoint?.fifteenPercent == null
? ""
: Extension.ToThaiNumber(String(fifteenPoint?.fifteenPercent));
const fifteenPointData =
fifteenPoint?.fifteenPoint == undefined || fifteenPoint?.fifteenPoint == null
? "."
: "." + Extension.ToThaiNumber(String(fifteenPoint?.fifteenPoint));
const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
type: "FULL",
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriodTarget) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const octPreviousYear = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 1,
},
});
const octPreviousYear2 = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 2,
},
});
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
if (octPreviousYear) {
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
type: "FULL",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: octPreviousYear?.id,
},
},
});
}
let octPreviousYearProfile2: SalaryProfileEmployee[] = [];
if (octPreviousYear2) {
octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
type: "FULL",
salaryOrg: {
snapshot: "SNAP2",
salaryPeriodId: octPreviousYear2?.id,
rootId: rootId,
},
},
});
}
const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root;
const formattedData = _salaryPeriodTarget.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,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
typeOld2:
octPreviousYear2 && octPreviousYearProfile2.length > 0 ? (() => {
const _profile = octPreviousYearProfile2
.filter((profileOCT2) => profileOCT2.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
yearOld: octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()),
typeOld1:
octPreviousYear && octPreviousYearProfile.length > 0 ? (() => {
const _profile = octPreviousYearProfile
.filter((profileOCT) => profileOCT.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
typeOld:
_salaryPeriodTarget.length > 0
? (() => {
const _profile = _salaryPeriodTarget
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
.map((profile) => ({
type: profile.type,
}));
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
})()
: null, //เมษา ปีเดียวกัน
type:
profile.type === "HAFT"
? ".๕ ขั้น"
: profile.type === "FULL"
? "๑ ขั้น"
: profile.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ",
score1: null,
score2: null,
};
});
return new HttpSuccess({
template: "emp2-03",
reportName: "emp2-03",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(-2,),
yearShortOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))).slice(-2,),
fifteenPercent: fifteenPercentData + fifteenPointData,
agency: agency,
data: formattedData,
},
});
}
/**
* API 04- ( ..1)
*
* @summary 04- ( ..1)
*
*/
@Get("emp2-05/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_5(@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: {
amountSpecial: Not(IsNull()),
type: Not("NONE"),
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "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,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null,
amountSpecial: profile.amountSpecial ? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: "emp2-05",
reportName: "emp2-05",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
/**
* API 07- ( ..2/1)
*
* @summary 07- ( ..2/1)
*
*/
@Get("emp2-07/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_7(@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: {
type: "NONE",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "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,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
score: null,
signature: null,
};
});
return new HttpSuccess({
template: "emp2-07",
reportName: "emp2-07",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
/**
* API 09-
*
* @summary 09-
*
*/
@Get("emp2-09/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_9(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isRetired: true,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriodTarget) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const octPreviousYear = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 1,
},
});
const octPreviousYear2 = await this.salaryPeriodRepository.findOne({
where: {
period: "OCT",
year: salaryPeriod?.year - 2,
},
});
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
if (octPreviousYear) {
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
isRetired: true,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: octPreviousYear?.id,
},
},
});
}
let octPreviousYearProfile2: SalaryProfileEmployee[] = [];
if (octPreviousYear2) {
octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg"],
where: {
isRetired: true,
salaryOrg: {
snapshot: "SNAP2",
salaryPeriodId: octPreviousYear2?.id,
rootId: rootId,
},
},
});
}
const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root;
const formattedData = _salaryPeriodTarget.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,
posNumber:
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,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
typeOld2:
octPreviousYear2 && octPreviousYearProfile2.length > 0 ? (() => {
const _profile = octPreviousYearProfile2
.filter((profileOCT2) => profileOCT2.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
yearOld: octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()),
typeOld1:
octPreviousYear && octPreviousYearProfile.length > 0 ? (() => {
const _profile = octPreviousYearProfile
.filter((profileOCT) => profileOCT.citizenId === profile.citizenId);
if (_profile.length > 0) {
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
}
return null;
})()
: null,
typeOld:
_salaryPeriodTarget.length > 0
? (() => {
const _profile = _salaryPeriodTarget
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
.map((profile) => ({
type: profile.type,
}));
return _profile[0]?.type === "HAFT"
? ".๕ ขั้น"
: _profile[0]?.type === "FULL"
? "๑ ขั้น"
: profile?.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ";
})()
: null, //เมษา ปีเดียวกัน
type:
profile.type === "HAFT"
? ".๕ ขั้น"
: profile.type === "FULL"
? "๑ ขั้น"
: profile.type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ",
score1: null,
score2: null,
reason: null,
};
});
return new HttpSuccess({
template: "emp2-09",
reportName: "emp2-09",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(-2,),
yearShortOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))).slice(-2,),
agency: agency,
data: formattedData,
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
/**
* API 13-
*
* @summary 13-
*
*/
@Get("emp2-13/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_13(@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.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
});
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
/**
* API 15-
*
* @summary 15-
*
*/
@Get("emp2-15/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_15(@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: {
isRetired: true,
type: "NONE",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "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,
posNumber:
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,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: "emp2-15",
reportName: "emp2-15",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
/**
* API 17- ()
*
* @summary 17- ()
*
*/
@Get("emp2-17/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_17(@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.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
});
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
/**
* API 21-
*
* @summary 21-
*
*/
@Get("emp2-21/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_21(@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: {
type: "NONE",
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
orgShortName: "ASC",
posMasterNo: "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,
posNumber:
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,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
return new HttpSuccess({
template: "emp2-21",
reportName: "emp2-21",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
/**
* API 25-
*
* @summary 25-
*
*/
@Get("emp2-25/{rootId}/{salaryPeriodId}")
async SalaryReportEmp2_25(@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.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
});
},
order: {
orgShortName: "ASC",
posMasterNo: "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,
posLevel: profile.posLevel,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
};
});
return new HttpSuccess({
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
}