รวม report
This commit is contained in:
parent
9bfa2dd8c5
commit
377e8a46de
2 changed files with 192 additions and 546 deletions
|
|
@ -4733,21 +4733,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: Not("NONE"),
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
rootId: rootId,
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
},
|
||||
},
|
||||
order: {
|
||||
orgShortName: "ASC",
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!_salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -4771,17 +4773,14 @@ 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,
|
||||
reason: null,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess({
|
||||
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
|
||||
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
|
||||
template: "emp2-11",
|
||||
reportName: "emp2-11",
|
||||
data: {
|
||||
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
||||
agency: agency,
|
||||
|
|
@ -4841,28 +4840,31 @@ 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",
|
||||
},
|
||||
});
|
||||
|
||||
if (!_salaryPeriod) {
|
||||
const salaryProfile = await this.salaryProfileEmployeeRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
isRetired: true,
|
||||
isNext: true,
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
rootId: rootId,
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
},
|
||||
},
|
||||
order: {
|
||||
orgShortName: "ASC",
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryProfile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
||||
const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root;
|
||||
|
||||
const formattedData = _salaryPeriod.map((profile, index) => {
|
||||
const formattedData = salaryProfile.map((profile, index) => {
|
||||
const fullNameParts = [
|
||||
profile.child4,
|
||||
profile.child3,
|
||||
|
|
@ -4879,17 +4881,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()),
|
||||
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
||||
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
||||
positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.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-13",
|
||||
reportName: "emp2-13",
|
||||
data: {
|
||||
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
||||
agency: agency,
|
||||
|
|
@ -5112,28 +5116,30 @@ 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",
|
||||
},
|
||||
});
|
||||
|
||||
if (!_salaryPeriod) {
|
||||
const salaryProfile = await this.salaryProfileEmployeeRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
isNext: true,
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
rootId: rootId,
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
},
|
||||
},
|
||||
order: {
|
||||
orgShortName: "ASC",
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryProfile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
||||
const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root;
|
||||
|
||||
const formattedData = _salaryPeriod.map((profile, index) => {
|
||||
const formattedData = salaryProfile.map((profile, index) => {
|
||||
const fullNameParts = [
|
||||
profile.child4,
|
||||
profile.child3,
|
||||
|
|
@ -5150,17 +5156,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()),
|
||||
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
||||
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
||||
positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.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-17",
|
||||
reportName: "emp2-17",
|
||||
data: {
|
||||
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
||||
agency: agency,
|
||||
|
|
@ -5578,20 +5586,90 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("emp2-25/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReportEmp2_25(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
//งวดปีปัจจุบัน
|
||||
const salaryPeriodOCT = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
},
|
||||
});
|
||||
if (!salaryPeriod) {
|
||||
if (!salaryPeriodOCT) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const _salaryPeriod = await this.salaryProfileRepository.find({
|
||||
|
||||
const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
period: "APR",
|
||||
year: salaryPeriodOCT.year,
|
||||
},
|
||||
});
|
||||
if (!salaryPeriodAPR) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
//งวดปีก่อนหน้า
|
||||
const perviousYearAPR = await this.salaryPeriodRepository.findOne({
|
||||
where:{
|
||||
period: "APR",
|
||||
year: salaryPeriodOCT.year-1,
|
||||
},
|
||||
});
|
||||
if (!perviousYearAPR) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า");
|
||||
}
|
||||
|
||||
const perviousYearOCT = await this.salaryPeriodRepository.findOne({
|
||||
where:{
|
||||
period: "OCT",
|
||||
year: salaryPeriodOCT.year-1,
|
||||
},
|
||||
});
|
||||
if (!perviousYearOCT) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า");
|
||||
}
|
||||
|
||||
//ปีก่อนหน้า
|
||||
const salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
salaryPeriodId: perviousYearAPR.id,
|
||||
},
|
||||
},
|
||||
order: {
|
||||
orgShortName: "ASC",
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryProfilePerviousAPR) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
salaryPeriodId: perviousYearOCT.id,
|
||||
},
|
||||
},
|
||||
order: {
|
||||
orgShortName: "ASC",
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryProfilePerviousOCT) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
//ปีปัจุบัน
|
||||
const salaryProfileCurrentAPR = await this.salaryProfileEmployeeRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP1",
|
||||
rootId: rootId,
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
},
|
||||
},
|
||||
|
|
@ -5601,13 +5679,46 @@ export class ReportController extends Controller {
|
|||
},
|
||||
});
|
||||
|
||||
if (!_salaryPeriod) {
|
||||
if (!salaryProfileCurrentAPR) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
||||
const salaryProfileCurrentOCT = await this.salaryProfileEmployeeRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg: {
|
||||
snapshot: "SNAP2",
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
},
|
||||
},
|
||||
order: {
|
||||
orgShortName: "ASC",
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryProfileCurrentOCT) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const agency = salaryProfileCurrentOCT[0] == null ? "" : salaryProfileCurrentOCT[0].root;
|
||||
|
||||
const formattedData = salaryProfileCurrentOCT.map((profile, index) => {
|
||||
//งวดปีก่อนหน้า
|
||||
const matchedAPRProfileOld = salaryProfilePerviousAPR.find(aprProfile_old => aprProfile_old.citizenId === profile.citizenId);
|
||||
const matchedOCTProfileOld = salaryProfilePerviousOCT.find(octProfile_old => octProfile_old.citizenId === profile.citizenId);
|
||||
const amountUseAPR_Old = matchedAPRProfileOld ? matchedAPRProfileOld.amountUse : 0;
|
||||
const amountUseOCT_Old = matchedOCTProfileOld ? matchedOCTProfileOld.amountUse : 0;
|
||||
const amountUseOld = amountUseAPR_Old + amountUseOCT_Old;
|
||||
|
||||
//งวดปีปัจจุบัน
|
||||
const matchedAPRProfile = salaryProfileCurrentAPR.find(aprProfile => aprProfile.citizenId === profile.citizenId);
|
||||
const matchedOCTProfile = salaryProfileCurrentOCT.find(octProfile => octProfile.citizenId === profile.citizenId);
|
||||
const amountUseAPR = matchedAPRProfile ? matchedAPRProfile.amountUse : 0;
|
||||
const amountUseOCT = matchedOCTProfile ? matchedOCTProfile.amountUse : 0;
|
||||
const amountUse = amountUseAPR + amountUseOCT;
|
||||
|
||||
|
||||
const formattedData = _salaryPeriod.map((profile, index) => {
|
||||
const fullNameParts = [
|
||||
profile.child4,
|
||||
profile.child3,
|
||||
|
|
@ -5624,22 +5735,26 @@ 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,
|
||||
positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null,
|
||||
amountUseOld: amountUseOld ? Extension.ToThaiNumber(amountUseOld.toLocaleString()) : null,
|
||||
amountUse: amountUse ? Extension.ToThaiNumber(amountUse.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-25",
|
||||
reportName: "emp2-25",
|
||||
data: {
|
||||
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
||||
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriodOCT.year))),
|
||||
agency: agency,
|
||||
data: formattedData,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue