fitered group salary report

This commit is contained in:
AdisakKanthawilang 2024-07-05 11:25:35 +07:00
parent 9ca08b4640
commit 93940017f9
2 changed files with 97 additions and 55 deletions

View file

@ -216,8 +216,12 @@ export class ReportController extends Controller {
* @summary 1 () 1 ()
*
*/
@Get("gov-01/{rootId}/{salaryPeriodId}")
async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-01/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport1(
@Path() rootId: string,
@Path() salaryPeriodId: string,
@Path() group: string,
) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -226,12 +230,14 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP1",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
},
@ -363,16 +369,17 @@ export class ReportController extends Controller {
profile.child2,
profile.child1,
profile.root,
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
];
const fullName = fullNameParts
const affiliation = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
const fullName = `${profile.prefix}${profile.firstName} ${profile.lastName}`;
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
affiliation: affiliation,
posLevel: profile.posLevel,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
@ -1255,17 +1262,14 @@ export class ReportController extends Controller {
profile: salaryProfileGroup1
? salaryProfileGroup1.map((item: any, index: any) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname:
affiliation:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
(item.root == undefined && item.root == null ? "" : item.root) +
"/" +
item.prefix +
item.firstName +
" " +
item.lastName, // สังกัด/ชื่อ-นามสกุล
(item.root == undefined && item.root == null ? "" : item.root),
// สังกัด
fullName: item.prefix + item.firstName + " " + item.lastName,
posLevel: item.posLevel,
posMasterNo:
Extension.ToThaiNumber(item.orgShortName) +
@ -1309,17 +1313,14 @@ export class ReportController extends Controller {
profileGroup2: salaryProfileGroup2
? salaryProfileGroup2.map((item: any, index: any) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname:
affiliation:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
(item.root == undefined && item.root == null ? "" : item.root) +
"/" +
item.prefix +
item.firstName +
" " +
item.lastName, // สังกัด/ชื่อ-นามสกุล
(item.root == undefined && item.root == null ? "" : item.root),
// สังกัด/ชื่อ-นามสกุล
fullName: item.prefix + item.firstName + " " + item.lastName,
posLevel: item.posLevel,
posMasterNo:
Extension.ToThaiNumber(item.orgShortName) +
@ -1741,8 +1742,12 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-04/{rootId}/{salaryPeriodId}")
async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-04/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport4(
@Path() rootId: string,
@Path() salaryPeriodId: string,
@Path() group: string,
) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -1752,13 +1757,14 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
type: In(["HAFT", "FULL", "FULLHAFT"]),
@ -1789,9 +1795,16 @@ export class ReportController extends Controller {
log_group: profile.salaryOrg.group,
log_type: profile.type,
log_isNext: profile.isNext,
position:
profile.position +
"/" +
// position:
// profile.position +
// "/" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "/") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "/") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + "/") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + "/") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
position: profile.position,
affiliation:
(profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "/") +
(profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "/") +
(profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + "/") +
@ -1845,8 +1858,8 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-04-01/{rootId}/{salaryPeriodId}")
async SalaryReport4Retire(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-04-01/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport4Retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -1856,13 +1869,14 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
type: In(["HAFT", "FULL", "FULLHAFT"]),
@ -1880,6 +1894,7 @@ export class ReportController extends Controller {
const _root = await this.salaryOrgRepository.findOne({
where: {
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
});
@ -1893,9 +1908,8 @@ export class ReportController extends Controller {
log_group: profile.salaryOrg.group,
log_type: profile.type,
log_isNext: profile.isNext,
position:
profile.position +
"/" +
position: profile.position,
affiliation:
(profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "/") +
(profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "/") +
(profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + "/") +
@ -1949,8 +1963,12 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-05/{rootId}/{salaryPeriodId}")
async SalaryReport5(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-05/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport5(
@Path() rootId: string,
@Path() salaryPeriodId: string,
@Path() group: string,
) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -1960,13 +1978,14 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
type: "NONE", //ไม่ได้เลื่อน
@ -1983,6 +2002,7 @@ export class ReportController extends Controller {
const _root = await this.salaryOrgRepository.findOne({
where: {
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
});
@ -1991,7 +2011,6 @@ export class ReportController extends Controller {
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.position,
profile.child4,
profile.child3,
profile.child2,
@ -1999,14 +2018,15 @@ export class ReportController extends Controller {
profile.root,
];
const position = fullNameParts
const affiliation = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
const position = profile.position;
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullname: profile.prefix + profile.firstName + " " + profile.lastName,
position: position,
affiliation: affiliation,
posLevel: profile.posLevel,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
@ -2037,8 +2057,8 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-05-01/{rootId}/{salaryPeriodId}")
async SalaryReport5retire(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-05-01/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport5retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -2049,12 +2069,14 @@ export class ReportController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
type: "NONE", //ไม่ได้เลื่อน
@ -2071,6 +2093,7 @@ export class ReportController extends Controller {
const _root = await this.salaryOrgRepository.findOne({
where: {
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
});
@ -2079,7 +2102,6 @@ export class ReportController extends Controller {
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.position,
profile.child4,
profile.child3,
profile.child2,
@ -2087,14 +2109,15 @@ export class ReportController extends Controller {
profile.root,
];
const position = fullNameParts
const affiliation = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
const position = profile.position;
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullname: profile.prefix + profile.firstName + " " + profile.lastName,
position: position,
affiliation: affiliation,
posLevel: profile.posLevel,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
@ -2137,8 +2160,12 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-07/{rootId}/{salaryPeriodId}")
async SalaryReport7(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-07/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport7(
@Path() rootId: string,
@Path() salaryPeriodId: string,
@Path() group: string,
) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -2150,11 +2177,13 @@ export class ReportController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const salaryProfile = await this.salaryProfileRepository.find({
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
salaryPeriod: {
period: salaryPeriod.period === "APR" ? "APR" : "OCT",
@ -2170,6 +2199,7 @@ export class ReportController extends Controller {
const _root = await this.salaryOrgRepository.findOne({
where: {
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
});
@ -2179,9 +2209,8 @@ export class ReportController extends Controller {
const formattedData = salaryProfile.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
position:
item.position +
"/" +
position: item.position,
affiliation:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
@ -2238,8 +2267,8 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-07-01/{rootId}/{salaryPeriodId}")
async SalaryReport7retire(@Path() rootId: string, @Path() salaryPeriodId: string) {
@Get("gov-07-01/{rootId}/{salaryPeriodId}/{group}")
async SalaryReport7retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
@ -2251,12 +2280,13 @@ export class ReportController extends Controller {
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
const salaryProfile = await this.salaryProfileRepository.find({
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
salaryPeriod: {
period: salaryPeriod.period,
@ -2273,6 +2303,7 @@ export class ReportController extends Controller {
const _root = await this.salaryOrgRepository.findOne({
where: {
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
});
@ -2281,9 +2312,8 @@ export class ReportController extends Controller {
const formattedData = salaryProfile.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
position:
item.position +
"/" +
position: item.position,
affiliation:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
@ -2429,6 +2459,12 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
position: item.position,
affiliation:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
(item.root == undefined && item.root == null ? "" : item.root),
posType: item.posType,
posLevel: item.posLevel,
posMasterNo:
@ -2449,6 +2485,12 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
position: item.position,
affiliation:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
(item.root == undefined && item.root == null ? "" : item.root),
posType: item.posType,
posLevel: item.posLevel,
posMasterNo: