emp2(11,13,17)
This commit is contained in:
parent
fbe018c211
commit
1730d19632
1 changed files with 179 additions and 79 deletions
|
|
@ -74,21 +74,23 @@ import {
|
|||
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, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -112,17 +114,14 @@ import {
|
|||
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,
|
||||
|
|
@ -147,28 +146,31 @@ import {
|
|||
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,
|
||||
|
|
@ -185,17 +187,19 @@ import {
|
|||
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,
|
||||
|
|
@ -220,28 +224,30 @@ import {
|
|||
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,
|
||||
|
|
@ -258,17 +264,19 @@ import {
|
|||
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,
|
||||
|
|
@ -283,22 +291,92 @@ import {
|
|||
* @summary 25-แบบฟอร์มบัญชีถือจ่ายอัตราค่าจ้างลูกจ้างประจำกรุงเทพมหานคร
|
||||
*
|
||||
*/
|
||||
@Get("emp2-25/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReportEmp2_25(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
@Get("emp2-25/{salaryPeriodId}")
|
||||
async SalaryReportEmp2_25(@Path() salaryPeriodId: string) {
|
||||
//งวดปีปัจจุบัน
|
||||
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,
|
||||
},
|
||||
},
|
||||
|
|
@ -308,13 +386,31 @@ import {
|
|||
},
|
||||
});
|
||||
|
||||
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 = _salaryPeriod.map((profile, index) => {
|
||||
const formattedData = salaryProfileCurrentOCT.map((profile, index) => {
|
||||
const fullNameParts = [
|
||||
profile.child4,
|
||||
profile.child3,
|
||||
|
|
@ -331,23 +427,27 @@ import {
|
|||
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: null,
|
||||
amountUse: 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