แก้report gov01
This commit is contained in:
parent
7fb7b467a2
commit
d5f40373a8
1 changed files with 72 additions and 35 deletions
|
|
@ -214,6 +214,14 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("gov1-01/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
},
|
||||
});
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryPeriodAPR = await this.salaryProfileRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
|
|
@ -236,7 +244,7 @@ export class ReportController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const agency = salaryPeriodAPR[0]?.root;
|
||||
const agency = salaryPeriodAPR[0] == null ? "" : salaryPeriodAPR[0].root;
|
||||
|
||||
const formattedData = salaryPeriodAPR.map((profile, index) => {
|
||||
const fullNameParts = [
|
||||
|
|
@ -265,7 +273,17 @@ export class ReportController extends Controller {
|
|||
};
|
||||
});
|
||||
|
||||
return { agency: agency, data: formattedData };
|
||||
return new HttpSuccess({
|
||||
template: "gov1-01",
|
||||
reportName: "gov1-01",
|
||||
data: {
|
||||
date: Extension.ToThaiNumber(
|
||||
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
|
||||
),
|
||||
agency: agency,
|
||||
data: formattedData,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,43 +293,62 @@ export class ReportController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("gov1-02/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport2(
|
||||
@Path() rootId: string,
|
||||
@Path() salaryPeriodId: string,
|
||||
// @Path() salaryOrgId: string,
|
||||
) {
|
||||
const statistics = await this.salaryProfileRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
async SalaryReport2(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
salaryOrg: {
|
||||
// id: salaryOrgId,
|
||||
snapshot: "SNAP1",
|
||||
group: "GROUP2",
|
||||
rootId: rootId,
|
||||
salaryPeriod: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
},
|
||||
},
|
||||
id: salaryPeriodId,
|
||||
},
|
||||
});
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryPeriodAPR = await this.salaryOrgRepository.find({
|
||||
relations: ["salaryPeriod", "salaryProfiles"],
|
||||
where: {
|
||||
snapshot: "SNAP1",
|
||||
rootId: rootId,
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
salaryPeriod: {
|
||||
period: "APR",
|
||||
},
|
||||
},
|
||||
order: { group: "ASC" },
|
||||
});
|
||||
const agency =
|
||||
salaryPeriodAPR[0] == null || salaryPeriodAPR[0].salaryProfiles[0] == null
|
||||
? ""
|
||||
: salaryPeriodAPR[0].salaryProfiles[0].root;
|
||||
|
||||
const notPromoSum =
|
||||
(statistics[0]?.salaryOrg?.total ?? 0) - (statistics[0]?.salaryOrg?.fifteenPercent ?? 0);
|
||||
const haftCount = statistics?.filter((item) => item.type === "HAFT").length ?? 0;
|
||||
const data = {
|
||||
group: statistics[0]?.salaryOrg.total ? "กลุ่ม 2" : "",
|
||||
total: statistics[0]?.salaryOrg.total ? statistics[0]?.salaryOrg.total : "",
|
||||
fifteenPercent: statistics[0]?.salaryOrg.fifteenPercent
|
||||
? statistics[0]?.salaryOrg.fifteenPercent
|
||||
: "",
|
||||
full: statistics[0]?.salaryOrg.quantityUsed ? statistics[0]?.salaryOrg.quantityUsed : "",
|
||||
remaining: statistics[0]?.salaryOrg.remainQuota ? statistics[0]?.salaryOrg.remainQuota : "",
|
||||
haft: haftCount,
|
||||
notPromoted: notPromoSum,
|
||||
reason: null,
|
||||
};
|
||||
return data;
|
||||
const formattedData = salaryPeriodAPR.map((org, index) => {
|
||||
return {
|
||||
group: `กลุ่มที่ ${Extension.ToThaiNumber(org.group == "GROUP1" ? "1" : "2")}`,
|
||||
total: Extension.ToThaiNumber(org.total.toString()),
|
||||
fifteenPercent: Extension.ToThaiNumber(org.fifteenPercent.toString()),
|
||||
full: Extension.ToThaiNumber(
|
||||
org.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
|
||||
),
|
||||
haft: Extension.ToThaiNumber(
|
||||
org.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
|
||||
),
|
||||
notPromoted: Extension.ToThaiNumber(
|
||||
org.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
|
||||
),
|
||||
reason: null,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "gov1-02",
|
||||
reportName: "gov1-02",
|
||||
data: {
|
||||
date: Extension.ToThaiNumber(
|
||||
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
|
||||
),
|
||||
dateNow: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date())),
|
||||
agency: agency,
|
||||
data: formattedData,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue