2024-03-28 18:15:40 +07:00
|
|
|
|
import {
|
|
|
|
|
|
Controller,
|
|
|
|
|
|
Get,
|
|
|
|
|
|
Post,
|
|
|
|
|
|
Put,
|
|
|
|
|
|
Delete,
|
|
|
|
|
|
Patch,
|
|
|
|
|
|
Route,
|
|
|
|
|
|
Security,
|
|
|
|
|
|
Tags,
|
|
|
|
|
|
Body,
|
|
|
|
|
|
Path,
|
|
|
|
|
|
Request,
|
|
|
|
|
|
Example,
|
|
|
|
|
|
SuccessResponse,
|
|
|
|
|
|
Response,
|
|
|
|
|
|
Query,
|
|
|
|
|
|
} from "tsoa";
|
|
|
|
|
|
import { AppDataSource } from "../database/data-source";
|
|
|
|
|
|
import HttpSuccess from "../interfaces/http-success";
|
|
|
|
|
|
import HttpStatusCode from "../interfaces/http-status";
|
|
|
|
|
|
import HttpError from "../interfaces/http-error";
|
|
|
|
|
|
import { In, Not, IsNull, MoreThan } from "typeorm";
|
|
|
|
|
|
import { Salarys } from "../entities/Salarys";
|
|
|
|
|
|
import { SalaryRanks } from "../entities/SalaryRanks";
|
|
|
|
|
|
import { PosType } from "../entities/PosType";
|
|
|
|
|
|
import { PosLevel } from "../entities/PosLevel";
|
|
|
|
|
|
import { SalaryPeriod } from "../entities/SalaryPeriod";
|
|
|
|
|
|
import { SalaryOrg } from "../entities/SalaryOrg";
|
|
|
|
|
|
import { SalaryProfile } from "../entities/SalaryProfile";
|
|
|
|
|
|
import Extension from "../interfaces/extension";
|
|
|
|
|
|
import { SalaryEmployee } from "../entities/SalaryEmployee";
|
|
|
|
|
|
import { SalaryRankEmployee } from "../entities/SalaryRankEmployee";
|
|
|
|
|
|
import { EmployeePosType } from "../entities/EmployeePosType";
|
|
|
|
|
|
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
|
|
|
|
|
import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee";
|
|
|
|
|
|
import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee";
|
|
|
|
|
|
@Route("api/v1/salary/report/tum")
|
|
|
|
|
|
@Tags("Tum")
|
|
|
|
|
|
@Security("bearerAuth")
|
|
|
|
|
|
@Response(
|
|
|
|
|
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
|
|
|
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
|
|
|
|
)
|
|
|
|
|
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
|
|
|
|
export class TumReportController extends Controller {
|
|
|
|
|
|
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
|
|
|
|
|
private salaryRepository = AppDataSource.getRepository(Salarys);
|
|
|
|
|
|
private salaryEmployeeRepository = AppDataSource.getRepository(SalaryEmployee);
|
|
|
|
|
|
private salaryRankRepository = AppDataSource.getRepository(SalaryRanks);
|
|
|
|
|
|
private salaryEmployeeRankRepository = AppDataSource.getRepository(SalaryRankEmployee);
|
|
|
|
|
|
private poTypeRepository = AppDataSource.getRepository(PosType);
|
|
|
|
|
|
private poTypeEmployeeRepository = AppDataSource.getRepository(EmployeePosType);
|
|
|
|
|
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
|
|
|
|
|
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
|
|
|
|
|
private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg);
|
|
|
|
|
|
private salaryOrgEmployeeRepository = AppDataSource.getRepository(SalaryOrgEmployee);
|
|
|
|
|
|
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
|
|
|
|
|
|
private salaryProfileEmployeeRepository = AppDataSource.getRepository(SalaryProfileEmployee);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 03-รายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ได้รับการเสนอขอเลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้น
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 03-รายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ได้รับการเสนอขอเลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้น
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-03/{rootId}/{salaryPeriodId}")
|
2024-03-29 11:12:45 +07:00
|
|
|
|
async SalaryReportEmp2_3(@Path() rootId: string='b43e886b-008c-49d3-8df3-97a5b0f3cd2a', @Path() salaryPeriodId: string='2ec16330-ea28-4f51-8ac5-4f60295288a5') {
|
2024-03-28 18:15:40 +07:00
|
|
|
|
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,
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
} ,
|
|
|
|
|
|
select:[
|
|
|
|
|
|
"fifteenPoint",
|
|
|
|
|
|
"fifteenPercent"
|
|
|
|
|
|
]
|
|
|
|
|
|
})
|
2024-03-29 11:12:45 +07:00
|
|
|
|
|
2024-03-28 18:15:40 +07:00
|
|
|
|
const fifteenPercentData =
|
|
|
|
|
|
fifteenPoint?.fifteenPercent == undefined || fifteenPoint?.fifteenPercent == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(fifteenPoint?.fifteenPercent));
|
2024-03-29 11:12:45 +07:00
|
|
|
|
|
2024-03-28 18:15:40 +07:00
|
|
|
|
const fifteenPointData =
|
|
|
|
|
|
fifteenPoint?.fifteenPoint == undefined || fifteenPoint?.fifteenPoint == null
|
|
|
|
|
|
? ".๐๐"
|
|
|
|
|
|
: "." + Extension.ToThaiNumber(String(fifteenPoint?.fifteenPoint));
|
2024-03-29 11:12:45 +07:00
|
|
|
|
|
2024-03-28 18:15:40 +07:00
|
|
|
|
const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({
|
2024-03-29 11:12:45 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
2024-03-28 18:15:40 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
type: "FULL",
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-29 11:12:45 +07:00
|
|
|
|
|
2024-03-28 18:15:40 +07:00
|
|
|
|
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,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-29 11:12:45 +07:00
|
|
|
|
|
2024-03-28 18:15:40 +07:00
|
|
|
|
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;
|
2024-03-29 11:12:45 +07:00
|
|
|
|
|
2024-03-28 18:15:40 +07:00
|
|
|
|
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,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 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:
|
|
|
|
|
|
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,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 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:
|
|
|
|
|
|
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,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 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:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "emp2-21",
|
|
|
|
|
|
reportName: "emp2-21",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|