2024-02-19 15:23:03 +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";
|
2024-03-18 13:07:09 +07:00
|
|
|
|
import { In, Not, IsNull, MoreThan } from "typeorm";
|
2024-02-19 15:23:03 +07:00
|
|
|
|
import { Salarys } from "../entities/Salarys";
|
|
|
|
|
|
import { SalaryRanks } from "../entities/SalaryRanks";
|
|
|
|
|
|
import { PosType } from "../entities/PosType";
|
|
|
|
|
|
import { PosLevel } from "../entities/PosLevel";
|
2024-03-18 13:07:09 +07:00
|
|
|
|
import { SalaryPeriod } from "../entities/SalaryPeriod";
|
|
|
|
|
|
import { SalaryOrg } from "../entities/SalaryOrg";
|
|
|
|
|
|
import { SalaryProfile } from "../entities/SalaryProfile";
|
2024-03-18 17:30:54 +07:00
|
|
|
|
import Extension from "../interfaces/extension";
|
|
|
|
|
|
import { SalaryEmployee } from "../entities/SalaryEmployee";
|
|
|
|
|
|
import { SalaryRankEmployee } from "../entities/SalaryRankEmployee";
|
2024-03-21 15:29:39 +07:00
|
|
|
|
import { EmployeePosType } from "../entities/EmployeePosType";
|
|
|
|
|
|
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
|
|
|
|
|
import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee";
|
|
|
|
|
|
import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee";
|
2024-02-19 15:23:03 +07:00
|
|
|
|
@Route("api/v1/salary/report")
|
|
|
|
|
|
@Tags("Report")
|
|
|
|
|
|
@Security("bearerAuth")
|
|
|
|
|
|
@Response(
|
|
|
|
|
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
|
|
|
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
|
|
|
|
)
|
|
|
|
|
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
|
|
|
|
export class ReportController extends Controller {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
2024-02-19 15:23:03 +07:00
|
|
|
|
private salaryRepository = AppDataSource.getRepository(Salarys);
|
2024-03-18 17:30:54 +07:00
|
|
|
|
private salaryEmployeeRepository = AppDataSource.getRepository(SalaryEmployee);
|
2024-02-19 15:23:03 +07:00
|
|
|
|
private salaryRankRepository = AppDataSource.getRepository(SalaryRanks);
|
2024-03-18 17:30:54 +07:00
|
|
|
|
private salaryEmployeeRankRepository = AppDataSource.getRepository(SalaryRankEmployee);
|
2024-02-19 15:23:03 +07:00
|
|
|
|
private poTypeRepository = AppDataSource.getRepository(PosType);
|
2024-03-21 15:29:39 +07:00
|
|
|
|
private poTypeEmployeeRepository = AppDataSource.getRepository(EmployeePosType);
|
2024-02-19 15:23:03 +07:00
|
|
|
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
2024-03-21 15:29:39 +07:00
|
|
|
|
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
2024-03-18 13:07:09 +07:00
|
|
|
|
private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg);
|
2024-03-21 15:29:39 +07:00
|
|
|
|
private salaryOrgEmployeeRepository = AppDataSource.getRepository(SalaryOrgEmployee);
|
2024-03-18 13:07:09 +07:00
|
|
|
|
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
|
2024-03-21 15:29:39 +07:00
|
|
|
|
private salaryProfileEmployeeRepository = AppDataSource.getRepository(SalaryProfileEmployee);
|
2024-02-19 15:23:03 +07:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-03-18 13:50:24 +07:00
|
|
|
|
* API รายงานอัตราเงินเดือน
|
2024-02-19 15:23:03 +07:00
|
|
|
|
*
|
2024-03-18 13:50:24 +07:00
|
|
|
|
* @summary รายงานอัตราเงินเดือน
|
2024-02-19 15:23:03 +07:00
|
|
|
|
*
|
|
|
|
|
|
* @param {string} id Guid, *Id ผังเงินเดือน
|
|
|
|
|
|
*/
|
2024-03-18 13:50:24 +07:00
|
|
|
|
@Get("{id}")
|
2024-02-19 15:23:03 +07:00
|
|
|
|
async SalaryReport(@Path() id: string) {
|
|
|
|
|
|
const salarys = await this.salaryRepository.findOne({
|
2024-03-18 17:30:54 +07:00
|
|
|
|
where: { id: id },
|
2024-02-19 15:23:03 +07:00
|
|
|
|
});
|
|
|
|
|
|
if (!salarys) {
|
2024-02-28 13:35:08 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผังเงินเดือนนี้");
|
2024-02-19 15:23:03 +07:00
|
|
|
|
}
|
|
|
|
|
|
const posType = await this.poTypeRepository.findOne({
|
|
|
|
|
|
where: { id: salarys.posTypeId },
|
|
|
|
|
|
});
|
|
|
|
|
|
const posLevel = await this.posLevelRepository.findOne({
|
|
|
|
|
|
where: { id: salarys.posLevelId },
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryRank = await this.salaryRankRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryId: salarys.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
select: [
|
|
|
|
|
|
"id",
|
|
|
|
|
|
"salary",
|
|
|
|
|
|
"salaryHalf",
|
|
|
|
|
|
"salaryHalfSpecial",
|
|
|
|
|
|
"salaryFull",
|
|
|
|
|
|
"salaryFullSpecial",
|
|
|
|
|
|
"salaryFullHalf",
|
|
|
|
|
|
"salaryFullHalfSpecial",
|
|
|
|
|
|
],
|
|
|
|
|
|
order: {
|
|
|
|
|
|
salary: "DESC",
|
|
|
|
|
|
salaryHalf: "DESC",
|
2024-03-18 17:30:54 +07:00
|
|
|
|
},
|
2024-02-19 15:23:03 +07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const mapSalaryRank = salaryRank.map((item, index) => ({
|
|
|
|
|
|
// no: index + 1,
|
|
|
|
|
|
// id: item.id,
|
2024-03-18 17:30:54 +07:00
|
|
|
|
salary: item.salary == null || item.salary == 0 ? "" : item.salary.toLocaleString(),
|
|
|
|
|
|
salaryHalf:
|
|
|
|
|
|
item.salaryHalf == null || item.salaryHalf == 0
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: item.salaryHalf.toLocaleString() +
|
|
|
|
|
|
(item.salaryHalfSpecial == null || item.salaryHalfSpecial == 0
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: " (" + item.salaryHalfSpecial.toLocaleString() + "*)"),
|
|
|
|
|
|
salaryFull:
|
|
|
|
|
|
item.salaryFull == null || item.salaryFull == 0
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: item.salaryFull.toLocaleString() +
|
|
|
|
|
|
(item.salaryFullSpecial == null || item.salaryFullSpecial == 0
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: " (" + item.salaryFullSpecial.toLocaleString() + "*)"),
|
|
|
|
|
|
salaryFullHalf:
|
|
|
|
|
|
item.salaryFullHalf == null || item.salaryFullHalf == 0
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: item.salaryFullHalf.toLocaleString() +
|
|
|
|
|
|
(item.salaryFullHalfSpecial == null || item.salaryFullHalfSpecial == 0
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: " (" + item.salaryFullHalfSpecial.toLocaleString() + "*)"),
|
2024-02-19 15:23:03 +07:00
|
|
|
|
}));
|
|
|
|
|
|
|
2024-03-18 17:30:54 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "SalaryRank",
|
|
|
|
|
|
reportName: "SalaryRank",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
nameType:
|
|
|
|
|
|
salarys.name == "OFFICER"
|
|
|
|
|
|
? "ผังข้าราชการกรุงเทพมหานครสามัญ"
|
|
|
|
|
|
: salarys.name == "EMPLOYEE"
|
|
|
|
|
|
? "ผังลูกจ้างประจำกรุงเทพมหานคร"
|
|
|
|
|
|
: "",
|
2024-02-19 15:31:07 +07:00
|
|
|
|
level: posLevel?.posLevelName == null ? "" : posLevel?.posLevelName,
|
|
|
|
|
|
type: posType?.posTypeName == null ? "" : posType?.posTypeName,
|
2024-03-18 17:30:54 +07:00
|
|
|
|
date:
|
|
|
|
|
|
salarys.date == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: salarys.date.getDate() +
|
|
|
|
|
|
" " +
|
|
|
|
|
|
Extension.ToThaiMonth(salarys.date.getMonth() + 1) +
|
|
|
|
|
|
" " +
|
|
|
|
|
|
Extension.ToThaiYear(salarys.date.getFullYear()),
|
|
|
|
|
|
startDate:
|
|
|
|
|
|
salarys.startDate == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: salarys.startDate.getDate() +
|
|
|
|
|
|
" " +
|
|
|
|
|
|
Extension.ToThaiMonth(salarys.startDate.getMonth() + 1) +
|
|
|
|
|
|
" " +
|
|
|
|
|
|
Extension.ToThaiYear(salarys.startDate.getFullYear()),
|
|
|
|
|
|
endDate:
|
|
|
|
|
|
salarys.endDate == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: salarys.endDate.getDate() +
|
|
|
|
|
|
" " +
|
|
|
|
|
|
Extension.ToThaiMonth(salarys.endDate.getMonth() + 1) +
|
|
|
|
|
|
" " +
|
|
|
|
|
|
Extension.ToThaiYear(salarys.endDate.getFullYear()),
|
2024-02-19 15:31:07 +07:00
|
|
|
|
details: salarys.details == null ? "" : salarys.details,
|
2024-03-18 17:30:54 +07:00
|
|
|
|
salaryRanks: mapSalaryRank,
|
|
|
|
|
|
},
|
2024-02-19 15:31:07 +07:00
|
|
|
|
});
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}
|
2024-03-18 17:30:54 +07:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API รายงานอัตราเงินเดือนลูกจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary รายงานอัตราเงินเดือนลูกจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param {string} id Guid, *Id ผังเงินเดือนลูกจ้าง
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("employee/{id}")
|
|
|
|
|
|
async SalaryEmployeeReport(@Path() id: string) {
|
|
|
|
|
|
const salarys = await this.salaryEmployeeRepository.findOne({
|
|
|
|
|
|
where: { id: id },
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salarys) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผังเงินเดือนนี้");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const salaryRank = await this.salaryEmployeeRankRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryEmployeeId: salarys.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
select: ["id", "step", "salaryMonth", "salaryDay"],
|
|
|
|
|
|
order: {
|
|
|
|
|
|
step: "ASC",
|
|
|
|
|
|
salaryMonth: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const mapSalaryRank = salaryRank.map((item, index) => ({
|
|
|
|
|
|
step: item.step == null || item.step == 0 ? "" : item.step.toLocaleString(),
|
|
|
|
|
|
salaryMonth:
|
|
|
|
|
|
item.salaryMonth == null || item.salaryMonth == 0 ? "" : item.salaryMonth.toLocaleString(),
|
|
|
|
|
|
salaryDay:
|
|
|
|
|
|
item.salaryDay == null || item.salaryDay == 0 ? "" : item.salaryDay.toLocaleString(),
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "SalaryRankEmployee",
|
|
|
|
|
|
reportName: "SalaryRankEmployee",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
date: Extension.ToThaiFullDate(new Date()),
|
|
|
|
|
|
group: salarys.group == null || salarys.group == 0 ? "" : salarys.group.toLocaleString(),
|
|
|
|
|
|
salaryRanks: mapSalaryRank,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-18 13:07:09 +07:00
|
|
|
|
/**
|
2024-04-01 13:31:39 +07:00
|
|
|
|
* API รายชื่อข้าราชการผู้ที่ครองตำแหน่ง รอบเมษายน และตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
2024-04-01 13:31:39 +07:00
|
|
|
|
* @summary รายชื่อข้าราชการผู้ที่ครองตำแหน่ง รอบเมษายน และตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-03-20 18:05:57 +07:00
|
|
|
|
@Get("gov-01/{rootId}/{salaryPeriodId}")
|
2024-03-18 17:30:54 +07:00
|
|
|
|
async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-19 22:34:09 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-20 18:05:57 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileRepository.find({
|
2024-03-18 13:07:09 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-20 18:05:57 +07:00
|
|
|
|
if (!_salaryPeriod) {
|
2024-03-18 13:07:09 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
2024-04-05 16:35:18 +07:00
|
|
|
|
const _root = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const root = _root?.root == null ? "" : _root.root;
|
|
|
|
|
|
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
2024-03-18 13:07:09 +07:00
|
|
|
|
|
2024-03-20 18:05:57 +07:00
|
|
|
|
const formattedData = _salaryPeriod.map((profile, index) => {
|
2024-03-18 13:07:09 +07:00
|
|
|
|
const fullNameParts = [
|
2024-03-21 10:25:48 +07:00
|
|
|
|
profile.child4,
|
|
|
|
|
|
profile.child3,
|
|
|
|
|
|
profile.child2,
|
|
|
|
|
|
profile.child1,
|
|
|
|
|
|
profile.root,
|
|
|
|
|
|
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
2024-03-18 13:07:09 +07:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const fullName = fullNameParts
|
|
|
|
|
|
.filter((part) => part !== undefined && part !== null)
|
|
|
|
|
|
.join("/");
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
|
2024-03-21 10:25:48 +07:00
|
|
|
|
fullName: fullName,
|
|
|
|
|
|
posLevel: profile.posLevel,
|
2024-03-18 13:07:09 +07:00
|
|
|
|
posNumber:
|
2024-03-21 10:25:48 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-18 13:07:09 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-19 22:34:09 +07:00
|
|
|
|
return new HttpSuccess({
|
2024-03-20 18:05:57 +07:00
|
|
|
|
template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
|
|
|
|
|
|
reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
|
2024-03-19 22:34:09 +07:00
|
|
|
|
data: {
|
2024-03-21 10:25:48 +07:00
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-04-05 16:35:18 +07:00
|
|
|
|
agency: root,
|
2024-03-19 22:34:09 +07:00
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-01 13:31:39 +07:00
|
|
|
|
* API บัญชีการคำนวณโควตาเลื่อนเงินเดือน รอบเมษายน และตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
2024-04-01 13:31:39 +07:00
|
|
|
|
* @summary บัญชีการคำนวณโควตาเลื่อนเงินเดือน รอบเมษายน และตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-03-20 18:05:57 +07:00
|
|
|
|
@Get("gov-02/{rootId}/{salaryPeriodId}")
|
2024-03-19 22:34:09 +07:00
|
|
|
|
async SalaryReport2(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
2024-03-18 13:07:09 +07:00
|
|
|
|
where: {
|
2024-03-19 22:34:09 +07:00
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-20 18:05:57 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryOrgRepository.find({
|
2024-03-19 22:34:09 +07:00
|
|
|
|
relations: ["salaryPeriod", "salaryProfiles"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-18 13:07:09 +07:00
|
|
|
|
},
|
2024-03-19 22:34:09 +07:00
|
|
|
|
});
|
2024-04-05 16:35:18 +07:00
|
|
|
|
|
2024-03-19 22:34:09 +07:00
|
|
|
|
const agency =
|
2024-03-20 18:05:57 +07:00
|
|
|
|
_salaryPeriod[0] == null || _salaryPeriod[0].salaryProfiles[0] == null
|
2024-03-19 22:34:09 +07:00
|
|
|
|
? ""
|
2024-03-20 18:05:57 +07:00
|
|
|
|
: _salaryPeriod[0].salaryProfiles[0].root;
|
|
|
|
|
|
if (salaryPeriod.period == "APR") {
|
|
|
|
|
|
let data1 = _salaryPeriod.find((x) => x.group == "GROUP2");
|
|
|
|
|
|
let formattedData1;
|
|
|
|
|
|
if (data1 != null) {
|
|
|
|
|
|
formattedData1 = {
|
|
|
|
|
|
total: Extension.ToThaiNumber(data1.total.toString()),
|
|
|
|
|
|
fifteenPercent: Extension.ToThaiNumber(data1.fifteenPercent.toString()),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
let data2 = _salaryPeriod.find((x) => x.group == "GROUP1");
|
|
|
|
|
|
let formattedData2;
|
|
|
|
|
|
if (data2 != null) {
|
|
|
|
|
|
formattedData2 = {
|
|
|
|
|
|
total: Extension.ToThaiNumber(data2.total.toString()),
|
|
|
|
|
|
fifteenPercent: Extension.ToThaiNumber(data2.fifteenPercent.toString()),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "NONE")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
let data3 = _salaryPeriod.find((x) => x.group == "GROUP1");
|
|
|
|
|
|
let formattedData3;
|
|
|
|
|
|
if (data3 != null) {
|
|
|
|
|
|
formattedData3 = {
|
|
|
|
|
|
total: Extension.ToThaiNumber(data3.total.toString()),
|
|
|
|
|
|
fifteenPercent: Extension.ToThaiNumber(data3.fifteenPercent.toString()),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "NONE")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
let data4 = _salaryPeriod.find((x) => x.group == "GROUP1");
|
|
|
|
|
|
let formattedData4;
|
|
|
|
|
|
if (data4 != null) {
|
|
|
|
|
|
formattedData4 = {
|
|
|
|
|
|
total: Extension.ToThaiNumber(data4.total.toString()),
|
|
|
|
|
|
fifteenPercent: Extension.ToThaiNumber(data4.fifteenPercent.toString()),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2024-03-18 13:07:09 +07:00
|
|
|
|
|
2024-03-20 18:05:57 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "gov1-02",
|
|
|
|
|
|
reportName: "gov1-02",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
date: Extension.ToThaiNumber(
|
|
|
|
|
|
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
|
|
|
|
|
|
),
|
2024-03-21 10:25:48 +07:00
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
dateNow: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date())),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data1: formattedData1,
|
|
|
|
|
|
data2: formattedData2,
|
|
|
|
|
|
data3: formattedData3,
|
|
|
|
|
|
data4: formattedData4,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let data1 = _salaryPeriod.find((x) => x.group == "GROUP2");
|
2024-03-20 19:30:13 +07:00
|
|
|
|
const _salaryPeriodAPR1 = await this.salaryOrgRepository.findOne({
|
2024-03-20 18:05:57 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
2024-03-20 19:30:13 +07:00
|
|
|
|
group: "GROUP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriod: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const _salaryPeriodAPR2 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
group: "GROUP2",
|
2024-03-20 18:05:57 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriod: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
let formattedData1;
|
|
|
|
|
|
if (data1 != null) {
|
|
|
|
|
|
const haftSalary = data1.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
const fullSalary = data1.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
const fullHaftSalary = data1.salaryProfiles
|
2024-03-20 19:30:13 +07:00
|
|
|
|
.filter((x) => x.type == "FULLHAFT")
|
2024-03-20 18:05:57 +07:00
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
formattedData1 = {
|
|
|
|
|
|
totalSalary: Extension.ToThaiNumber(data1.currentAmount.toString()),
|
|
|
|
|
|
totalUser: Extension.ToThaiNumber(data1.total.toString()),
|
|
|
|
|
|
sixPercentAmount: Extension.ToThaiNumber(data1.sixPercentAmount.toString()),
|
|
|
|
|
|
spentAmount: Extension.ToThaiNumber(data1.spentAmount.toString()),
|
|
|
|
|
|
remainingAmount: Extension.ToThaiNumber(
|
|
|
|
|
|
(data1.sixPercentAmount - data1.spentAmount).toString(),
|
|
|
|
|
|
),
|
2024-03-20 19:30:13 +07:00
|
|
|
|
fifteenPercentOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.fifteenPercent).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
totalOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.total).toString(),
|
|
|
|
|
|
),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
fullHaft: Extension.ToThaiNumber(
|
2024-03-20 19:30:13 +07:00
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "FULLHAFT").length.toString(),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data1.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
|
|
|
|
|
|
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
|
|
|
|
|
|
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
|
|
|
|
|
|
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
|
|
|
|
|
|
summary: Extension.ToThaiNumber(
|
|
|
|
|
|
(
|
|
|
|
|
|
data1.sixPercentAmount -
|
|
|
|
|
|
data1.spentAmount -
|
|
|
|
|
|
haftSalary -
|
|
|
|
|
|
fullSalary -
|
|
|
|
|
|
fullHaftSalary
|
|
|
|
|
|
).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
let data2 = _salaryPeriod.find((x) => x.group == "GROUP1");
|
|
|
|
|
|
let formattedData2;
|
|
|
|
|
|
if (data2 != null) {
|
|
|
|
|
|
const haftSalary = data2.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
const fullSalary = data2.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
const fullHaftSalary = data2.salaryProfiles
|
2024-03-20 19:30:13 +07:00
|
|
|
|
.filter((x) => x.type == "FULLHAFT")
|
2024-03-20 18:05:57 +07:00
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
formattedData2 = {
|
|
|
|
|
|
totalSalary: Extension.ToThaiNumber(data2.currentAmount.toString()),
|
|
|
|
|
|
totalUser: Extension.ToThaiNumber(data2.total.toString()),
|
|
|
|
|
|
sixPercentAmount: Extension.ToThaiNumber(data2.sixPercentAmount.toString()),
|
|
|
|
|
|
spentAmount: Extension.ToThaiNumber(data2.spentAmount.toString()),
|
|
|
|
|
|
remainingAmount: Extension.ToThaiNumber(
|
|
|
|
|
|
(data2.sixPercentAmount - data2.spentAmount).toString(),
|
|
|
|
|
|
),
|
2024-03-20 19:30:13 +07:00
|
|
|
|
fifteenPercentOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
totalOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.total).toString(),
|
|
|
|
|
|
),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
fullHaft: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
2024-03-20 19:30:13 +07:00
|
|
|
|
.filter((x) => x.type == "FULLHAFT")
|
2024-03-20 18:05:57 +07:00
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data2.salaryProfiles
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "อาวุโส" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการพิเศษ" ||
|
|
|
|
|
|
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
|
|
|
|
|
|
)
|
|
|
|
|
|
.filter((x) => x.type == "NONE")
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
|
|
|
|
|
|
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
|
|
|
|
|
|
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
|
|
|
|
|
|
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
|
|
|
|
|
|
summary: Extension.ToThaiNumber(
|
|
|
|
|
|
(
|
|
|
|
|
|
data2.sixPercentAmount -
|
|
|
|
|
|
data2.spentAmount -
|
|
|
|
|
|
haftSalary -
|
|
|
|
|
|
fullSalary -
|
|
|
|
|
|
fullHaftSalary
|
|
|
|
|
|
).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
let data3 = _salaryPeriod.find((x) => x.group == "GROUP1");
|
|
|
|
|
|
let formattedData3;
|
|
|
|
|
|
if (data3 != null) {
|
|
|
|
|
|
const haftSalary = data3.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
const fullSalary = data3.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
const fullHaftSalary = data3.salaryProfiles
|
2024-03-20 19:30:13 +07:00
|
|
|
|
.filter((x) => x.type == "FULLHAFT")
|
2024-03-20 18:05:57 +07:00
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
formattedData3 = {
|
|
|
|
|
|
totalSalary: Extension.ToThaiNumber(data3.currentAmount.toString()),
|
|
|
|
|
|
totalUser: Extension.ToThaiNumber(data3.total.toString()),
|
|
|
|
|
|
sixPercentAmount: Extension.ToThaiNumber(data3.sixPercentAmount.toString()),
|
|
|
|
|
|
spentAmount: Extension.ToThaiNumber(data3.spentAmount.toString()),
|
|
|
|
|
|
remainingAmount: Extension.ToThaiNumber(
|
|
|
|
|
|
(data3.sixPercentAmount - data3.spentAmount).toString(),
|
|
|
|
|
|
),
|
2024-03-20 19:30:13 +07:00
|
|
|
|
fifteenPercentOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
totalOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.total).toString(),
|
|
|
|
|
|
),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
fullHaft: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
2024-03-20 19:30:13 +07:00
|
|
|
|
.filter((x) => x.type == "FULLHAFT")
|
2024-03-20 18:05:57 +07:00
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data3.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "NONE")
|
|
|
|
|
|
.filter(
|
|
|
|
|
|
(x) =>
|
|
|
|
|
|
x.posLevel == "ปฏิบัติงาน" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญงาน" ||
|
|
|
|
|
|
x.posLevel == "ปฏิบัติการ" ||
|
|
|
|
|
|
x.posLevel == "ชำนาญการ",
|
|
|
|
|
|
)
|
|
|
|
|
|
.length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
|
|
|
|
|
|
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
|
|
|
|
|
|
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
|
|
|
|
|
|
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
|
|
|
|
|
|
summary: Extension.ToThaiNumber(
|
|
|
|
|
|
(
|
|
|
|
|
|
data3.sixPercentAmount -
|
|
|
|
|
|
data3.spentAmount -
|
|
|
|
|
|
haftSalary -
|
|
|
|
|
|
fullSalary -
|
|
|
|
|
|
fullHaftSalary
|
|
|
|
|
|
).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
let data4 = _salaryPeriod.find((x) => x.group == "GROUP1");
|
|
|
|
|
|
let formattedData4;
|
|
|
|
|
|
if (data4 != null) {
|
|
|
|
|
|
const haftSalary = data4.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "HAFT")
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
const fullSalary = data4.salaryProfiles
|
|
|
|
|
|
.filter((x) => x.type == "FULL")
|
|
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
const fullHaftSalary = data4.salaryProfiles
|
2024-03-20 19:30:13 +07:00
|
|
|
|
.filter((x) => x.type == "FULLHAFT")
|
2024-03-20 18:05:57 +07:00
|
|
|
|
.reduce((accumulator, object: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
accumulator +
|
2024-03-20 19:30:13 +07:00
|
|
|
|
(object.amountUse == null ? 0 : object.amountUse) +
|
2024-03-20 18:05:57 +07:00
|
|
|
|
(object.amountSpecial == null ? 0 : object.amountSpecial)
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
formattedData4 = {
|
|
|
|
|
|
totalSalary: Extension.ToThaiNumber(data4.currentAmount.toString()),
|
|
|
|
|
|
totalUser: Extension.ToThaiNumber(data4.total.toString()),
|
|
|
|
|
|
sixPercentAmount: Extension.ToThaiNumber(data4.sixPercentAmount.toString()),
|
|
|
|
|
|
spentAmount: Extension.ToThaiNumber(data4.spentAmount.toString()),
|
|
|
|
|
|
remainingAmount: Extension.ToThaiNumber(
|
|
|
|
|
|
(data4.sixPercentAmount - data4.spentAmount).toString(),
|
|
|
|
|
|
),
|
2024-03-20 19:30:13 +07:00
|
|
|
|
fifteenPercentOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
totalOld: Extension.ToThaiNumber(
|
|
|
|
|
|
(_salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.total).toString(),
|
|
|
|
|
|
),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
haft: Extension.ToThaiNumber(
|
|
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
full: Extension.ToThaiNumber(
|
|
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
fullHaft: Extension.ToThaiNumber(
|
2024-03-20 19:30:13 +07:00
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "FULLHAFT").length.toString(),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
),
|
|
|
|
|
|
notPromoted: Extension.ToThaiNumber(
|
|
|
|
|
|
data4.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
|
|
|
|
|
|
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
|
|
|
|
|
|
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
|
|
|
|
|
|
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
|
|
|
|
|
|
summary: Extension.ToThaiNumber(
|
|
|
|
|
|
(
|
|
|
|
|
|
data4.sixPercentAmount -
|
|
|
|
|
|
data4.spentAmount -
|
|
|
|
|
|
haftSalary -
|
|
|
|
|
|
fullSalary -
|
|
|
|
|
|
fullHaftSalary
|
|
|
|
|
|
).toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "gov2-02",
|
|
|
|
|
|
reportName: "gov2-02",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
date: Extension.ToThaiNumber(
|
|
|
|
|
|
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
|
|
|
|
|
|
),
|
2024-03-21 10:25:48 +07:00
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-03-20 18:05:57 +07:00
|
|
|
|
dateNow: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date())),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data1: formattedData1,
|
|
|
|
|
|
data2: formattedData2,
|
|
|
|
|
|
data3: formattedData3,
|
|
|
|
|
|
data4: formattedData4,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-01 13:31:39 +07:00
|
|
|
|
* API รายชื่อข้าราชการที่ได้รับการเสนอขอเลื่อนหนึ่งขั้น รอบเมษายน และตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
2024-04-01 13:31:39 +07:00
|
|
|
|
* @summary รายชื่อข้าราชการที่ได้รับการเสนอขอเลื่อนหนึ่งขั้น รอบเมษายน และตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
|
|
|
|
|
* @param {string} rootId Guid, *Id Root
|
|
|
|
|
|
* @param {string} salaryPeriodId Guid, *Id Period
|
|
|
|
|
|
*/
|
2024-03-21 09:51:42 +07:00
|
|
|
|
@Get("gov-03/{rootId}/{salaryPeriodId}")
|
2024-03-18 17:30:54 +07:00
|
|
|
|
async SalaryReport3(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-18 13:07:09 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg_Group1 = await this.salaryOrgRepository.findOne({
|
2024-03-18 13:07:09 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-18 13:07:09 +07:00
|
|
|
|
},
|
2024-03-22 17:44:56 +07:00
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg_Group2 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-18 13:07:09 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
|
2024-03-22 11:31:56 +07:00
|
|
|
|
if (salaryPeriod.period === "APR") {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfileGroup1 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: salaryOrg_Group1?.id,
|
|
|
|
|
|
type: "FULL", //หนึ่งขั้น
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryProfileGroup2 = await this.salaryProfileRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrgId: salaryOrg_Group2?.id,
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL", //หนึ่งขั้น
|
2024-03-22 11:31:56 +07:00
|
|
|
|
},
|
2024-03-21 18:18:50 +07:00
|
|
|
|
});
|
2024-03-22 11:31:56 +07:00
|
|
|
|
|
2024-03-21 18:18:50 +07:00
|
|
|
|
//รอบปีก่อนๆ
|
|
|
|
|
|
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year - 2,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod.year - 2,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg1_APR_Group1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg1_APR_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg1_OCT_Group1 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg1_OCT_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile1_Group1 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: In([salaryOrg1_APR_Group1?.id, salaryOrg1_OCT_Group1?.id]),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile1_Group2 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: In([salaryOrg1_APR_Group2?.id, salaryOrg1_OCT_Group2?.id]),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
|
2024-03-21 18:18:50 +07:00
|
|
|
|
//รอบปีก่อนหน้า
|
|
|
|
|
|
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year - 1,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryPeriodIncrease2_OCT = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod.year - 1,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg2_APR_Group1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg2_APR_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg2_OCT_GROUP1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg2_OCT_GROUP2 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryProfile2_Group1 = await this.salaryProfileRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrgId: In([salaryOrg2_APR_Group1?.id, salaryOrg2_OCT_GROUP1?.id]),
|
|
|
|
|
|
type: "FULL",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile2_Group2 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: In([salaryOrg2_APR_Group2?.id, salaryOrg2_OCT_GROUP2?.id]),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
|
2024-03-22 11:31:56 +07:00
|
|
|
|
const yearIncrease1 = Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 2)),
|
|
|
|
|
|
);
|
|
|
|
|
|
const yearIncrease2 = Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
|
|
|
|
|
|
);
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const fifteenPercent_Group1 =
|
|
|
|
|
|
salaryOrg_Group1?.fifteenPercent == undefined || salaryOrg_Group1?.fifteenPercent == null
|
2024-03-22 11:31:56 +07:00
|
|
|
|
? "๐"
|
2024-03-22 17:44:56 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPercent));
|
|
|
|
|
|
const fifteenPoint_Group1 =
|
|
|
|
|
|
salaryOrg_Group1?.fifteenPoint == undefined || salaryOrg_Group1?.fifteenPoint == null
|
2024-03-22 11:31:56 +07:00
|
|
|
|
? ".๐๐"
|
2024-03-22 17:44:56 +07:00
|
|
|
|
: "." + Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPoint));
|
|
|
|
|
|
const fifteenPercent_Group2 =
|
|
|
|
|
|
salaryOrg_Group2?.fifteenPercent == undefined || salaryOrg_Group2?.fifteenPercent == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPercent));
|
|
|
|
|
|
const fifteenPoint_Group2 =
|
|
|
|
|
|
salaryOrg_Group2?.fifteenPoint == undefined || salaryOrg_Group2?.fifteenPoint == null
|
|
|
|
|
|
? ".๐๐"
|
|
|
|
|
|
: "." + Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPoint));
|
2024-03-21 18:18:50 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "gov1-03",
|
|
|
|
|
|
reportName: "gov1-03",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: year,
|
|
|
|
|
|
yearIncrease1: yearIncrease1,
|
|
|
|
|
|
yearIncrease2: yearIncrease2,
|
|
|
|
|
|
yearIncreaseSlice: yearIncrease2.slice(-2),
|
2024-03-22 11:31:56 +07:00
|
|
|
|
yearSlice: year.slice(-2),
|
2024-03-22 17:44:56 +07:00
|
|
|
|
point: fifteenPercent_Group1 + fifteenPoint_Group1,
|
|
|
|
|
|
pointGroup2: fifteenPercent_Group2 + fifteenPoint_Group2,
|
2024-04-05 16:35:18 +07:00
|
|
|
|
root: salaryOrg_Group1?.root,
|
2024-03-22 17:44:56 +07:00
|
|
|
|
profile: salaryProfileGroup1.map((item, index) => ({
|
|
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname:
|
|
|
|
|
|
(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, // สังกัด/ชื่อ-นามสกุล
|
|
|
|
|
|
posLevel: item.posLevel,
|
|
|
|
|
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
|
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
|
|
|
|
|
salaryIncrease1:
|
|
|
|
|
|
salaryProfile1_Group1.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const filteredAmount = salaryProfile1_Group1
|
|
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
2024-03-22 18:04:20 +07:00
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
2024-03-22 17:44:56 +07:00
|
|
|
|
})()
|
|
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
|
|
|
|
|
salaryIncrease2:
|
|
|
|
|
|
salaryProfile2_Group1.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const filteredAmount = salaryProfile2_Group1
|
|
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
2024-03-22 18:04:20 +07:00
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
2024-03-22 17:44:56 +07:00
|
|
|
|
})()
|
|
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
|
|
|
|
|
score: null, //ผลการประเมินฯ
|
|
|
|
|
|
remark: null, //หมายเหตุ
|
|
|
|
|
|
})),
|
|
|
|
|
|
profileGroup2: salaryProfileGroup2.map((item, index) => ({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname:
|
|
|
|
|
|
(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, // สังกัด/ชื่อ-นามสกุล
|
|
|
|
|
|
posLevel: item.posLevel,
|
|
|
|
|
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
|
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
|
|
|
|
|
salaryIncrease1:
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryProfile1_Group2.length > 0
|
2024-03-22 12:04:57 +07:00
|
|
|
|
? (() => {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const filteredAmount = salaryProfile1_Group2
|
2024-03-22 12:04:57 +07:00
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
2024-03-22 12:04:57 +07:00
|
|
|
|
})()
|
2024-03-21 18:18:50 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
|
|
|
|
|
salaryIncrease2:
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryProfile2_Group2.length > 0
|
2024-03-22 12:04:57 +07:00
|
|
|
|
? (() => {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const filteredAmount = salaryProfile2_Group2
|
2024-03-22 12:04:57 +07:00
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
2024-03-22 12:04:57 +07:00
|
|
|
|
})()
|
2024-03-21 18:18:50 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
|
|
|
|
|
score: null, //ผลการประเมินฯ
|
|
|
|
|
|
remark: null, //หมายเหตุ
|
|
|
|
|
|
})),
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 11:31:56 +07:00
|
|
|
|
} else if (salaryPeriod.period === "OCT") {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
// find period APR
|
2024-03-21 18:18:50 +07:00
|
|
|
|
const salaryPeriod_APR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod?.year,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg_APR_Group1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriod_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-22 11:31:56 +07:00
|
|
|
|
},
|
2024-03-21 18:18:50 +07:00
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg_APR_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriod_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryProfile_APR_Group1 = await this.salaryProfileRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrgId: salaryOrg_APR_Group1?.id,
|
|
|
|
|
|
type: In(["HAFT", "FULL"]),
|
2024-03-22 11:31:56 +07:00
|
|
|
|
},
|
2024-03-21 18:18:50 +07:00
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile_APR_Group2 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: salaryOrg_APR_Group2?.id,
|
2024-03-22 11:31:56 +07:00
|
|
|
|
type: In(["HAFT", "FULL"]),
|
|
|
|
|
|
},
|
2024-03-21 18:18:50 +07:00
|
|
|
|
});
|
|
|
|
|
|
//end period APR
|
2024-03-18 13:07:09 +07:00
|
|
|
|
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfileGroup1 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: salaryOrg_Group1?.id,
|
|
|
|
|
|
type: In(["FULLHAFT", "FULL"]),
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryProfileGroup2 = await this.salaryProfileRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrgId: salaryOrg_Group2?.id,
|
2024-03-22 11:31:56 +07:00
|
|
|
|
type: In(["FULLHAFT", "FULL"]),
|
|
|
|
|
|
},
|
2024-03-21 18:18:50 +07:00
|
|
|
|
});
|
2024-03-22 11:31:56 +07:00
|
|
|
|
|
2024-03-21 18:18:50 +07:00
|
|
|
|
//รอบปีก่อนๆ
|
|
|
|
|
|
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year - 2,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod.year - 2,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg1_APR_Group1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg1_APR_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg1_OCT_Group1 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg1_OCT_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile1_Group1 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: In([salaryOrg1_APR_Group1?.id, salaryOrg1_OCT_Group1?.id]),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile1_Group2 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: In([salaryOrg1_APR_Group2?.id, salaryOrg1_OCT_Group2?.id]),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
|
2024-03-21 18:18:50 +07:00
|
|
|
|
//รอบปีก่อนหน้า
|
|
|
|
|
|
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year - 1,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryPeriodIncrease2_OCT = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod.year - 1,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg2_APR_Group1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg2_APR_Group2 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryOrg2_OCT_GROUP1 = await this.salaryOrgRepository.findOne({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP1",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrg2_OCT_GROUP2 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:04:20 +07:00
|
|
|
|
group: "GROUP2",
|
2024-03-22 17:44:56 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryProfile2_Group1 = await this.salaryProfileRepository.find({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrgId: In([salaryOrg2_APR_Group1?.id, salaryOrg2_OCT_GROUP1?.id]),
|
|
|
|
|
|
type: "FULL",
|
2024-03-21 18:18:50 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const salaryProfile2_Group2 = await this.salaryProfileRepository.find({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
where: {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrgId: In([salaryOrg2_APR_Group2?.id, salaryOrg2_OCT_GROUP2?.id]),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
type: "FULL",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
|
2024-03-22 11:31:56 +07:00
|
|
|
|
const yearIncrease1 = Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 2)),
|
|
|
|
|
|
);
|
|
|
|
|
|
const yearIncrease2 = Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
|
|
|
|
|
|
);
|
|
|
|
|
|
const fifteenPercent =
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrg_Group1?.fifteenPercent == undefined || salaryOrg_Group1?.fifteenPercent == null
|
2024-03-22 11:31:56 +07:00
|
|
|
|
? "๐"
|
2024-03-22 17:44:56 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPercent));
|
2024-03-22 11:31:56 +07:00
|
|
|
|
const fifteenPoint =
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryOrg_Group1?.fifteenPoint == undefined || salaryOrg_Group1?.fifteenPoint == null
|
2024-03-22 11:31:56 +07:00
|
|
|
|
? ".๐๐"
|
2024-03-22 17:44:56 +07:00
|
|
|
|
: "." + Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPoint));
|
|
|
|
|
|
const fifteenPercent_Group2 =
|
|
|
|
|
|
salaryOrg_Group2?.fifteenPercent == undefined || salaryOrg_Group2?.fifteenPercent == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPercent));
|
2024-03-22 18:04:20 +07:00
|
|
|
|
const fifteenPoint_Group2 =
|
|
|
|
|
|
salaryOrg_Group2?.fifteenPoint == undefined || salaryOrg_Group2?.fifteenPoint == null
|
|
|
|
|
|
? ".๐๐"
|
|
|
|
|
|
: "." + Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPoint));
|
2024-03-21 18:18:50 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "gov2-03",
|
|
|
|
|
|
reportName: "gov2-03",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: year,
|
|
|
|
|
|
yearIncrease1: yearIncrease1,
|
|
|
|
|
|
yearIncrease2: yearIncrease2,
|
|
|
|
|
|
yearIncreaseSlice: yearIncrease2.slice(-2),
|
2024-03-22 11:31:56 +07:00
|
|
|
|
yearSlice: year.slice(-2),
|
2024-03-21 18:18:50 +07:00
|
|
|
|
point: fifteenPercent + fifteenPoint,
|
2024-03-22 17:44:56 +07:00
|
|
|
|
pointGroup2: fifteenPercent_Group2 + fifteenPoint_Group2,
|
2024-04-05 16:35:18 +07:00
|
|
|
|
root: salaryOrg_Group1?.root,
|
2024-03-22 17:44:56 +07:00
|
|
|
|
profile: salaryProfileGroup1.map((item, index) => ({
|
|
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname:
|
|
|
|
|
|
(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, // สังกัด/ชื่อ-นามสกุล
|
|
|
|
|
|
posLevel: item.posLevel,
|
|
|
|
|
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
|
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
|
|
|
|
|
salaryIncrease1:
|
|
|
|
|
|
salaryProfile1_Group1.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const filteredAmount = salaryProfile1_Group1
|
|
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
2024-03-22 18:04:20 +07:00
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
2024-03-22 17:44:56 +07:00
|
|
|
|
})()
|
|
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
|
|
|
|
|
salaryIncrease2:
|
|
|
|
|
|
salaryProfile2_Group1.length > 0
|
|
|
|
|
|
? (() => {
|
2024-03-22 18:04:20 +07:00
|
|
|
|
const filteredAmount = salaryProfile2_Group1
|
|
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
|
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
|
|
|
|
|
})()
|
2024-03-22 17:44:56 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
|
|
|
|
|
salaryIncreaseAPR:
|
|
|
|
|
|
salaryProfile_APR_Group1.length > 0
|
|
|
|
|
|
? (() => {
|
2024-03-22 18:04:20 +07:00
|
|
|
|
const filteredAmount = salaryProfile_APR_Group1
|
|
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
|
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
|
|
|
|
|
})()
|
2024-03-22 17:44:56 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนรอบเมษา
|
|
|
|
|
|
Type: item.type === "FULL" ? "หนึ่งขั้น" : "หนึ่งขั้นครึ่ง",
|
|
|
|
|
|
score1: null, //ผลการประเมินฯ ครั้งที่ 1
|
|
|
|
|
|
score2: null, //ผลการประเมินฯ ครั้งที่ 2
|
|
|
|
|
|
})),
|
|
|
|
|
|
profileGroup2: salaryProfileGroup2.map((item, index) => ({
|
2024-03-21 18:18:50 +07:00
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname:
|
|
|
|
|
|
(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, // สังกัด/ชื่อ-นามสกุล
|
|
|
|
|
|
posLevel: item.posLevel,
|
|
|
|
|
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
|
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
|
|
|
|
|
salaryIncrease1:
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryProfile1_Group2.length > 0
|
2024-03-22 12:04:57 +07:00
|
|
|
|
? (() => {
|
2024-03-22 17:44:56 +07:00
|
|
|
|
const filteredAmount = salaryProfile1_Group2
|
2024-03-22 12:04:57 +07:00
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
2024-03-22 12:04:57 +07:00
|
|
|
|
})()
|
2024-03-21 18:18:50 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
|
|
|
|
|
salaryIncrease2:
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryProfile2_Group2.length > 0
|
2024-03-22 12:04:57 +07:00
|
|
|
|
? (() => {
|
2024-03-22 18:04:20 +07:00
|
|
|
|
const filteredAmount = salaryProfile2_Group2
|
2024-03-22 18:02:51 +07:00
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
|
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
|
|
|
|
|
})()
|
2024-03-21 18:18:50 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
|
|
|
|
|
salaryIncreaseAPR:
|
2024-03-22 17:44:56 +07:00
|
|
|
|
salaryProfile_APR_Group2.length > 0
|
2024-03-22 12:04:57 +07:00
|
|
|
|
? (() => {
|
2024-03-22 18:04:20 +07:00
|
|
|
|
const filteredAmount = salaryProfile_APR_Group2
|
2024-03-22 18:02:51 +07:00
|
|
|
|
.filter((profile) => profile.citizenId === item.citizenId)
|
|
|
|
|
|
.map((profile) => profile.amount);
|
|
|
|
|
|
const Amount = filteredAmount[0];
|
|
|
|
|
|
return Amount === undefined || Amount === null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(Amount?.toLocaleString());
|
|
|
|
|
|
})()
|
2024-03-21 18:18:50 +07:00
|
|
|
|
: "๐", //การเลื่อนเงินเดือนรอบเมษา
|
|
|
|
|
|
Type: item.type === "FULL" ? "หนึ่งขั้น" : "หนึ่งขั้นครึ่ง",
|
|
|
|
|
|
score1: null, //ผลการประเมินฯ ครั้งที่ 1
|
|
|
|
|
|
score2: null, //ผลการประเมินฯ ครั้งที่ 2
|
|
|
|
|
|
})),
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-21 09:51:42 +07:00
|
|
|
|
/**
|
2024-03-27 15:30:41 +07:00
|
|
|
|
* API แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
2024-03-27 15:30:41 +07:00
|
|
|
|
* @summary แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม
|
2024-03-18 13:07:09 +07:00
|
|
|
|
*
|
|
|
|
|
|
* @param {string} rootId Guid, *Id Root
|
|
|
|
|
|
* @param {string} salaryPeriodId Guid, *Id Period
|
|
|
|
|
|
*/
|
2024-03-21 09:51:42 +07:00
|
|
|
|
@Get("gov-04/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-21 10:25:48 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
2024-03-21 09:51:42 +07:00
|
|
|
|
where: {
|
2024-03-21 10:25:48 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
type: "NONE", //ไม่ได้เลื่อน
|
2024-04-05 16:35:18 +07:00
|
|
|
|
isRetired: false, //กรองเฉพาะคนที่ไม่เกษียณ
|
2024-03-21 09:51:42 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
group: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
type: "DESC",
|
2024-03-21 10:25:48 +07:00
|
|
|
|
orgShortName: "ASC",
|
2024-03-21 09:51:42 +07:00
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-04-05 16:35:18 +07:00
|
|
|
|
const _root = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const root = _root?.root == null ? "" : _root.root;
|
|
|
|
|
|
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
2024-03-21 10:25:48 +07:00
|
|
|
|
|
|
|
|
|
|
const formattedData = _salaryPeriod.map((profile, index) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname: profile.prefix + profile.firstName + " " + profile.lastName,
|
|
|
|
|
|
log_group: profile.salaryOrg.group,
|
|
|
|
|
|
log_type: profile.type,
|
|
|
|
|
|
log_isNext: profile.isNext,
|
|
|
|
|
|
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),
|
|
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
orgShortName: profile.orgShortName + Extension.ToThaiNumber(String(profile.posMasterNo)),
|
|
|
|
|
|
amount:
|
|
|
|
|
|
profile.amount == undefined || profile.amount == null || profile.amount == 0
|
|
|
|
|
|
? ""
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(profile.amount.toLocaleString())),
|
2024-03-21 10:25:48 +07:00
|
|
|
|
amountSpecial:
|
|
|
|
|
|
(profile.positionSalaryAmount == undefined ||
|
|
|
|
|
|
profile.positionSalaryAmount == null ||
|
|
|
|
|
|
profile.positionSalaryAmount == 0
|
|
|
|
|
|
? ""
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(profile.positionSalaryAmount.toLocaleString()))) +
|
2024-03-21 10:25:48 +07:00
|
|
|
|
(profile.amountSpecial == undefined ||
|
|
|
|
|
|
profile.amountSpecial == null ||
|
|
|
|
|
|
profile.amountSpecial == 0
|
|
|
|
|
|
? ""
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: `(${Extension.ToThaiNumber(String(profile.amountSpecial.toLocaleString()))})`),
|
2024-03-21 10:25:48 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
remark:
|
|
|
|
|
|
`${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
|
|
|
|
|
|
`${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` +
|
|
|
|
|
|
`${profile.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
|
|
|
|
|
|
`${profile.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-21 09:51:42 +07:00
|
|
|
|
return new HttpSuccess({
|
2024-03-21 10:25:48 +07:00
|
|
|
|
template: salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04",
|
|
|
|
|
|
reportName: salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04",
|
2024-03-21 09:51:42 +07:00
|
|
|
|
data: {
|
2024-03-21 10:25:48 +07:00
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
effectiveDate: salaryPeriod.effectiveDate,
|
2024-04-05 16:35:18 +07:00
|
|
|
|
root: root,
|
2024-03-21 10:25:48 +07:00
|
|
|
|
profile: formattedData,
|
2024-03-21 09:51:42 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-18 13:07:09 +07:00
|
|
|
|
|
2024-03-18 16:11:13 +07:00
|
|
|
|
/**
|
2024-03-27 15:30:41 +07:00
|
|
|
|
* API แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ)
|
2024-03-18 16:11:13 +07:00
|
|
|
|
*
|
2024-03-27 15:30:41 +07:00
|
|
|
|
* @summary แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @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) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const _salaryPeriod = await this.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
type: "NONE", //ไม่ได้เลื่อน
|
2024-04-05 16:35:18 +07:00
|
|
|
|
isRetired: true, //กรองเฉพาะคนที่เกษียณ
|
2024-03-27 15:30:41 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
group: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
type: "DESC",
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-04-05 16:35:18 +07:00
|
|
|
|
const _root = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const root = _root?.root == null ? "" : _root.root;
|
|
|
|
|
|
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
2024-03-27 15:30:41 +07:00
|
|
|
|
|
|
|
|
|
|
const formattedData = _salaryPeriod.map((profile, index) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname: profile.prefix + profile.firstName + " " + profile.lastName,
|
|
|
|
|
|
log_group: profile.salaryOrg.group,
|
|
|
|
|
|
log_type: profile.type,
|
|
|
|
|
|
log_isNext: profile.isNext,
|
|
|
|
|
|
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),
|
|
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
orgShortName: profile.orgShortName + Extension.ToThaiNumber(String(profile.posMasterNo)),
|
|
|
|
|
|
amount:
|
|
|
|
|
|
profile.amount == undefined || profile.amount == null || profile.amount == 0
|
|
|
|
|
|
? ""
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(profile.amount.toLocaleString())),
|
2024-03-27 15:30:41 +07:00
|
|
|
|
amountSpecial:
|
|
|
|
|
|
(profile.positionSalaryAmount == undefined ||
|
|
|
|
|
|
profile.positionSalaryAmount == null ||
|
|
|
|
|
|
profile.positionSalaryAmount == 0
|
|
|
|
|
|
? ""
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(profile.positionSalaryAmount.toLocaleString()))) +
|
2024-03-27 15:30:41 +07:00
|
|
|
|
(profile.amountSpecial == undefined ||
|
|
|
|
|
|
profile.amountSpecial == null ||
|
|
|
|
|
|
profile.amountSpecial == 0
|
|
|
|
|
|
? ""
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: `(${Extension.ToThaiNumber(String(profile.amountSpecial.toLocaleString()))})`),
|
2024-03-27 15:30:41 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
remark:
|
|
|
|
|
|
`${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
|
|
|
|
|
|
`${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` +
|
|
|
|
|
|
`${profile.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
|
|
|
|
|
|
`${profile.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04",
|
|
|
|
|
|
reportName: salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
effectiveDate: salaryPeriod.effectiveDate,
|
2024-04-05 16:35:18 +07:00
|
|
|
|
root: root,
|
2024-03-27 15:30:41 +07:00
|
|
|
|
profile: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม
|
2024-03-18 16:11:13 +07:00
|
|
|
|
*
|
|
|
|
|
|
* @param {string} rootId Guid, *Id Root
|
|
|
|
|
|
* @param {string} salaryPeriodId Guid, *Id Period
|
|
|
|
|
|
*/
|
2024-03-21 09:51:42 +07:00
|
|
|
|
@Get("gov-05/{rootId}/{salaryPeriodId}")
|
2024-03-18 17:30:54 +07:00
|
|
|
|
async SalaryReport5(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-18 16:11:13 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-21 10:25:48 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
2024-03-18 16:11:13 +07:00
|
|
|
|
where: {
|
2024-03-21 10:25:48 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
type: "NONE", //ไม่ได้เลื่อน
|
2024-04-05 16:35:18 +07:00
|
|
|
|
isRetired: false, //กรองเฉพาะคนที่ไม่เกษียณ
|
2024-03-27 15:30:41 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
group: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-04-05 16:35:18 +07:00
|
|
|
|
const _root = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const root = _root?.root == null ? "" : _root.root;
|
|
|
|
|
|
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
2024-03-27 15:30:41 +07:00
|
|
|
|
|
|
|
|
|
|
const formattedData = _salaryPeriod.map((profile, index) => {
|
|
|
|
|
|
const fullNameParts = [
|
|
|
|
|
|
profile.position,
|
|
|
|
|
|
profile.child4,
|
|
|
|
|
|
profile.child3,
|
|
|
|
|
|
profile.child2,
|
|
|
|
|
|
profile.child1,
|
|
|
|
|
|
profile.root,
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const position = fullNameParts
|
|
|
|
|
|
.filter((part) => part !== undefined && part !== null)
|
|
|
|
|
|
.join("/");
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
|
|
|
|
|
|
fullname: profile.prefix + profile.firstName + " " + profile.lastName,
|
|
|
|
|
|
position: position,
|
|
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-04-05 14:08:15 +07:00
|
|
|
|
reason: null, //เหตุผล
|
2024-03-27 15:30:41 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
2024-04-05 14:08:15 +07:00
|
|
|
|
remark: null, //หมายเหตุ
|
2024-03-27 15:30:41 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05",
|
|
|
|
|
|
reportName: salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-04-05 16:35:18 +07:00
|
|
|
|
agency: root,
|
2024-03-27 15:30:41 +07:00
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @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) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const _salaryPeriod = await this.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
type: "NONE", //ไม่ได้เลื่อน
|
2024-04-05 16:35:18 +07:00
|
|
|
|
isRetired: true, //กรองเฉพาะคนที่เกษียณ
|
2024-03-18 16:11:13 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 10:25:48 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
group: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
2024-03-18 16:11:13 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-04-05 16:35:18 +07:00
|
|
|
|
const _root = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const root = _root?.root == null ? "" : _root.root;
|
|
|
|
|
|
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
2024-03-18 16:11:13 +07:00
|
|
|
|
|
2024-03-21 10:25:48 +07:00
|
|
|
|
const formattedData = _salaryPeriod.map((profile, index) => {
|
|
|
|
|
|
const fullNameParts = [
|
|
|
|
|
|
profile.position,
|
|
|
|
|
|
profile.child4,
|
|
|
|
|
|
profile.child3,
|
|
|
|
|
|
profile.child2,
|
|
|
|
|
|
profile.child1,
|
|
|
|
|
|
profile.root,
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const position = fullNameParts
|
|
|
|
|
|
.filter((part) => part !== undefined && part !== null)
|
|
|
|
|
|
.join("/");
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
|
|
|
|
|
|
fullname: profile.prefix + profile.firstName + " " + profile.lastName,
|
|
|
|
|
|
position: position,
|
|
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-18 16:11:13 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
2024-03-21 10:25:48 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05",
|
|
|
|
|
|
reportName: salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-04-05 16:35:18 +07:00
|
|
|
|
agency: root,
|
2024-03-21 10:25:48 +07:00
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-18 16:11:13 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-18 17:30:54 +07:00
|
|
|
|
// /* API แบบ 3 กท บัญชีแสดงวันลาครึ่งปี ขรก
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @summary แบบ 3 กท บัญชีแสดงวันลาครึ่งปี ขรก
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @param {string} rootId Guid, *Id Root
|
|
|
|
|
|
// * @param {string} salaryPeriodId Guid, *Id Period
|
|
|
|
|
|
// */
|
2024-03-21 09:51:42 +07:00
|
|
|
|
// @Get("gov-06/{rootId}/{salaryPeriodId}")
|
2024-03-18 17:30:54 +07:00
|
|
|
|
// async SalaryReport6(){
|
2024-03-18 16:11:13 +07:00
|
|
|
|
|
2024-03-18 17:30:54 +07:00
|
|
|
|
// }
|
2024-03-18 16:11:13 +07:00
|
|
|
|
|
2024-03-18 13:07:09 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API คำสั่งเลื่อนเงินเดือน รอบเมษายน
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary คำสั่งเลื่อนเงินเดือน รอบเมษายน
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param {string} rootId Guid, *Id Root
|
|
|
|
|
|
* @param {string} salaryPeriodId Guid, *Id Period
|
|
|
|
|
|
*/
|
2024-03-21 09:51:42 +07:00
|
|
|
|
@Get("gov-07/{rootId}/{salaryPeriodId}")
|
2024-03-18 17:30:54 +07:00
|
|
|
|
async SalaryReport7(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-18 13:07:09 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const salaryProfile = await this.salaryProfileRepository.find({
|
|
|
|
|
|
where: {
|
2024-03-20 13:54:34 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
salaryPeriod: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-03-18 13:07:09 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-20 13:54:34 +07:00
|
|
|
|
type: "DESC",
|
|
|
|
|
|
orgShortName: "ASC",
|
2024-03-18 13:07:09 +07:00
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-04-05 16:35:18 +07:00
|
|
|
|
const _root = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const root = _root?.root == null ? "" : _root.root;
|
|
|
|
|
|
// const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root;
|
2024-03-18 13:07:09 +07:00
|
|
|
|
|
2024-03-20 13:54:34 +07:00
|
|
|
|
const formattedData = salaryProfile.map((item, index) => ({
|
2024-03-18 13:07:09 +07:00
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname: item.prefix + item.firstName + " " + item.lastName,
|
2024-03-20 13:54:34 +07:00
|
|
|
|
position:
|
|
|
|
|
|
item.position +
|
|
|
|
|
|
"/" +
|
|
|
|
|
|
(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),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
posType: item.posType,
|
|
|
|
|
|
posLevel: item.posLevel,
|
2024-03-20 13:54:34 +07:00
|
|
|
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
positionSalaryAmount:
|
|
|
|
|
|
item.positionSalaryAmount == undefined || item.positionSalaryAmount == null
|
|
|
|
|
|
? "๐"
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(item.positionSalaryAmount.toLocaleString())) +
|
2024-03-20 13:54:34 +07:00
|
|
|
|
(item.amountSpecial > 0
|
|
|
|
|
|
? `(${Extension.ToThaiNumber(String(item.positionSalaryAmount))})`
|
|
|
|
|
|
: ""),
|
|
|
|
|
|
remark:
|
2024-03-21 10:25:48 +07:00
|
|
|
|
`${item.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
|
|
|
|
|
|
`${item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` +
|
|
|
|
|
|
`${item.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
|
|
|
|
|
|
`${item.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // ห
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}));
|
|
|
|
|
|
|
2024-03-20 13:54:34 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "gov1-07",
|
|
|
|
|
|
reportName: "gov1-07",
|
|
|
|
|
|
data: {
|
2024-03-21 10:25:48 +07:00
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-03-20 13:54:34 +07:00
|
|
|
|
yearOld: Extension.ToThaiNumber((salaryPeriod.year + 542).toString()),
|
|
|
|
|
|
date: Extension.ToThaiNumber(
|
|
|
|
|
|
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)),
|
|
|
|
|
|
),
|
2024-04-05 16:35:18 +07:00
|
|
|
|
agency: root,
|
2024-03-20 13:54:34 +07:00
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* APIคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary คำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param {string} rootId Guid, *Id Root
|
|
|
|
|
|
* @param {string} salaryPeriodId Guid, *Id Period
|
|
|
|
|
|
*/
|
2024-03-21 09:51:42 +07:00
|
|
|
|
@Get("gov-08/{rootId}/{salaryPeriodId}")
|
2024-03-18 17:30:54 +07:00
|
|
|
|
async SalaryReport8(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-18 13:07:09 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-05 14:08:15 +07:00
|
|
|
|
const salaryOrgGroup1 = await this.salaryOrgRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
group: "GROUP1"
|
|
|
|
|
|
},
|
|
|
|
|
|
relations: ["salaryProfiles"],
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryOrgGroup2 = await this.salaryOrgRepository.findOne({
|
2024-03-18 13:07:09 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-04-05 14:08:15 +07:00
|
|
|
|
group: "GROUP2"
|
2024-03-18 13:07:09 +07:00
|
|
|
|
},
|
|
|
|
|
|
relations: ["salaryProfiles"],
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const salaryProfileSpecial = await this.salaryProfileRepository.find({
|
2024-04-05 15:01:48 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
2024-03-18 13:07:09 +07:00
|
|
|
|
where: {
|
2024-04-05 14:08:15 +07:00
|
|
|
|
salaryOrgId: In([salaryOrgGroup1?.id, salaryOrgGroup2?.id,]),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
amountSpecial: MoreThan(1),
|
|
|
|
|
|
},
|
|
|
|
|
|
select: [
|
|
|
|
|
|
"id",
|
|
|
|
|
|
"prefix",
|
|
|
|
|
|
"firstName",
|
|
|
|
|
|
"lastName",
|
|
|
|
|
|
"root",
|
|
|
|
|
|
"position",
|
|
|
|
|
|
"posType",
|
|
|
|
|
|
"posLevel",
|
|
|
|
|
|
"orgShortName",
|
|
|
|
|
|
"posMasterNo",
|
|
|
|
|
|
"amount",
|
|
|
|
|
|
"amountSpecial",
|
|
|
|
|
|
],
|
|
|
|
|
|
order: {
|
2024-04-05 15:01:48 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
group: "ASC"
|
|
|
|
|
|
},
|
2024-03-18 13:07:09 +07:00
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const salaryProfileNoAmount = await this.salaryProfileRepository.find({
|
2024-04-05 15:01:48 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
2024-03-18 13:07:09 +07:00
|
|
|
|
where: {
|
2024-04-05 14:08:15 +07:00
|
|
|
|
salaryOrgId: In([salaryOrgGroup1?.id, salaryOrgGroup2?.id,]),
|
|
|
|
|
|
// amountUse: IsNull() || 0,
|
|
|
|
|
|
// positionSalaryAmount: IsNull() || 0,
|
|
|
|
|
|
type: "NONE"
|
2024-03-18 13:07:09 +07:00
|
|
|
|
},
|
|
|
|
|
|
select: [
|
|
|
|
|
|
"id",
|
|
|
|
|
|
"prefix",
|
|
|
|
|
|
"firstName",
|
|
|
|
|
|
"lastName",
|
|
|
|
|
|
"root",
|
|
|
|
|
|
"position",
|
|
|
|
|
|
"posType",
|
|
|
|
|
|
"posLevel",
|
|
|
|
|
|
"orgShortName",
|
|
|
|
|
|
"posMasterNo",
|
|
|
|
|
|
"amount",
|
|
|
|
|
|
],
|
|
|
|
|
|
order: {
|
2024-04-05 15:01:48 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
group: "ASC"
|
|
|
|
|
|
},
|
2024-03-18 13:07:09 +07:00
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const profileSpecial = salaryProfileSpecial.map((item, index) => ({
|
|
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname: item.prefix + item.firstName + " " + item.lastName,
|
|
|
|
|
|
position: item.position,
|
|
|
|
|
|
posType: item.posType,
|
|
|
|
|
|
posLevel: item.posLevel,
|
2024-04-05 14:08:15 +07:00
|
|
|
|
posMasterNo:
|
|
|
|
|
|
item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
amountSpecial:
|
|
|
|
|
|
item.amountSpecial == undefined || item.amountSpecial == null
|
|
|
|
|
|
? "๐"
|
2024-04-01 14:11:06 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(item.amountSpecial.toLocaleString())),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
remark: null,
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
const profileNoAmount = salaryProfileNoAmount.map((item, index) => ({
|
|
|
|
|
|
no: Extension.ToThaiNumber(String(index + 1)),
|
|
|
|
|
|
fullname: item.prefix + item.firstName + " " + item.lastName,
|
|
|
|
|
|
position: item.position,
|
|
|
|
|
|
posType: item.posType,
|
|
|
|
|
|
posLevel: item.posLevel,
|
2024-04-05 14:08:15 +07:00
|
|
|
|
posMasterNo:
|
|
|
|
|
|
item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
amount:
|
|
|
|
|
|
item.amount == undefined || item.amount == null
|
|
|
|
|
|
? "๐"
|
2024-04-05 15:01:48 +07:00
|
|
|
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
2024-03-18 13:07:09 +07:00
|
|
|
|
remark: null,
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2024-04-01 13:31:39 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "gov1-08",
|
|
|
|
|
|
reportName: "gov1-08",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
date: Extension.ToThaiNumber(
|
|
|
|
|
|
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)),
|
|
|
|
|
|
),
|
|
|
|
|
|
profileSpecial: profileSpecial,
|
|
|
|
|
|
profileNoAmount: profileNoAmount,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-18 13:07:09 +07:00
|
|
|
|
}
|
2024-03-21 15:29:39 +07:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 01-บัญชีคำนวณโควตา
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 01-บัญชีคำนวณโควตา
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-01/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_1(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
const _salaryPeriod = await this.salaryOrgEmployeeRepository.findOne({
|
|
|
|
|
|
relations: ["salaryPeriod", "salaryProfiles"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const agency =
|
|
|
|
|
|
_salaryPeriod == null || _salaryPeriod.salaryProfiles[0] == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: _salaryPeriod.salaryProfiles[0].root;
|
|
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "emp1-01",
|
|
|
|
|
|
reportName: "emp1-01",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
total: _salaryPeriod == null ? "" : Extension.ToThaiNumber(_salaryPeriod.total.toString()),
|
|
|
|
|
|
fifteenPercent:
|
|
|
|
|
|
_salaryPeriod == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: Extension.ToThaiNumber(_salaryPeriod.fifteenPercent.toString()),
|
|
|
|
|
|
full:
|
|
|
|
|
|
_salaryPeriod == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: Extension.ToThaiNumber(
|
|
|
|
|
|
_salaryPeriod.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
haft:
|
|
|
|
|
|
_salaryPeriod == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: Extension.ToThaiNumber(
|
|
|
|
|
|
_salaryPeriod.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
notPromoted:
|
|
|
|
|
|
_salaryPeriod == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: Extension.ToThaiNumber(
|
|
|
|
|
|
_salaryPeriod.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
|
|
|
|
|
|
),
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-21 15:29:39 +07:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 02-รายชื่อลูกจ้างประจำผู้ครองตำแหน่ง ณ วันที่ 1 มีนาคม
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 02-รายชื่อลูกจ้างประจำผู้ครองตำแหน่ง ณ วันที่ 1 มีนาคม
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-02/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_2(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
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: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
amount: "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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-02",
|
|
|
|
|
|
reportName: "emp1-02",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 03-รายชื่อลูกจ้างประจำที่ได้รับการเสนอขอเลื่อนขั้นค่าจ้างหนึ่งขั้น
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 03-รายชื่อลูกจ้างประจำที่ได้รับการเสนอขอเลื่อนขั้นค่าจ้างหนึ่งขั้น
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-03/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_3(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
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: {
|
2024-03-22 11:31:56 +07:00
|
|
|
|
type: "FULL",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
amount: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!_salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
|
|
|
|
|
|
const fifteenPercent =
|
|
|
|
|
|
(_salaryPeriod[0].salaryOrg == null || _salaryPeriod[0].salaryOrg.fifteenPercent == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: _salaryPeriod[0].salaryOrg.fifteenPercent.toString()) +
|
|
|
|
|
|
"." +
|
|
|
|
|
|
(_salaryPeriod[0].salaryOrg == null || _salaryPeriod[0].salaryOrg.fifteenPoint == null
|
|
|
|
|
|
? "๐๐"
|
|
|
|
|
|
: _salaryPeriod[0].salaryOrg.fifteenPoint.toString());
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-22 11:31:56 +07:00
|
|
|
|
score: null,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-03",
|
|
|
|
|
|
reportName: "emp1-03",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
fifteenPercent: Extension.ToThaiNumber(fifteenPercent),
|
|
|
|
|
|
yearShort: Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year)).substr(-2),
|
|
|
|
|
|
),
|
|
|
|
|
|
yearShortOld: Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 1)).substr(-2),
|
|
|
|
|
|
),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 04-แบบ ลจ.กทม.1-รายชื่อลูกจ้างผู้สมควรได้เลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 04-แบบ ลจ.กทม.1-รายชื่อลูกจ้างผู้สมควรได้เลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-04/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_4(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
2024-03-22 11:31:56 +07:00
|
|
|
|
isNext: false,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
amount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
2024-03-21 15:29:39 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-04",
|
|
|
|
|
|
reportName: "emp1-04",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 05-แบบ ลจ.กทม.1-1-รายชื่อลูกจ้างผู้สมควรได้รับค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 05-แบบ ลจ.กทม.1-1-รายชื่อลูกจ้างผู้สมควรได้รับค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-05/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_5(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
2024-03-22 11:31:56 +07:00
|
|
|
|
isNext: true,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
amount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-03-22 11:31:56 +07:00
|
|
|
|
amountSpecial:
|
|
|
|
|
|
profile.amountSpecial > 0
|
|
|
|
|
|
? "(" + Extension.ToThaiNumber(profile.amountSpecial.toString()) + ")"
|
|
|
|
|
|
: "",
|
2024-03-21 16:34:30 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
2024-03-21 15:29:39 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-05",
|
|
|
|
|
|
reportName: "emp1-05",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 06-แบบ ลจ.กทม.2-รายชื่อลูกจ้างผู้ไม่สมควรเลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 06-แบบ ลจ.กทม.2-รายชื่อลูกจ้างผู้ไม่สมควรเลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-06/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_6(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
type: In(["NONE"]),
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
amount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reasonSign: null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
reason: null, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-06",
|
|
|
|
|
|
reportName: "emp1-06",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 07-แบบ ลจ.กทม.2-1-รายชื่อลูกจ้างผู้ไม่สมควรได้รับค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 07-แบบ ลจ.กทม.2-1-รายชื่อลูกจ้างผู้ไม่สมควรได้รับค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-07/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_7(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-22 12:32:17 +07:00
|
|
|
|
isNext: false,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
amount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reasonSign: null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
reason: null, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-07",
|
|
|
|
|
|
reportName: "emp1-07",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
// /**
|
|
|
|
|
|
// * API 08-แบบ ลจ.กทม.3-บัญชีแสดงวันลาในครึ่งปีของลูกจ้าง
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @summary 08-แบบ ลจ.กทม.3-บัญชีแสดงวันลาในครึ่งปีของลูกจ้าง
|
|
|
|
|
|
// *
|
|
|
|
|
|
// */
|
|
|
|
|
|
// @Get("emp-08/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
// async SalaryReportEmp1_8(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
// const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
// where: {
|
|
|
|
|
|
// id: salaryPeriodId,
|
|
|
|
|
|
// },
|
|
|
|
|
|
// });
|
|
|
|
|
|
// if (!salaryPeriod) {
|
|
|
|
|
|
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2024-03-21 15:29:39 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-09/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_9(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
2024-03-25 15:57:38 +07:00
|
|
|
|
period: "APR",
|
2024-03-27 16:00:02 +07:00
|
|
|
|
isActive: true,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-25 15:57:38 +07:00
|
|
|
|
|
|
|
|
|
|
const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
year: salaryPeriod.year - 1,
|
|
|
|
|
|
period: "APR",
|
2024-03-27 16:00:02 +07:00
|
|
|
|
isActive: true,
|
2024-03-25 15:57:38 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const salaryPeriodOCT = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
year: salaryPeriod.year - 1,
|
|
|
|
|
|
period: "OCT",
|
2024-03-27 16:00:02 +07:00
|
|
|
|
isActive: true,
|
2024-03-25 15:57:38 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-27 16:00:02 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
2024-03-21 15:29:39 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
2024-03-25 15:57:38 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
2024-03-27 16:00:02 +07:00
|
|
|
|
type: "NONE",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-25 15:57:38 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
2024-03-27 16:00:02 +07:00
|
|
|
|
|
2024-03-25 15:57:38 +07:00
|
|
|
|
const _salaryProfileEmpAPR = await this.salaryProfileEmployeeRepository.find({
|
2024-03-27 16:00:02 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
2024-03-25 15:57:38 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodAPR?.id,
|
2024-03-27 16:00:02 +07:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-03-25 15:57:38 +07:00
|
|
|
|
});
|
|
|
|
|
|
const _salaryProfileEmpOCT = await this.salaryProfileEmployeeRepository.find({
|
2024-03-27 16:00:02 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
2024-03-25 15:57:38 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodOCT?.id,
|
2024-03-27 16:00:02 +07:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-03-25 15:57:38 +07:00
|
|
|
|
});
|
2024-03-21 15:29:39 +07:00
|
|
|
|
|
2024-03-25 15:57:38 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
|
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
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,
|
2024-03-25 15:57:38 +07:00
|
|
|
|
position: profile.position,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-25 15:57:38 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "๐",
|
2024-03-27 16:00:02 +07:00
|
|
|
|
type1:
|
|
|
|
|
|
_salaryProfileEmpAPR.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = _salaryProfileEmpAPR
|
|
|
|
|
|
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
|
|
|
|
|
|
.map((profile) => ({
|
|
|
|
|
|
type: profile.type,
|
|
|
|
|
|
isNext: profile.isNext,
|
|
|
|
|
|
positionSalaryAmountPer: profile.positionSalaryAmountPer,
|
|
|
|
|
|
}));
|
|
|
|
|
|
if (_profile[0].isNext) {
|
|
|
|
|
|
return _profile[0].positionSalaryAmountPer === 0.02
|
|
|
|
|
|
? "๒%"
|
|
|
|
|
|
: _profile[0].positionSalaryAmountPer === 0.04
|
|
|
|
|
|
? "๔%"
|
|
|
|
|
|
: "๖%";
|
|
|
|
|
|
}
|
|
|
|
|
|
return _profile[0].type === "HALF"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0].type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
|
|
|
|
|
})()
|
|
|
|
|
|
: null, //เมษา ปีก่อนหน้า
|
|
|
|
|
|
type2:
|
|
|
|
|
|
_salaryProfileEmpOCT.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = _salaryProfileEmpOCT
|
|
|
|
|
|
.filter((profileOCT) => profileOCT.citizenId === profile.citizenId)
|
|
|
|
|
|
.map((profile) => ({
|
|
|
|
|
|
type: profile.type,
|
|
|
|
|
|
isNext: profile.isNext,
|
|
|
|
|
|
positionSalaryAmountPer: profile.positionSalaryAmountPer,
|
|
|
|
|
|
}));
|
|
|
|
|
|
if (_profile[0].isNext) {
|
|
|
|
|
|
return _profile[0].positionSalaryAmountPer === 0.02
|
|
|
|
|
|
? "๒%"
|
|
|
|
|
|
: _profile[0].positionSalaryAmountPer === 0.04
|
|
|
|
|
|
? "๔%"
|
|
|
|
|
|
: "๖%";
|
|
|
|
|
|
}
|
|
|
|
|
|
return _profile[0].type === "HALF"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0].type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
|
|
|
|
|
})()
|
|
|
|
|
|
: null, //ตุลา ปีก่อนหน้า
|
|
|
|
|
|
type:
|
|
|
|
|
|
profile.isNext === true
|
|
|
|
|
|
? profile.positionSalaryAmountPer === 0.02
|
|
|
|
|
|
? "๒%"
|
|
|
|
|
|
: profile.positionSalaryAmountPer === 0.04
|
|
|
|
|
|
? "๔%"
|
|
|
|
|
|
: "๖%"
|
|
|
|
|
|
: profile.type === "HALF"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: profile.type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ",
|
2024-03-25 15:57:38 +07:00
|
|
|
|
score: null, //ผลการประเมิน
|
|
|
|
|
|
remark: null, //หมายเหตุ
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-09",
|
|
|
|
|
|
reportName: "emp1-09",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-03-27 16:00:02 +07:00
|
|
|
|
yearBeforeSlice: Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 1)).slice(-2),
|
|
|
|
|
|
),
|
|
|
|
|
|
yearSlice: Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2),
|
|
|
|
|
|
),
|
2024-03-21 15:29:39 +07:00
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-25 15:57:38 +07:00
|
|
|
|
|
2024-04-01 17:19:32 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp-10/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp1_10(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-04-01 17:19:32 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
const salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
type: Not("NONE"),
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryProfileEmp) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
const agency = salaryProfileEmp[0] == null ? "" : salaryProfileEmp[0].root;
|
|
|
|
|
|
const formattedData = salaryProfileEmp.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,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
};
|
2024-04-01 17:19:32 +07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
|
template: "emp1-10",
|
|
|
|
|
|
reportName: "emp1-10",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-21 15:29:39 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 11-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 11-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-11/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_11(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
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) {
|
|
|
|
|
|
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,
|
|
|
|
|
|
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({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-11",
|
|
|
|
|
|
reportName: "emp1-11",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 12-บัญชีรายละเอียดผู้ได้รับอัตราค่าจ้างสูงกว่าขั้นสูง (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 12-บัญชีรายละเอียดผู้ได้รับอัตราค่าจ้างสูงกว่าขั้นสูง (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-12/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_12(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
2024-03-22 12:32:17 +07:00
|
|
|
|
isNext: false,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
remark:
|
|
|
|
|
|
`${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
|
|
|
|
|
|
`${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` +
|
|
|
|
|
|
`${profile.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
|
|
|
|
|
|
`${profile.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-12",
|
|
|
|
|
|
reportName: "emp1-12",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 13-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 13-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-13/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_13(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
type: In(["NONE"]),
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
reason: null, // หมายเหตุ
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-13",
|
|
|
|
|
|
reportName: "emp1-13",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 14-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 14-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-14/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_14(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
|
|
|
|
|
remark:
|
|
|
|
|
|
`${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
|
|
|
|
|
|
`${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` +
|
|
|
|
|
|
`${profile.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
|
|
|
|
|
|
`${profile.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-14",
|
|
|
|
|
|
reportName: "emp1-14",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 15-บัญชีรายละเอียดลูกจ้างประจำที่ได้รับค่าตอบแทนพิเศษ(แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 15-บัญชีรายละเอียดลูกจ้างประจำที่ได้รับค่าตอบแทนพิเศษ(แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-15/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_15(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-22 12:32:17 +07:00
|
|
|
|
isNext: true,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 12:32:17 +07:00
|
|
|
|
amount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
precentTwo:
|
2024-03-27 12:11:09 +07:00
|
|
|
|
profile.positionSalaryAmountPer == 0.02
|
2024-03-22 12:32:17 +07:00
|
|
|
|
? profile.positionSalaryAmount * profile.positionSalaryAmountPer
|
|
|
|
|
|
: null, //ร้อยละ 2
|
|
|
|
|
|
precentFour:
|
2024-03-27 12:11:09 +07:00
|
|
|
|
profile.positionSalaryAmountPer == 0.04
|
2024-03-22 12:32:17 +07:00
|
|
|
|
? profile.positionSalaryAmount * profile.positionSalaryAmountPer
|
|
|
|
|
|
: null, //ร้อยละ 4
|
2024-03-21 16:34:30 +07:00
|
|
|
|
reason: null, // หมายเหตุ
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-15",
|
|
|
|
|
|
reportName: "emp1-15",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 16-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 16-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-16/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_16(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-21 16:34:30 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-03-22 12:32:17 +07:00
|
|
|
|
isNext: false,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
2024-03-21 16:34:30 +07:00
|
|
|
|
positionSalaryAmount: "ASC",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
position: profile.position,
|
|
|
|
|
|
posLevel: `${profile.posTypeShort} ${profile.posLevel}`,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-21 16:34:30 +07:00
|
|
|
|
reason: null, // หมายเหตุ
|
2024-03-21 15:29:39 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-16",
|
|
|
|
|
|
reportName: "emp1-16",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 17-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 17-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-17/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_17(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
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) {
|
|
|
|
|
|
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,
|
|
|
|
|
|
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({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
template: "emp1-17",
|
|
|
|
|
|
reportName: "emp1-17",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 18-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 18-คำสั่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2024-04-01 17:19:32 +07:00
|
|
|
|
@Get("emp-18/{rootId}/{salaryPeriodId}")
|
2024-03-22 18:02:51 +07:00
|
|
|
|
async SalaryReportEmp1_18(@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.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
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,
|
|
|
|
|
|
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: "emp1-18",
|
|
|
|
|
|
reportName: "emp1-18",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 01-บัญชีการคำนวณวงเงินเลื่อนขั้นค่าจ้างลูกจ้างประจำกรุงเทพมหานคร
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 01-บัญชีการคำนวณวงเงินเลื่อนขั้นค่าจ้างลูกจ้างประจำกรุงเทพมหานคร
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-01/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_1(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-26 16:59:14 +07:00
|
|
|
|
|
|
|
|
|
|
const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
where: {
|
2024-03-26 16:59:14 +07:00
|
|
|
|
year: salaryPeriod.year,
|
|
|
|
|
|
period: "APR",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
2024-03-26 16:59:14 +07:00
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriodAPR) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนรอบเดือนเมษายน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const aprSnap2 = await this.salaryOrgEmployeeRepository.findOne({
|
|
|
|
|
|
relations: ["salaryPeriod", "salaryProfiles"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodAPR.id,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-26 16:59:14 +07:00
|
|
|
|
if (!aprSnap2) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-26 16:59:14 +07:00
|
|
|
|
const octSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
|
|
|
|
|
relations: ["salaryPeriod", "salaryProfiles"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
group: "GROUP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-26 16:59:14 +07:00
|
|
|
|
if (!octSnap1) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-26 16:59:14 +07:00
|
|
|
|
const octSnap2 = await this.salaryOrgEmployeeRepository.findOne({
|
|
|
|
|
|
relations: ["salaryPeriod", "salaryProfiles"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
group: "GROUP1",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-26 16:59:14 +07:00
|
|
|
|
if (!octSnap2) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
2024-03-27 16:00:02 +07:00
|
|
|
|
let fullHaftTotalAmount: any = 0;
|
|
|
|
|
|
let fullHaftCount: any = 0;
|
|
|
|
|
|
let fullTotalAmount: any = 0;
|
|
|
|
|
|
let fullCount: any = 0;
|
|
|
|
|
|
let haftTotalAmount: any = 0;
|
|
|
|
|
|
let haftCount: any = 0;
|
|
|
|
|
|
let noneCount: any = 0;
|
2024-03-26 16:59:14 +07:00
|
|
|
|
|
|
|
|
|
|
if (octSnap2 && octSnap2.salaryProfiles) {
|
2024-03-27 16:00:02 +07:00
|
|
|
|
octSnap2.salaryProfiles.forEach((profile: any) => {
|
2024-03-26 16:59:14 +07:00
|
|
|
|
switch (profile.type) {
|
|
|
|
|
|
case "FULLHAFT":
|
|
|
|
|
|
fullHaftTotalAmount += profile.amount ?? 0;
|
|
|
|
|
|
fullHaftCount++;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "FULL":
|
|
|
|
|
|
fullTotalAmount += profile.amount ?? 0;
|
|
|
|
|
|
fullCount++;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "HAFT":
|
|
|
|
|
|
haftTotalAmount += profile.amount ?? 0;
|
|
|
|
|
|
haftCount++;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "NONE":
|
|
|
|
|
|
noneCount++;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const emp2step = new Set();
|
|
|
|
|
|
if (octSnap2 && aprSnap2) {
|
2024-03-27 16:00:02 +07:00
|
|
|
|
octSnap2.salaryProfiles.forEach((octProfile) => {
|
|
|
|
|
|
aprSnap2.salaryProfiles.forEach((aprProfile) => {
|
|
|
|
|
|
if (
|
|
|
|
|
|
octProfile.citizenId === aprProfile.citizenId &&
|
|
|
|
|
|
((octProfile.type === "FULL" && aprProfile.type === "FULL") ||
|
|
|
|
|
|
(octProfile.type === "HAFT" && aprProfile.type === "FULLHAFT") ||
|
|
|
|
|
|
(octProfile.type === "FULLHAFT" && aprProfile.type === "HAFT"))
|
|
|
|
|
|
) {
|
|
|
|
|
|
emp2step.add(octProfile.citizenId);
|
|
|
|
|
|
}
|
2024-03-26 16:59:14 +07:00
|
|
|
|
});
|
2024-03-27 16:00:02 +07:00
|
|
|
|
});
|
2024-03-26 16:59:14 +07:00
|
|
|
|
}
|
2024-03-27 16:00:02 +07:00
|
|
|
|
const totalEmp2step = emp2step.size ?? 0;
|
2024-03-26 16:59:14 +07:00
|
|
|
|
|
|
|
|
|
|
const agency = octSnap1.salaryProfiles[0] == null ? "" : octSnap1.salaryProfiles[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return new HttpSuccess({
|
2024-03-26 16:59:14 +07:00
|
|
|
|
template: "emp2-01",
|
|
|
|
|
|
reportName: "emp2-01",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-03-27 16:00:02 +07:00
|
|
|
|
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(
|
|
|
|
|
|
-2,
|
|
|
|
|
|
),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
agency: agency,
|
2024-03-26 16:59:14 +07:00
|
|
|
|
totalUser: octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.total.toString()),
|
2024-03-27 16:00:02 +07:00
|
|
|
|
totalSalary:
|
|
|
|
|
|
octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.currentAmount.toString()),
|
|
|
|
|
|
sixPercent:
|
|
|
|
|
|
octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.sixPercentAmount.toString()),
|
|
|
|
|
|
remainingAmountApr:
|
|
|
|
|
|
aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.useAmount.toString()), //จำนวนเงินที่ใช้เลื่อนขั้นค่าจ้างไปแล้วในวันที่ 1 เม.ย.
|
|
|
|
|
|
remainingAmountOct:
|
|
|
|
|
|
octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.spentAmount.toString()), //เหลือเงินใช้เลื่อนขั้นค่าจ้างในวันที่ 1 ต.ค.
|
2024-03-26 16:59:14 +07:00
|
|
|
|
totalOld: aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.total.toString()), //จำนวน(คน)(โควตาเลื่อนขั้นค่าจ้าง)
|
2024-03-27 16:00:02 +07:00
|
|
|
|
fifteenPercentOld:
|
|
|
|
|
|
aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.fifteenPercent.toString()),
|
|
|
|
|
|
totalUseOld:
|
|
|
|
|
|
aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.quantityUsed.toString()), //พิจารณาให้(คน)(โควตาเลื่อนขั้นค่าจ้าง)
|
|
|
|
|
|
full2: totalEmp2step == null ? "" : Extension.ToThaiNumber(totalEmp2step.toString()), //เลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้นจำนวน(คน)
|
|
|
|
|
|
fullHaft: fullHaftCount == null ? "" : Extension.ToThaiNumber(fullHaftCount.toString()), //จำนวน(คน)(หนึ่งขั้นครึ่ง)
|
|
|
|
|
|
fullHaftSalary:
|
|
|
|
|
|
fullHaftTotalAmount == null ? "" : Extension.ToThaiNumber(fullHaftTotalAmount.toString()), //ใช้เงิน(หนึ่งขั้นครึ่ง)
|
|
|
|
|
|
full: fullCount == null ? "" : Extension.ToThaiNumber(fullCount.toString()), //จำนวน(คน)(หนึ่งขั้น)
|
|
|
|
|
|
fullSalary:
|
|
|
|
|
|
fullTotalAmount == null ? "" : Extension.ToThaiNumber(fullTotalAmount.toString()), //ใช้เงิน(หนึ่งขั้น)
|
|
|
|
|
|
haft: haftCount == null ? "" : Extension.ToThaiNumber(haftCount.toString()), //จำนวน(คน)(ครึ่งขั้น)
|
|
|
|
|
|
haftSalary:
|
|
|
|
|
|
haftTotalAmount == null ? "" : Extension.ToThaiNumber(haftTotalAmount.toString()), //ใช้เงิน(ครึ่งขั้น)
|
|
|
|
|
|
notPromoted: noneCount == null ? "" : Extension.ToThaiNumber(noneCount.toString()), //ไม่ได้เลื่อนขั้นค่าจ้างจำนวน(คน)
|
2024-03-26 16:59:14 +07:00
|
|
|
|
total: octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.useAmount.toString()), //รวมใช้เงิน
|
2024-03-27 16:00:02 +07:00
|
|
|
|
summary:
|
|
|
|
|
|
octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.remainingAmount.toString()), //เหลือเงิน
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 02-รายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ครองตำแหน่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 02-รายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ครองตำแหน่ง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-02/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_2(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
2024-03-27 16:00:02 +07:00
|
|
|
|
period: "OCT",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-27 16:00:02 +07:00
|
|
|
|
|
|
|
|
|
|
const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod?.year,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriodAPR) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const salaryPeriodAPRProfile = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodAPR?.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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-04-05 14:22:26 +07:00
|
|
|
|
|
|
|
|
|
|
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
|
2024-03-27 16:00:02 +07:00
|
|
|
|
if (octPreviousYear) {
|
2024-04-05 14:22:26 +07:00
|
|
|
|
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: octPreviousYear?.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-27 16:00:02 +07:00
|
|
|
|
}
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
|
|
|
|
|
let octPreviousYearProfile2: SalaryProfileEmployee[] = [];
|
2024-03-27 16:00:02 +07:00
|
|
|
|
if (octPreviousYear2) {
|
2024-04-05 14:22:26 +07:00
|
|
|
|
octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
salaryPeriodId: octPreviousYear2?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-27 16:00:02 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-26 16:59:14 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
2024-03-27 16:00:02 +07:00
|
|
|
|
const formattedData = _salaryPeriod.map((profile: any, index: number) => {
|
|
|
|
|
|
if (!profile) {
|
2024-04-05 14:22:26 +07:00
|
|
|
|
return null;
|
2024-03-27 16:00:02 +07:00
|
|
|
|
}
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-26 16:59:14 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
yearOld2:
|
|
|
|
|
|
octPreviousYear2 == null
|
|
|
|
|
|
? null
|
|
|
|
|
|
: Extension.ToThaiNumber(octPreviousYear2.year.toString()),
|
2024-03-27 16:00:02 +07:00
|
|
|
|
typeOld2:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
octPreviousYear2 && octPreviousYearProfile2.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = octPreviousYearProfile2.filter(
|
|
|
|
|
|
(profileOCT2) => profileOCT2.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
2024-03-27 16:00:02 +07:00
|
|
|
|
if (_profile.length > 0) {
|
2024-03-28 10:26:34 +07:00
|
|
|
|
return _profile[0]?.type === "HAFT"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
2024-03-27 16:00:02 +07:00
|
|
|
|
? "๑ ขั้น"
|
2024-03-28 10:26:34 +07:00
|
|
|
|
: profile?.type === "FULLHAFT"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
2024-03-27 16:00:02 +07:00
|
|
|
|
}
|
|
|
|
|
|
return null;
|
2024-04-05 14:22:26 +07:00
|
|
|
|
})()
|
2024-03-27 16:00:02 +07:00
|
|
|
|
: null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
yearOld:
|
|
|
|
|
|
octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()),
|
2024-03-27 16:00:02 +07:00
|
|
|
|
typeOld1:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
octPreviousYear && octPreviousYearProfile.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = octPreviousYearProfile.filter(
|
|
|
|
|
|
(profileOCT) => profileOCT.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
2024-03-27 16:00:02 +07:00
|
|
|
|
if (_profile.length > 0) {
|
2024-04-05 14:22:26 +07:00
|
|
|
|
return _profile[0]?.type === "HAFT"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile?.type === "FULLHAFT"
|
2024-03-27 16:00:02 +07:00
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
2024-04-05 14:22:26 +07:00
|
|
|
|
})()
|
2024-03-27 16:00:02 +07:00
|
|
|
|
: null,
|
|
|
|
|
|
typeOld:
|
|
|
|
|
|
salaryPeriodAPRProfile.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = salaryPeriodAPRProfile
|
|
|
|
|
|
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
|
|
|
|
|
|
.map((profile) => ({
|
|
|
|
|
|
type: profile.type,
|
|
|
|
|
|
}));
|
2024-04-05 14:22:26 +07:00
|
|
|
|
return _profile[0]?.type === "HAFT"
|
2024-03-27 16:00:02 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile?.type === "FULLHAFT"
|
|
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
2024-03-27 16:00:02 +07:00
|
|
|
|
})()
|
|
|
|
|
|
: null, //เมษา ปีเดียวกัน
|
|
|
|
|
|
type:
|
2024-03-28 10:26:34 +07:00
|
|
|
|
profile.type === "HAFT"
|
2024-03-27 16:00:02 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: profile.type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
2024-03-28 10:26:34 +07:00
|
|
|
|
: profile.type === "FULLHAFT"
|
2024-03-27 16:00:02 +07:00
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ", //หน่วยงานพิจารณาเลื่อนขั้นค่าจ้าง 1 ต.ค. (จำนวนขั้น)
|
2024-03-22 18:02:51 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-26 16:59:14 +07:00
|
|
|
|
template: "emp2-02",
|
|
|
|
|
|
reportName: "emp2-02",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 03-รายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ได้รับการเสนอขอเลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้น
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 03-รายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ได้รับการเสนอขอเลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้น
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-03/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_3(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
2024-03-29 14:09:42 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const fifteenPoint = await this.salaryOrgEmployeeRepository.findOne({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
where: {
|
2024-03-29 11:27:56 +07:00
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
rootId: rootId,
|
2024-03-29 14:09:42 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
2024-03-29 14:09:42 +07:00
|
|
|
|
});
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const fifteenPercentData =
|
2024-03-29 14:09:42 +07:00
|
|
|
|
fifteenPoint?.fifteenPercent == undefined || fifteenPoint?.fifteenPercent == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: Extension.ToThaiNumber(String(fifteenPoint?.fifteenPercent));
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
|
|
|
|
|
const fifteenPointData =
|
|
|
|
|
|
fifteenPoint?.fifteenPoint == undefined || fifteenPoint?.fifteenPoint == null
|
|
|
|
|
|
? ".๐๐"
|
|
|
|
|
|
: "." + Extension.ToThaiNumber(String(fifteenPoint?.fifteenPoint));
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
const _salaryProfileEmployee = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
type: Not("NONE"),
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
if (!_salaryProfileEmployee) {
|
2024-03-29 11:27:56 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
const aprSalaryPeriodCurrent = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod.year,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-29 14:09:42 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const octPreviousYear = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod?.year - 1,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
2024-03-29 11:27:56 +07:00
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
const aprPreviousYear2 = await this.salaryPeriodRepository.findOne({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
where: {
|
2024-03-29 14:09:42 +07:00
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriod?.year - 1,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-29 14:09:42 +07:00
|
|
|
|
|
|
|
|
|
|
let aprPreviousYearProfileCurrent: SalaryProfileEmployee[] = [];
|
|
|
|
|
|
if (aprSalaryPeriodCurrent) {
|
|
|
|
|
|
aprPreviousYearProfileCurrent = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
type: Not("NONE"),
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: aprSalaryPeriodCurrent?.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
|
|
|
|
|
|
if (octPreviousYear) {
|
|
|
|
|
|
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
2024-03-29 14:09:42 +07:00
|
|
|
|
type: Not("NONE"),
|
2024-03-29 11:27:56 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: octPreviousYear?.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
let aprPreviousYearProfile2: SalaryProfileEmployee[] = [];
|
|
|
|
|
|
if (aprPreviousYear2) {
|
|
|
|
|
|
aprPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
2024-03-29 14:09:42 +07:00
|
|
|
|
type: Not("NONE"),
|
2024-03-29 11:27:56 +07:00
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
2024-03-29 14:09:42 +07:00
|
|
|
|
salaryPeriodId: aprPreviousYear2?.id,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 18:02:51 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
const agency = _salaryProfileEmployee[0] == null ? "" : _salaryProfileEmployee[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-29 14:09:42 +07:00
|
|
|
|
const formattedData = _salaryProfileEmployee.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
//เมษา ปีก่อนหน้า
|
|
|
|
|
|
typeOld2:
|
|
|
|
|
|
aprPreviousYear2 && aprPreviousYearProfile2.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = aprPreviousYearProfile2.filter(
|
|
|
|
|
|
(profileAPR2) => profileAPR2.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
|
|
|
|
|
if (_profile.length > 0) {
|
|
|
|
|
|
return _profile[0]?.type === "HAFT"
|
2024-03-29 11:27:56 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile?.type === "FULLHAFT"
|
|
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
})()
|
|
|
|
|
|
: null,
|
2024-03-29 14:09:42 +07:00
|
|
|
|
yearOld:
|
|
|
|
|
|
octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()),
|
2024-04-05 14:22:26 +07:00
|
|
|
|
//ตุลา ปีก่อนหน้า
|
|
|
|
|
|
typeOld1:
|
|
|
|
|
|
octPreviousYear && octPreviousYearProfile.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = octPreviousYearProfile.filter(
|
|
|
|
|
|
(profileOCT) => profileOCT.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
2024-03-29 14:09:42 +07:00
|
|
|
|
if (_profile.length > 0) {
|
2024-04-05 14:22:26 +07:00
|
|
|
|
return _profile[0]?.type === "HAFT"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile?.type === "FULLHAFT"
|
2024-03-29 14:09:42 +07:00
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
2024-04-05 14:22:26 +07:00
|
|
|
|
})()
|
2024-03-29 14:09:42 +07:00
|
|
|
|
: null,
|
|
|
|
|
|
typeOld:
|
|
|
|
|
|
aprPreviousYearProfileCurrent.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = aprPreviousYearProfileCurrent
|
|
|
|
|
|
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
|
|
|
|
|
|
.map((profile) => ({
|
|
|
|
|
|
type: profile.type,
|
|
|
|
|
|
}));
|
2024-04-05 14:22:26 +07:00
|
|
|
|
return _profile[0]?.type === "HAFT"
|
2024-03-29 14:09:42 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile?.type === "FULLHAFT"
|
|
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
2024-03-29 14:09:42 +07:00
|
|
|
|
})()
|
2024-04-05 14:22:26 +07:00
|
|
|
|
: null, //เมษา
|
2024-03-29 14:09:42 +07:00
|
|
|
|
type:
|
|
|
|
|
|
profile.type === "HAFT"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: profile.type === "FULL"
|
|
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile.type === "FULLHAFT"
|
|
|
|
|
|
? "๑.๕ ขั้น"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ",
|
2024-03-29 14:09:42 +07:00
|
|
|
|
score1: null,
|
|
|
|
|
|
score2: null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
};
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
template: "emp2-03",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reportName: "emp2-03",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-04-05 14:22:26 +07:00
|
|
|
|
yearOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year - 1))),
|
|
|
|
|
|
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(
|
|
|
|
|
|
-2,
|
|
|
|
|
|
),
|
|
|
|
|
|
yearShortOld: Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
|
|
|
|
|
|
).slice(-2),
|
2024-03-29 11:27:56 +07:00
|
|
|
|
fifteenPercent: fifteenPercentData + fifteenPointData,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 04-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้สมควรได้เลื่อนขั้นค่าจ้าง (แบบ ลจ.กทม.1)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 04-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้สมควรได้เลื่อนขั้นค่าจ้าง (แบบ ลจ.กทม.1)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-04/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_4(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
type: Not("NONE"),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
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),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
score: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
template: "emp2-04",
|
|
|
|
|
|
reportName: "emp2-04",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 05-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้สมควรได้รับค่าตอบแทนพิเศษ (แบบ ลจ.กทม.1/1)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 05-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้สมควรได้รับค่าตอบแทนพิเศษ (แบบ ลจ.กทม.1/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, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
amountSpecial: Not(IsNull()),
|
|
|
|
|
|
type: Not("NONE"),
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
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,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
template: "emp2-05",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reportName: "emp2-05",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 06-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่สมควรเลื่อนขั้นค่าจ้าง (แบบ ลจ.กทม.2)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 06-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่สมควรเลื่อนขั้นค่าจ้าง (แบบ ลจ.กทม.2)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-06/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_6(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
type: "NONE",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
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),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
score: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
template: "emp2-06",
|
|
|
|
|
|
reportName: "emp2-06",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
type: "NONE",
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
|
|
|
|
|
reason: null,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
score: null,
|
|
|
|
|
|
signature: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
template: "emp2-07",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reportName: "emp2-07",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 08-บัญชีแสดงวันลาในครึ่งปีที่แล้วมาของลูกจ้างประจำกรุงเทพมหานคร (แบบ ลจ.กทม.3)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 08-บัญชีแสดงวันลาในครึ่งปีที่แล้วมาของลูกจ้างประจำกรุงเทพมหานคร (แบบ ลจ.กทม.3)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-08/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_8(@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.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
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,
|
|
|
|
|
|
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",
|
|
|
|
|
|
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, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
isRetired: true,
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
if (!_salaryPeriodTarget) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const octPreviousYear = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod?.year - 1,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
2024-03-29 11:27:56 +07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const octPreviousYear2 = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriod?.year - 2,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
let octPreviousYearProfile: SalaryProfileEmployee[] = [];
|
|
|
|
|
|
if (octPreviousYear) {
|
|
|
|
|
|
octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
isRetired: true,
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: octPreviousYear?.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-22 18:02:51 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
let octPreviousYearProfile2: SalaryProfileEmployee[] = [];
|
|
|
|
|
|
if (octPreviousYear2) {
|
|
|
|
|
|
octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
isRetired: true,
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
salaryPeriodId: octPreviousYear2?.id,
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root;
|
|
|
|
|
|
|
|
|
|
|
|
const formattedData = _salaryPeriodTarget.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
typeOld2:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
octPreviousYear2 && octPreviousYearProfile2.length > 0
|
|
|
|
|
|
? (() => {
|
|
|
|
|
|
const _profile = octPreviousYearProfile2.filter(
|
|
|
|
|
|
(profileOCT2) => profileOCT2.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
|
|
|
|
|
if (_profile.length > 0) {
|
|
|
|
|
|
return _profile[0]?.type === "HAFT"
|
2024-03-29 11:27:56 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: 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"
|
2024-03-29 11:27:56 +07:00
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: _profile[0]?.type === "FULL"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: 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"
|
2024-03-29 11:27:56 +07:00
|
|
|
|
? "๑ ขั้น"
|
|
|
|
|
|
: profile?.type === "FULLHAFT"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ";
|
|
|
|
|
|
})()
|
|
|
|
|
|
: null, //เมษา ปีเดียวกัน
|
|
|
|
|
|
type:
|
|
|
|
|
|
profile.type === "HAFT"
|
|
|
|
|
|
? "๐.๕ ขั้น"
|
|
|
|
|
|
: profile.type === "FULL"
|
2024-03-29 11:27:56 +07:00
|
|
|
|
? "๑ ขั้น"
|
2024-04-05 14:22:26 +07:00
|
|
|
|
: profile.type === "FULLHAFT"
|
|
|
|
|
|
? "๑.๕ ขั้น"
|
|
|
|
|
|
: "ไม่ได้เลื่อนขั้นฯ",
|
|
|
|
|
|
score1: null,
|
|
|
|
|
|
score2: null,
|
|
|
|
|
|
reason: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
template: "emp2-09",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reportName: "emp2-09",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
2024-04-05 14:22:26 +07:00
|
|
|
|
yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(
|
|
|
|
|
|
-2,
|
|
|
|
|
|
),
|
|
|
|
|
|
yearShortOld: Extension.ToThaiNumber(
|
|
|
|
|
|
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
|
|
|
|
|
|
).slice(-2),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 10-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง/ค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 10-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง/ค่าตอบแทนพิเศษ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-10/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_10(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
type: "NONE",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
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),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
reason1: null, //เหตุผลที่ไม่ได้เลื่อนขั้น
|
|
|
|
|
|
reason2: null, //เหตุผลที่ไม่ได้เลื่อนขั้น
|
|
|
|
|
|
reason3: null, //เหตุผลที่ไม่ได้เลื่อนขั้น
|
|
|
|
|
|
score: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
|
2024-04-05 14:22:26 +07:00
|
|
|
|
const yearOld = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year - 1)));
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return new HttpSuccess({
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
template: "emp2-10",
|
|
|
|
|
|
reportName: "emp2-10",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
year: year,
|
|
|
|
|
|
yearSlice: year.slice(-2),
|
|
|
|
|
|
yearOldSlice: yearOld.slice(-2),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 11-รายชื่อลูกจ้างประจำผู้มีผลการประเมินประสิทธิภาพและประสิทธิผลการปฏิบัติงานอยู่ในระดับดีเด่น
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 11-รายชื่อลูกจ้างประจำผู้มีผลการประเมินประสิทธิภาพและประสิทธิผลการปฏิบัติงานอยู่ในระดับดีเด่น
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-11/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_11(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
type: Not("NONE"),
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 17:35:28 +07:00
|
|
|
|
template: "emp2-11",
|
|
|
|
|
|
reportName: "emp2-11",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 12-คำสั่งเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับที่เกษียณอายุราชการ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 12-คำสั่งเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับที่เกษียณอายุราชการ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-12/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_12(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const salaryOrg = await this.salaryOrgEmployeeRepository.findOne({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
where: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!salaryOrg) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
template: "emp2-12",
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
reportName: "emp2-12",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 13-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ ที่เกษียณอายุราชการ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 13-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ ที่เกษียณอายุราชการ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-13/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_13(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const salaryProfile = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
isRetired: true,
|
|
|
|
|
|
isNext: true,
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryProfile) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const formattedData = salaryProfile.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return new HttpSuccess({
|
2024-03-29 17:35:28 +07:00
|
|
|
|
template: "emp2-13",
|
|
|
|
|
|
reportName: "emp2-13",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 14-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่ได้รับการเลื่อนขั้นค่าจ้างที่เกษียณอายุราชการ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 14-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่ได้รับการเลื่อนขั้นค่าจ้างที่เกษียณอายุราชการ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-14/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_14(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
type: "NONE",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isRetired: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
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),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
template: "emp2-14",
|
|
|
|
|
|
reportName: "emp2-14",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
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, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
isRetired: true,
|
|
|
|
|
|
type: "NONE",
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
template: "emp2-15",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reportName: "emp2-15",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 16-คำสั่งเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 16-คำสั่งเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-16/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_16(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const salaryOrg = await this.salaryOrgEmployeeRepository.findOne({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
where: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!salaryOrg) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
template: "emp2-16",
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
reportName: "emp2-16",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 17-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 17-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-17/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_17(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const salaryProfile = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
isNext: true,
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryProfile) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const formattedData = salaryProfile.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
return new HttpSuccess({
|
2024-03-29 17:35:28 +07:00
|
|
|
|
template: "emp2-17",
|
|
|
|
|
|
reportName: "emp2-17",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 18-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 18-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-18/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_18(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
type: "NONE",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isRetired: false,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
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),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
|
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
template: "emp2-18",
|
|
|
|
|
|
reportName: "emp2-18",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 20-บัญชีรายละเอียดให้ลูกจ้างประจำกรุงเทพมหานครได้รับค่าตอบแทนพิเศษ (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 20-บัญชีรายละเอียดให้ลูกจ้างประจำกรุงเทพมหานครได้รับค่าตอบแทนพิเศษ (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-20/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_20(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!_salaryProfileEmp) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
|
2024-03-22 18:02:51 +07:00
|
|
|
|
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const formattedData = _salaryProfileEmp.map((profile, index) => {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
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),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
|
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
|
|
|
|
|
precentTwo:
|
|
|
|
|
|
profile.positionSalaryAmount == 0.02
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString())
|
|
|
|
|
|
: null, //ร้อยละ 2
|
|
|
|
|
|
precentFour:
|
|
|
|
|
|
profile.positionSalaryAmount == 0.04
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString())
|
|
|
|
|
|
: null, //ร้อยละ 4
|
|
|
|
|
|
precentSix:
|
|
|
|
|
|
profile.positionSalaryAmount == 0.06
|
2024-04-05 14:22:26 +07:00
|
|
|
|
? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString())
|
|
|
|
|
|
: null, //ร้อยละ 6
|
2024-03-22 18:02:51 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
template: "emp2-20",
|
|
|
|
|
|
reportName: "emp2-20",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* 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, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 11:27:56 +07:00
|
|
|
|
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
type: "NONE",
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
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,
|
2024-03-29 11:27:56 +07:00
|
|
|
|
position: profile.position,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-22 18:02:51 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
|
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-03-29 11:27:56 +07:00
|
|
|
|
template: "emp2-21",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
reportName: "emp2-21",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 22-คำสั่งแก้ไขคำสั่งเลื่อนขั้นค่าจ้างลูกจ้างประจำกรุงเทพมหานคร (เฉพาะราย)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 22-คำสั่งแก้ไขคำสั่งเลื่อนขั้นค่าจ้างลูกจ้างประจำกรุงเทพมหานคร (เฉพาะราย)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-22/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_22(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const salaryOrg = await this.salaryOrgEmployeeRepository.findOne({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
where: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!salaryOrg) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
template: "emp2-22",
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
reportName: "emp2-22",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 23-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 23-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ (แนบท้ายคำสั่ง)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-23/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_23(@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.salaryProfileRepository.find({
|
|
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP1",
|
|
|
|
|
|
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,
|
|
|
|
|
|
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",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
|
|
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* API 24-คำสั่งยกเลิกคำสั่งเลื่อนขั้นค่าจ้างลูกจ้างประจำกรุงเทพมหานคร (เฉพาะราย)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 24-คำสั่งยกเลิกคำสั่งเลื่อนขั้นค่าจ้างลูกจ้างประจำกรุงเทพมหานคร (เฉพาะราย)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-24/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_24(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
|
|
|
|
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
|
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
period: "OCT",
|
2024-04-05 14:22:26 +07:00
|
|
|
|
isActive: true,
|
2024-03-22 18:02:51 +07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!salaryPeriod) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
const salaryOrg = await this.salaryOrgEmployeeRepository.findOne({
|
2024-03-22 18:02:51 +07:00
|
|
|
|
where: {
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
rootId: rootId,
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
if (!salaryOrg) {
|
2024-03-22 18:02:51 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
template: "blank",
|
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
|
|
|
|
reportName: "emp2-24",
|
2024-03-22 18:02:51 +07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-29 11:27:56 +07:00
|
|
|
|
|
2024-03-22 18:02:51 +07:00
|
|
|
|
/**
|
|
|
|
|
|
* API 25-แบบฟอร์มบัญชีถือจ่ายอัตราค่าจ้างลูกจ้างประจำกรุงเทพมหานคร
|
|
|
|
|
|
*
|
|
|
|
|
|
* @summary 25-แบบฟอร์มบัญชีถือจ่ายอัตราค่าจ้างลูกจ้างประจำกรุงเทพมหานคร
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Get("emp2-25/{rootId}/{salaryPeriodId}")
|
|
|
|
|
|
async SalaryReportEmp2_25(@Path() rootId: string, @Path() salaryPeriodId: string) {
|
2024-03-29 17:35:28 +07:00
|
|
|
|
//งวดปีปัจจุบัน
|
|
|
|
|
|
const salaryPeriodOCT = await this.salaryPeriodRepository.findOne({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
id: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryPeriodOCT) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
|
|
|
|
|
}
|
2024-03-29 17:35:28 +07:00
|
|
|
|
|
|
|
|
|
|
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({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
period: "APR",
|
|
|
|
|
|
year: salaryPeriodOCT.year - 1,
|
|
|
|
|
|
},
|
2024-03-29 17:35:28 +07:00
|
|
|
|
});
|
|
|
|
|
|
if (!perviousYearAPR) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const perviousYearOCT = await this.salaryPeriodRepository.findOne({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
where: {
|
|
|
|
|
|
period: "OCT",
|
|
|
|
|
|
year: salaryPeriodOCT.year - 1,
|
|
|
|
|
|
},
|
2024-03-29 17:35:28 +07:00
|
|
|
|
});
|
|
|
|
|
|
if (!perviousYearOCT) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ปีก่อนหน้า
|
|
|
|
|
|
const salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
salaryPeriodId: perviousYearAPR.id,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryProfilePerviousAPR) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
salaryPeriodId: perviousYearOCT.id,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryProfilePerviousOCT) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ปีปัจุบัน
|
|
|
|
|
|
const salaryProfileCurrentAPR = await this.salaryProfileEmployeeRepository.find({
|
2024-03-21 15:29:39 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
2024-04-05 14:22:26 +07:00
|
|
|
|
salaryOrg: {
|
2024-03-29 17:35:28 +07:00
|
|
|
|
snapshot: "SNAP2",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryProfileCurrentAPR) {
|
2024-03-21 15:29:39 +07:00
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const salaryProfileCurrentOCT = await this.salaryProfileEmployeeRepository.find({
|
2024-04-05 14:22:26 +07:00
|
|
|
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
|
|
|
|
|
where: {
|
|
|
|
|
|
salaryOrg: {
|
|
|
|
|
|
snapshot: "SNAP2",
|
|
|
|
|
|
salaryPeriodId: salaryPeriodId,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
},
|
|
|
|
|
|
order: {
|
|
|
|
|
|
orgShortName: "ASC",
|
|
|
|
|
|
posMasterNo: "ASC",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
if (!salaryProfileCurrentOCT) {
|
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const agency = salaryProfileCurrentOCT[0] == null ? "" : salaryProfileCurrentOCT[0].root;
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const formattedData = salaryProfileCurrentOCT.map((profile, index) => {
|
|
|
|
|
|
//งวดปีก่อนหน้า
|
2024-04-05 14:22:26 +07:00
|
|
|
|
const matchedAPRProfileOld = salaryProfilePerviousAPR.find(
|
|
|
|
|
|
(aprProfile_old) => aprProfile_old.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
|
|
|
|
|
const matchedOCTProfileOld = salaryProfilePerviousOCT.find(
|
|
|
|
|
|
(octProfile_old) => octProfile_old.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const amountUseAPR_Old = matchedAPRProfileOld ? matchedAPRProfileOld.amountUse : 0;
|
|
|
|
|
|
const amountUseOCT_Old = matchedOCTProfileOld ? matchedOCTProfileOld.amountUse : 0;
|
|
|
|
|
|
const amountUseOld = amountUseAPR_Old + amountUseOCT_Old;
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-29 17:35:28 +07:00
|
|
|
|
//งวดปีปัจจุบัน
|
2024-04-05 14:22:26 +07:00
|
|
|
|
const matchedAPRProfile = salaryProfileCurrentAPR.find(
|
|
|
|
|
|
(aprProfile) => aprProfile.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
|
|
|
|
|
const matchedOCTProfile = salaryProfileCurrentOCT.find(
|
|
|
|
|
|
(octProfile) => octProfile.citizenId === profile.citizenId,
|
|
|
|
|
|
);
|
2024-03-29 17:35:28 +07:00
|
|
|
|
const amountUseAPR = matchedAPRProfile ? matchedAPRProfile.amountUse : 0;
|
|
|
|
|
|
const amountUseOCT = matchedOCTProfile ? matchedOCTProfile.amountUse : 0;
|
|
|
|
|
|
const amountUse = amountUseAPR + amountUseOCT;
|
2024-03-21 15:29:39 +07:00
|
|
|
|
|
|
|
|
|
|
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,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
position: profile.position,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
posLevel: profile.posLevel,
|
|
|
|
|
|
posNumber:
|
2024-04-05 14:22:26 +07:00
|
|
|
|
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
|
2024-03-21 15:29:39 +07:00
|
|
|
|
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
|
2024-04-05 14:22:26 +07:00
|
|
|
|
positionSalaryAmount: profile.positionSalaryAmount
|
|
|
|
|
|
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
|
|
|
|
|
|
: null,
|
2024-03-29 17:35:28 +07:00
|
|
|
|
amountUseOld: amountUseOld ? Extension.ToThaiNumber(amountUseOld.toLocaleString()) : null,
|
|
|
|
|
|
amountUse: amountUse ? Extension.ToThaiNumber(amountUse.toLocaleString()) : null,
|
2024-03-21 15:29:39 +07:00
|
|
|
|
reason: null,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
2024-04-05 14:22:26 +07:00
|
|
|
|
|
2024-03-21 15:29:39 +07:00
|
|
|
|
return new HttpSuccess({
|
2024-03-29 17:35:28 +07:00
|
|
|
|
template: "emp2-25",
|
|
|
|
|
|
reportName: "emp2-25",
|
2024-03-21 15:29:39 +07:00
|
|
|
|
data: {
|
2024-03-29 17:35:28 +07:00
|
|
|
|
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriodOCT.year))),
|
2024-03-21 15:29:39 +07:00
|
|
|
|
agency: agency,
|
|
|
|
|
|
data: formattedData,
|
|
|
|
|
|
},
|
2024-04-05 14:22:26 +07:00
|
|
|
|
});
|
2024-03-21 15:29:39 +07:00
|
|
|
|
}
|
2024-02-19 15:23:03 +07:00
|
|
|
|
}
|