เงินเดือนลูกจ้าง
This commit is contained in:
parent
6950954268
commit
fa79bb5b7a
8 changed files with 2893 additions and 270 deletions
|
|
@ -113,7 +113,11 @@ export class Report2Controller extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("report2/{rootId}/{salaryPeriodId}/{salaryOrgId}")
|
||||
async SalaryReport2(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() salaryOrgId: string) {
|
||||
async SalaryReport2(
|
||||
@Path() rootId: string,
|
||||
@Path() salaryPeriodId: string,
|
||||
@Path() salaryOrgId: string,
|
||||
) {
|
||||
// const counts = await AppDataSource.getRepository(SalaryProfile)
|
||||
// .createQueryBuilder("salaryProfile")
|
||||
// .leftJoin("salaryProfile.salaryOrg", "salaryOrg")
|
||||
|
|
@ -243,35 +247,38 @@ export class Report2Controller extends Controller {
|
|||
// },
|
||||
// select: ["posType", "posLevel"],
|
||||
// });
|
||||
|
||||
const statistics = await this.salaryProfileRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg: {
|
||||
id:salaryOrgId,
|
||||
snapshot: "SNAP1",
|
||||
group: "GROUP2",
|
||||
rootId: rootId,
|
||||
salaryPeriod: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
},
|
||||
|
||||
const statistics = await this.salaryProfileRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg: {
|
||||
id: salaryOrgId,
|
||||
snapshot: "SNAP1",
|
||||
group: "GROUP2",
|
||||
rootId: rootId,
|
||||
salaryPeriod: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const notPromoSum = (statistics[0]?.salaryOrg?.total ?? 0) - (statistics[0]?.salaryOrg?.fifteenPercent ?? 0);
|
||||
const haftCount = statistics?.filter(item => item.type === "HAFT").length ?? 0;
|
||||
const data = {
|
||||
group: statistics[0]?.salaryOrg.total?"กลุ่ม 2":"",
|
||||
total: statistics[0]?.salaryOrg.total?statistics[0]?.salaryOrg.total:"",
|
||||
fifteenPercent: statistics[0]?.salaryOrg.fifteenPercent?statistics[0]?.salaryOrg.fifteenPercent:"",
|
||||
full: statistics[0]?.salaryOrg.quantityUsed?statistics[0]?.salaryOrg.quantityUsed:"",
|
||||
remaining: statistics[0]?.salaryOrg.remainQuota?statistics[0]?.salaryOrg.remainQuota:"",
|
||||
haft: haftCount,
|
||||
notPromoted: notPromoSum,
|
||||
reason: null,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const notPromoSum =
|
||||
(statistics[0]?.salaryOrg?.total ?? 0) - (statistics[0]?.salaryOrg?.fifteenPercent ?? 0);
|
||||
const haftCount = statistics?.filter((item) => item.type === "HAFT").length ?? 0;
|
||||
const data = {
|
||||
group: statistics[0]?.salaryOrg.total ? "กลุ่ม 2" : "",
|
||||
total: statistics[0]?.salaryOrg.total ? statistics[0]?.salaryOrg.total : "",
|
||||
fifteenPercent: statistics[0]?.salaryOrg.fifteenPercent
|
||||
? statistics[0]?.salaryOrg.fifteenPercent
|
||||
: "",
|
||||
full: statistics[0]?.salaryOrg.quantityUsed ? statistics[0]?.salaryOrg.quantityUsed : "",
|
||||
remaining: statistics[0]?.salaryOrg.remainQuota ? statistics[0]?.salaryOrg.remainQuota : "",
|
||||
haft: haftCount,
|
||||
notPromoted: notPromoSum,
|
||||
reason: null,
|
||||
};
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import { In, IsNull, Not, MoreThan } from "typeorm";
|
|||
import { SalaryProfile } from "../entities/SalaryProfile";
|
||||
import { SalaryPeriod } from "../entities/SalaryPeriod";
|
||||
import { SalaryOrg } from "../entities/SalaryOrg";
|
||||
import Extension from "../interfaces/extension";
|
||||
import Extension from "../interfaces/extension";
|
||||
|
||||
@Route("api/v1/salary/report/1")
|
||||
@Tags("Report")
|
||||
|
|
@ -43,213 +43,258 @@ export class Report_1_Controller extends Controller {
|
|||
* API รายงานแบบ 1 กท รอบเมษายน
|
||||
*
|
||||
* @summary รายงานแบบ 1 กท รอบเมษายน
|
||||
*
|
||||
*
|
||||
* @param {string} rootId Guid, *Id Root
|
||||
* @param {string} salaryPeriodId Guid, *Id Period
|
||||
*/
|
||||
@Get("03/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport3(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
async SalaryReport3(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId: string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
const salaryProfile = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
type: "FULL", //หนึ่งขั้น
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName",
|
||||
"posMasterNo", "amount", "amountSpecial"
|
||||
]
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"root",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"orgShortName",
|
||||
"posMasterNo",
|
||||
"amount",
|
||||
"amountSpecial",
|
||||
],
|
||||
});
|
||||
|
||||
const mapData = {
|
||||
effectiveDate : salaryPeriod?.effectiveDate,
|
||||
effectiveDate: salaryPeriod?.effectiveDate,
|
||||
// root: salaryProfile[0]?.root,
|
||||
profile: salaryProfile.map((item, index) => ({
|
||||
no: Extension.ToThaiNumber(String(index+1)),
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
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),
|
||||
no: Extension.ToThaiNumber(String(index + 1)),
|
||||
fullname: item.prefix + item.firstName + " " + item.lastName,
|
||||
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),
|
||||
posLevel: item.posLevel,
|
||||
posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||
amount: item.amount == undefined || item.amount == null ? "๐" : Extension.ToThaiNumber(String(item.amount)),
|
||||
amount:
|
||||
item.amount == undefined || item.amount == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amount)),
|
||||
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
||||
remark: null //หมายเหตุ
|
||||
}))
|
||||
}
|
||||
return mapData
|
||||
remark: null, //หมายเหตุ
|
||||
})),
|
||||
};
|
||||
return mapData;
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายงานแบบ 1 กท รอบเมษายน
|
||||
*
|
||||
* @summary รายงานแบบ 1 กท รอบเมษายน
|
||||
*
|
||||
*
|
||||
* @param {string} rootId Guid, *Id Root
|
||||
* @param {string} salaryPeriodId Guid, *Id Period
|
||||
*/
|
||||
@Get("04/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport4(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
async SalaryReport4(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId: string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
const salaryProfile = await this.salaryProfile.find({
|
||||
where: { salaryOrgId: salaryOrg?.id},
|
||||
where: { salaryOrgId: salaryOrg?.id },
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName",
|
||||
"posMasterNo", "amount", "amountSpecial"
|
||||
]
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"root",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"orgShortName",
|
||||
"posMasterNo",
|
||||
"amount",
|
||||
"amountSpecial",
|
||||
],
|
||||
});
|
||||
|
||||
const mapData = {
|
||||
effectiveDate : salaryPeriod?.effectiveDate,
|
||||
root: salaryProfile[0]?.root,
|
||||
effectiveDate: salaryPeriod?.effectiveDate,
|
||||
root: salaryProfile[0]?.root,
|
||||
profile: salaryProfile.map((item, index) => ({
|
||||
no: Extension.ToThaiNumber(String(index+1)),
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
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),
|
||||
no: Extension.ToThaiNumber(String(index + 1)),
|
||||
fullname: item.prefix + item.firstName + " " + item.lastName,
|
||||
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),
|
||||
posLevel: item.posLevel,
|
||||
orgShortName: item.orgShortName+Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||
amount: item.amount == undefined || item.amount == null ? "๐" : Extension.ToThaiNumber(String(item.amount)),
|
||||
amountSpecial: item.amountSpecial == undefined || item.amountSpecial == null ? "๐" : Extension.ToThaiNumber(String(item.amountSpecial)),
|
||||
orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||
amount:
|
||||
item.amount == undefined || item.amount == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amount)),
|
||||
amountSpecial:
|
||||
item.amountSpecial == undefined || item.amountSpecial == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amountSpecial)),
|
||||
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
||||
remark: null //หมายเหตุ
|
||||
}))
|
||||
}
|
||||
return mapData
|
||||
remark: null, //หมายเหตุ
|
||||
})),
|
||||
};
|
||||
return mapData;
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายงานคำสั่งเลื่อนเงินเดือน รอบเมษายน
|
||||
*
|
||||
* @summary รายงานคำสั่งเลื่อนเงินเดือน รอบเมษายน
|
||||
*
|
||||
*
|
||||
* @param {string} rootId Guid, *Id Root
|
||||
* @param {string} salaryPeriodId Guid, *Id Period
|
||||
*/
|
||||
@Get("07/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport7(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
async SalaryReport7(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId: string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
const salaryProfile = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountSpecial: IsNull() || 0,
|
||||
amountUse: MoreThan(1),
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName", "posMasterNo",
|
||||
"amount", "amountUse", "positionSalaryAmount"
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC"
|
||||
}
|
||||
});
|
||||
|
||||
const mapData = salaryProfile.map((item, index) => ({
|
||||
no: Extension.ToThaiNumber(String(index+1)),
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
const salaryProfile = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountSpecial: IsNull() || 0,
|
||||
amountUse: MoreThan(1),
|
||||
},
|
||||
select: [
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"root",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"orgShortName",
|
||||
"posMasterNo",
|
||||
"amount",
|
||||
"amountUse",
|
||||
"positionSalaryAmount",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
const mapData = salaryProfile.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,
|
||||
posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||
amount: item.amount == undefined || item.amount == null ? "๐" : Extension.ToThaiNumber(String(item.amount)),
|
||||
positionSalaryAmount: item.positionSalaryAmount == undefined || item.positionSalaryAmount == null ? "๐" : Extension.ToThaiNumber(String(item.positionSalaryAmount)),
|
||||
remark: null
|
||||
amount:
|
||||
item.amount == undefined || item.amount == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amount)),
|
||||
positionSalaryAmount:
|
||||
item.positionSalaryAmount == undefined || item.positionSalaryAmount == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.positionSalaryAmount)),
|
||||
remark: null,
|
||||
}));
|
||||
|
||||
return mapData;
|
||||
|
|
@ -259,100 +304,125 @@ export class Report_1_Controller extends Controller {
|
|||
* API รายงานคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน
|
||||
*
|
||||
* @summary รายงานคำสั่งคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน
|
||||
*
|
||||
*
|
||||
* @param {string} rootId Guid, *Id Root
|
||||
* @param {string} salaryPeriodId Guid, *Id Period
|
||||
*/
|
||||
@Get("08/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport8(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
async SalaryReport8(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId: string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
const salaryProfileSpecial = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountSpecial: MoreThan(1),
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName",
|
||||
"posMasterNo", "amount", "amountSpecial",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC"
|
||||
}
|
||||
});
|
||||
const salaryProfileSpecial = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountSpecial: MoreThan(1),
|
||||
},
|
||||
select: [
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"root",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"orgShortName",
|
||||
"posMasterNo",
|
||||
"amount",
|
||||
"amountSpecial",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
const salaryProfileNoAmount = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountUse: IsNull() || 0,
|
||||
positionSalaryAmount: IsNull() || 0,
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName",
|
||||
"posMasterNo", "amount",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC"
|
||||
}
|
||||
});
|
||||
const salaryProfileNoAmount = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountUse: IsNull() || 0,
|
||||
positionSalaryAmount: IsNull() || 0,
|
||||
},
|
||||
select: [
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"root",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"orgShortName",
|
||||
"posMasterNo",
|
||||
"amount",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const profileSpecial = salaryProfileSpecial.map((item, index) => ({
|
||||
no: Extension.ToThaiNumber(String(index+1)),
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
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,
|
||||
posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||
amount: item.amount == undefined || item.amount == null ? "๐" : Extension.ToThaiNumber(String(item.amount)),
|
||||
amountSpecial: item.amountSpecial == undefined || item.amountSpecial == null ? "๐" : Extension.ToThaiNumber(String(item.amountSpecial)),
|
||||
remark: null
|
||||
amount:
|
||||
item.amount == undefined || item.amount == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amount)),
|
||||
amountSpecial:
|
||||
item.amountSpecial == undefined || item.amountSpecial == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amountSpecial)),
|
||||
remark: null,
|
||||
}));
|
||||
|
||||
const profileNoAmount = salaryProfileNoAmount.map((item, index) => ({
|
||||
no: Extension.ToThaiNumber(String(index+1)),
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
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,
|
||||
posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||
amount: item.amount == undefined || item.amount == null ? "๐" : Extension.ToThaiNumber(String(item.amount)),
|
||||
remark: null
|
||||
amount:
|
||||
item.amount == undefined || item.amount == null
|
||||
? "๐"
|
||||
: Extension.ToThaiNumber(String(item.amount)),
|
||||
remark: null,
|
||||
}));
|
||||
|
||||
const mapData = {
|
||||
profileSpecial,
|
||||
profileNoAmount
|
||||
}
|
||||
profileSpecial,
|
||||
profileNoAmount,
|
||||
};
|
||||
return mapData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import { PosLevel } from "../entities/PosLevel";
|
|||
import { Salarys } from "../entities/Salarys";
|
||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee";
|
||||
import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee";
|
||||
|
||||
@Route("api/v1/salary/period")
|
||||
@Tags("Salary")
|
||||
|
|
@ -33,7 +35,9 @@ import CallAPI from "../interfaces/call-api";
|
|||
export class SalaryPeriodController extends Controller {
|
||||
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
||||
private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg);
|
||||
private salaryOrgEmployeeRepository = AppDataSource.getRepository(SalaryOrgEmployee);
|
||||
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
|
||||
private salaryProfileEmployeeRepository = AppDataSource.getRepository(SalaryProfileEmployee);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private salaryRepository = AppDataSource.getRepository(Salarys);
|
||||
|
|
@ -1466,6 +1470,16 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
|
||||
const salaryOrgEmployee = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
});
|
||||
const salaryProfileEmployee = await this.salaryProfileEmployeeRepository.find({
|
||||
where: { salaryOrgId: In(salaryOrgEmployee.map((x) => x.id)) },
|
||||
});
|
||||
await this.salaryProfileEmployeeRepository.remove(salaryProfileEmployee);
|
||||
await this.salaryOrgEmployeeRepository.remove(salaryOrgEmployee);
|
||||
|
||||
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
|
||||
let total = 1000;
|
||||
let _orgProfiles = await new CallAPI().PostData(request, "org/unauthorize/salary/gen", {
|
||||
|
|
@ -1493,6 +1507,37 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
}
|
||||
}
|
||||
total = 1000;
|
||||
let orgProfileEmployees: any;
|
||||
let _orgProfileEmployees = await new CallAPI().PostData(
|
||||
request,
|
||||
"org/unauthorize/profile/salary/employee/gen",
|
||||
{
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
},
|
||||
);
|
||||
orgProfileEmployees = _orgProfileEmployees.data;
|
||||
total = _orgProfileEmployees.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/orgProfileEmployees/gen", {
|
||||
page: index,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
})
|
||||
.then((x) => {
|
||||
Array.prototype.push.apply(orgProfileEmployees, x.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
|
|
@ -1520,6 +1565,28 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
orgs.map(async (rootId: string) => {
|
||||
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
|
||||
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
|
||||
salaryOrgNew.status = "PENDING";
|
||||
salaryOrgNew.rootId = rootId;
|
||||
salaryOrgNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryOrgNew.snapshot = snapshot;
|
||||
salaryOrgNew.createdUserId = request.user.sub;
|
||||
salaryOrgNew.createdFullName = request.user.name;
|
||||
salaryOrgNew.lastUpdateUserId = request.user.sub;
|
||||
salaryOrgNew.lastUpdateFullName = request.user.name;
|
||||
salaryOrgNew.group = "GROUP1";
|
||||
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
// if (salaryPeriod.period != "SPECIAL") {
|
||||
// delete salaryOrgNew.id;
|
||||
// salaryOrgNew.group = "GROUP2";
|
||||
// await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
// }
|
||||
}),
|
||||
);
|
||||
if (salaryPeriod.period != "SPECIAL") {
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
|
|
@ -1575,12 +1642,58 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: "GROUP1",
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfileEmployee(), profile);
|
||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryProfileNew.createdUserId = request.user.sub;
|
||||
salaryProfileNew.createdFullName = request.user.name;
|
||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgOld = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileEmployeeRepository.findOne({
|
||||
where: {
|
||||
citizenId: salaryProfileNew.citizenId,
|
||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||
},
|
||||
});
|
||||
salaryProfileNew.type = salaryOld == null ? 0 : salaryOld.type;
|
||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||
salaryProfileNew.positionSalaryAmount =
|
||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||
}
|
||||
await this.salaryProfileEmployeeRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
const salaryOrgEmployeeNew = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
if (salaryPeriod.period == "OCT") {
|
||||
const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -1640,6 +1753,58 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
let totalAmount = 0;
|
||||
if (salaryPeriodAPROld != null) {
|
||||
const salaryOrgSnap2Old: any = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodAPROld.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
totalAmount =
|
||||
salaryOrgSnap2Old == null
|
||||
? 0
|
||||
: Extension.sumObjectValues(salaryOrgSnap2Old.salaryProfiles, "amountUse");
|
||||
}
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
} else {
|
||||
_salaryOrg.currentAmount = salaryOrgSnap1.currentAmount;
|
||||
_salaryOrg.sixPercentAmount = salaryOrgSnap1.sixPercentAmount;
|
||||
_salaryOrg.spentAmount = salaryOrgSnap1.spentAmount;
|
||||
_salaryOrg.useAmount = salaryOrgSnap1.useAmount;
|
||||
_salaryOrg.remainingAmount = salaryOrgSnap1.remainingAmount;
|
||||
}
|
||||
} else {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
} else if (salaryPeriod.period == "APR") {
|
||||
await Promise.all(
|
||||
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||
|
|
@ -1674,6 +1839,39 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
} else {
|
||||
_salaryOrg.total = salaryOrgSnap1.total;
|
||||
_salaryOrg.fifteenPercent = salaryOrgSnap1.fifteenPercent;
|
||||
_salaryOrg.fifteenPoint = salaryOrgSnap1.fifteenPoint;
|
||||
_salaryOrg.quantityUsed = salaryOrgSnap1.quantityUsed;
|
||||
_salaryOrg.remainQuota = salaryOrgSnap1.remainQuota;
|
||||
}
|
||||
} else {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
@ -1754,25 +1952,23 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
|
||||
let orgProfiles: any;
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
})
|
||||
.then((x) => {
|
||||
orgProfiles = x.data;
|
||||
});
|
||||
if (orgProfiles.total > 100) {
|
||||
const page = Math.ceil(orgProfiles.total.length / 100);
|
||||
let total = 1000;
|
||||
let _orgProfiles = await new CallAPI().PostData(request, "org/unauthorize/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
});
|
||||
let orgProfiles = _orgProfiles.data;
|
||||
total = _orgProfiles.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/gen", {
|
||||
page: index,
|
||||
pageSize: 100,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
|
|
@ -1782,6 +1978,37 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
}
|
||||
}
|
||||
total = 1000;
|
||||
let orgProfileEmployees: any;
|
||||
let _orgProfileEmployees = await new CallAPI().PostData(
|
||||
request,
|
||||
"org/unauthorize/profile/salary/employee/gen",
|
||||
{
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
},
|
||||
);
|
||||
orgProfileEmployees = _orgProfileEmployees.data;
|
||||
total = _orgProfileEmployees.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/orgProfileEmployees/gen", {
|
||||
page: index,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
})
|
||||
.then((x) => {
|
||||
Array.prototype.push.apply(orgProfileEmployees, x.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
|
|
@ -1809,6 +2036,28 @@ export class SalaryPeriodController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
orgs.map(async (rootId: string) => {
|
||||
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
|
||||
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
|
||||
salaryOrgNew.status = "PENDING";
|
||||
salaryOrgNew.rootId = rootId;
|
||||
salaryOrgNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryOrgNew.snapshot = snapshot;
|
||||
salaryOrgNew.createdUserId = request.user.sub;
|
||||
salaryOrgNew.createdFullName = request.user.name;
|
||||
salaryOrgNew.lastUpdateUserId = request.user.sub;
|
||||
salaryOrgNew.lastUpdateFullName = request.user.name;
|
||||
salaryOrgNew.group = "GROUP1";
|
||||
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
// if (salaryPeriod.period != "SPECIAL") {
|
||||
// delete salaryOrgNew.id;
|
||||
// salaryOrgNew.group = "GROUP2";
|
||||
// await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
// }
|
||||
}),
|
||||
);
|
||||
|
||||
if (salaryPeriod.period != "SPECIAL") {
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
|
|
@ -1863,12 +2112,58 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: "GROUP1",
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfileEmployee(), profile);
|
||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryProfileNew.createdUserId = request.user.sub;
|
||||
salaryProfileNew.createdFullName = request.user.name;
|
||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgOld = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileEmployeeRepository.findOne({
|
||||
where: {
|
||||
citizenId: salaryProfileNew.citizenId,
|
||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||
},
|
||||
});
|
||||
salaryProfileNew.type = salaryOld == null ? 0 : salaryOld.type;
|
||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||
salaryProfileNew.positionSalaryAmount =
|
||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||
}
|
||||
await this.salaryProfileEmployeeRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
const salaryOrgEmployeeNew = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
if (salaryPeriod.period == "OCT") {
|
||||
const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -1928,6 +2223,58 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
let totalAmount = 0;
|
||||
if (salaryPeriodAPROld != null) {
|
||||
const salaryOrgSnap2Old: any = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodAPROld.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
totalAmount =
|
||||
salaryOrgSnap2Old == null
|
||||
? 0
|
||||
: Extension.sumObjectValues(salaryOrgSnap2Old.salaryProfiles, "amountUse");
|
||||
}
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
} else {
|
||||
_salaryOrg.currentAmount = salaryOrgSnap1.currentAmount;
|
||||
_salaryOrg.sixPercentAmount = salaryOrgSnap1.sixPercentAmount;
|
||||
_salaryOrg.spentAmount = salaryOrgSnap1.spentAmount;
|
||||
_salaryOrg.useAmount = salaryOrgSnap1.useAmount;
|
||||
_salaryOrg.remainingAmount = salaryOrgSnap1.remainingAmount;
|
||||
}
|
||||
} else {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
} else if (salaryPeriod.period == "APR") {
|
||||
await Promise.all(
|
||||
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||
|
|
@ -1962,6 +2309,39 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
} else {
|
||||
_salaryOrg.total = salaryOrgSnap1.total;
|
||||
_salaryOrg.fifteenPercent = salaryOrgSnap1.fifteenPercent;
|
||||
_salaryOrg.fifteenPoint = salaryOrgSnap1.fifteenPoint;
|
||||
_salaryOrg.quantityUsed = salaryOrgSnap1.quantityUsed;
|
||||
_salaryOrg.remainQuota = salaryOrgSnap1.remainQuota;
|
||||
}
|
||||
} else {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
1595
src/controllers/SalaryPeriodEmployeeController.ts
Normal file
1595
src/controllers/SalaryPeriodEmployeeController.ts
Normal file
File diff suppressed because it is too large
Load diff
150
src/entities/SalaryOrgEmployee.ts
Normal file
150
src/entities/SalaryOrgEmployee.ts
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany, Double } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { SalaryPeriod } from "./SalaryPeriod";
|
||||
import { SalaryProfileEmployee } from "./SalaryProfileEmployee";
|
||||
|
||||
@Entity("salaryOrgEmployee")
|
||||
export class SalaryOrgEmployee extends EntityBase {
|
||||
@Column({
|
||||
comment: "คีย์นอก(FK)ของตาราง salaryPeriod",
|
||||
length: 40,
|
||||
})
|
||||
salaryPeriodId: string;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะ",
|
||||
})
|
||||
status: string;
|
||||
|
||||
@Column({
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRoot",
|
||||
length: 40,
|
||||
})
|
||||
rootId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||
length: 40,
|
||||
})
|
||||
revisionId: string;
|
||||
|
||||
@Column({
|
||||
comment: "รอบการ Snapshot",
|
||||
length: 20,
|
||||
default: "SNAP1",
|
||||
})
|
||||
snapshot: string;
|
||||
|
||||
@Column({
|
||||
default: 0,
|
||||
comment: "จำนวนคนทั้งหมด",
|
||||
})
|
||||
total: number;
|
||||
|
||||
@Column({
|
||||
default: 0,
|
||||
comment: "15%ของจำนวนคน(จำนวนเต็ม)",
|
||||
})
|
||||
fifteenPercent: number;
|
||||
|
||||
@Column({
|
||||
comment: "15%ของจำนวนคน(จุดทศนิยม)",
|
||||
type: "double",
|
||||
default: 0,
|
||||
})
|
||||
fifteenPoint: number;
|
||||
|
||||
@Column({
|
||||
comment: "กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2",
|
||||
length: 10,
|
||||
})
|
||||
group: string;
|
||||
|
||||
@Column({
|
||||
comment: "เลือกไปแล้ว",
|
||||
default: 0,
|
||||
})
|
||||
quantityUsed: number;
|
||||
|
||||
@Column({
|
||||
comment: "คงเหลือโควตา",
|
||||
default: 0,
|
||||
})
|
||||
remainQuota: number;
|
||||
|
||||
@Column({
|
||||
comment: "จำนวนเงินคนครองปัจจุบัน",
|
||||
type: "double",
|
||||
default: 0,
|
||||
})
|
||||
currentAmount: number;
|
||||
|
||||
@Column({
|
||||
comment: "วงเงิน6%",
|
||||
type: "double",
|
||||
default: 0,
|
||||
})
|
||||
sixPercentAmount: number;
|
||||
|
||||
@Column({
|
||||
comment: "ยอดเงินที่ใช้ไป",
|
||||
type: "double",
|
||||
default: 0,
|
||||
})
|
||||
spentAmount: number;
|
||||
|
||||
@Column({
|
||||
comment: "ใช้ไปเท่าไหร่",
|
||||
type: "double",
|
||||
default: 0,
|
||||
})
|
||||
useAmount: number;
|
||||
|
||||
@Column({
|
||||
comment: "เหลือเท่าไหร่",
|
||||
type: "double",
|
||||
default: 0,
|
||||
})
|
||||
remainingAmount: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คำแนะนำ สกจ",
|
||||
length: 255,
|
||||
})
|
||||
ownerRecommend: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คำแนะนำ ผอ",
|
||||
length: 255,
|
||||
})
|
||||
headRecommend: string;
|
||||
|
||||
@ManyToOne(() => SalaryPeriod, (salaryPeriod) => salaryPeriod.salaryOrgs)
|
||||
@JoinColumn({ name: "salaryPeriodId" })
|
||||
salaryPeriod: SalaryPeriod;
|
||||
|
||||
@OneToMany(() => SalaryProfileEmployee, (salaryProfile) => salaryProfile.salaryOrg)
|
||||
salaryProfiles: SalaryProfileEmployee[];
|
||||
}
|
||||
|
||||
export class CreateSalaryOrgEmployee {
|
||||
@Column("uuid")
|
||||
salaryPeriodId: string;
|
||||
|
||||
@Column()
|
||||
status: string;
|
||||
|
||||
@Column("uuid")
|
||||
rootId: string;
|
||||
|
||||
@Column()
|
||||
total: number;
|
||||
|
||||
@Column()
|
||||
fifteenPercent: number;
|
||||
}
|
||||
|
||||
export type UpdateSalaryOrgEmployee = Partial<CreateSalaryOrgEmployee>;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { SalaryOrg } from "./SalaryOrg";
|
||||
import { SalaryOrgEmployee } from "./SalaryOrgEmployee";
|
||||
|
||||
@Entity("salaryPeriod")
|
||||
export class SalaryPeriod extends EntityBase {
|
||||
|
|
@ -51,6 +52,9 @@ export class SalaryPeriod extends EntityBase {
|
|||
|
||||
@OneToMany(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryPeriod)
|
||||
salaryOrgs: SalaryOrg[];
|
||||
|
||||
@OneToMany(() => SalaryOrgEmployee, (salaryOrgEmployee) => salaryOrgEmployee.salaryPeriod)
|
||||
salaryOrgEmployees: SalaryOrgEmployee[];
|
||||
}
|
||||
|
||||
export class CreateSalaryPeriod {
|
||||
|
|
|
|||
397
src/entities/SalaryProfileEmployee.ts
Normal file
397
src/entities/SalaryProfileEmployee.ts
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { SalaryOrgEmployee } from "./SalaryOrgEmployee";
|
||||
|
||||
@Entity("salaryProfileEmployee")
|
||||
export class SalaryProfileEmployee extends EntityBase {
|
||||
@Column({
|
||||
comment: "คีย์นอก(FK)ของตาราง salaryOrg",
|
||||
length: 40,
|
||||
})
|
||||
salaryOrgId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คำนำหน้า",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
prefix: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
firstName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สกุล",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
lastName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เลขบัตรประชาชน",
|
||||
length: 100,
|
||||
default: null,
|
||||
})
|
||||
citizenId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)",
|
||||
length: 100,
|
||||
default: null,
|
||||
})
|
||||
posMasterNoPrefix: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เลขที่ตำแหน่ง เป็นตัวเลข",
|
||||
default: null,
|
||||
})
|
||||
posMasterNo: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "Suffix หลังเลขที่ตำแหน่ง เช่น ช.",
|
||||
length: 100,
|
||||
default: null,
|
||||
})
|
||||
posMasterNoSuffix: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อย่อหน่วยงาน",
|
||||
length: 100,
|
||||
default: null,
|
||||
})
|
||||
orgShortName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ตำแหน่ง",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
position: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ประเภทตำแหน่ง",
|
||||
length: 100,
|
||||
default: null,
|
||||
})
|
||||
posType: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระดับตำแหน่ง",
|
||||
default: null,
|
||||
})
|
||||
posLevel: number;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// comment: "ตำแหน่งทางการบริหาร",
|
||||
// length: 255,
|
||||
// default: null,
|
||||
// })
|
||||
// posExecutive: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "double",
|
||||
comment: "เงินเดือนฐาน",
|
||||
default: null,
|
||||
})
|
||||
amount: number | null;
|
||||
|
||||
@Column({
|
||||
type: "double",
|
||||
comment: "เงินพิเศษ",
|
||||
default: 0,
|
||||
})
|
||||
amountSpecial: number;
|
||||
|
||||
@Column({
|
||||
type: "double",
|
||||
comment: "จำนวนเงินที่ใช้เลื่อน",
|
||||
default: 0,
|
||||
})
|
||||
amountUse: number;
|
||||
|
||||
@Column({
|
||||
type: "double",
|
||||
comment: "เงินเดือนหลังเลื่อน",
|
||||
default: 0,
|
||||
})
|
||||
positionSalaryAmount: number;
|
||||
|
||||
@Column({
|
||||
comment:
|
||||
"ประเภทการเลื่อน(ขั้น) PENDING->รายชื่อคนครอง NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น",
|
||||
length: 20,
|
||||
default: "PENDING",
|
||||
})
|
||||
type: string;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะ",
|
||||
length: 20,
|
||||
default: "PENDING",
|
||||
})
|
||||
status: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "id revision",
|
||||
length: 40,
|
||||
})
|
||||
revisionId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRoot",
|
||||
length: 40,
|
||||
})
|
||||
rootId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อของหน่วยงาน",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
root: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild1",
|
||||
length: 40,
|
||||
})
|
||||
child1Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อส่วนราชการ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
child1: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild2",
|
||||
length: 40,
|
||||
})
|
||||
child2Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อส่วนราชการ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
child2: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild3",
|
||||
length: 40,
|
||||
})
|
||||
child3Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อส่วนราชการ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
child3: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild4",
|
||||
length: 40,
|
||||
})
|
||||
child4Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อส่วนราชการ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
child4: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ผลการประเมินผลการปฏิบัติราชการ",
|
||||
default: null,
|
||||
})
|
||||
result: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระยะเวลาการปฏิบัติราชการในรอบครึ่งปี",
|
||||
default: null,
|
||||
})
|
||||
duration: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "การลงโทษทางวินัย",
|
||||
default: null,
|
||||
})
|
||||
isPunish: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "พักราชการ",
|
||||
default: null,
|
||||
})
|
||||
isSuspension: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ขาดราชการ",
|
||||
default: null,
|
||||
})
|
||||
isAbsent: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "วันลา",
|
||||
default: null,
|
||||
})
|
||||
isLeave: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกษียญ",
|
||||
default: false,
|
||||
})
|
||||
isRetired: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สำรอง",
|
||||
default: false,
|
||||
})
|
||||
isReserve: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ทะลุขั้น",
|
||||
default: false,
|
||||
})
|
||||
isNext: boolean;
|
||||
|
||||
@ManyToOne(() => SalaryOrgEmployee, (salaryOrg) => salaryOrg.salaryProfiles)
|
||||
@JoinColumn({ name: "salaryOrgId" })
|
||||
salaryOrg: SalaryOrgEmployee;
|
||||
}
|
||||
|
||||
export class CreateSalaryProfileEmployee {
|
||||
@Column("uuid")
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
type: string;
|
||||
|
||||
@Column()
|
||||
prefix: string;
|
||||
|
||||
@Column()
|
||||
firstName: string;
|
||||
|
||||
@Column()
|
||||
lastName: string;
|
||||
|
||||
@Column()
|
||||
citizenId: string;
|
||||
|
||||
@Column()
|
||||
posMasterNoPrefix: string | null;
|
||||
|
||||
@Column()
|
||||
posMasterNo: number;
|
||||
|
||||
@Column()
|
||||
posMasterNoSuffix: string | null;
|
||||
|
||||
@Column()
|
||||
orgShortName: string | null;
|
||||
|
||||
@Column()
|
||||
position: string;
|
||||
|
||||
@Column()
|
||||
posType: string;
|
||||
|
||||
@Column()
|
||||
posLevel: string;
|
||||
|
||||
// @Column()
|
||||
// posExecutive: string | null;
|
||||
|
||||
@Column()
|
||||
amount: number | null;
|
||||
|
||||
@Column("uuid")
|
||||
rootId: string | null;
|
||||
|
||||
@Column()
|
||||
root: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
child1Id: string | null;
|
||||
|
||||
@Column()
|
||||
child1: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
child2Id: string | null;
|
||||
|
||||
@Column()
|
||||
child2: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
child3Id: string | null;
|
||||
|
||||
@Column()
|
||||
child3: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
child4Id: string | null;
|
||||
|
||||
@Column()
|
||||
child4: string | null;
|
||||
|
||||
@Column()
|
||||
result: string | null;
|
||||
|
||||
@Column()
|
||||
duration: string | null;
|
||||
|
||||
@Column()
|
||||
isPunish: boolean;
|
||||
|
||||
@Column()
|
||||
isSuspension: boolean;
|
||||
|
||||
@Column()
|
||||
isAbsent: boolean;
|
||||
|
||||
@Column()
|
||||
isLeave: boolean;
|
||||
|
||||
@Column()
|
||||
isRetired: boolean;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableSalaryOrgAddRecommend11710564694856 implements MigrationInterface {
|
||||
name = 'UpdateTableSalaryOrgAddRecommend11710564694856'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`salaryOrgEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`salaryPeriodId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง salaryPeriod', \`status\` varchar(255) NOT NULL COMMENT 'สถานะ', \`rootId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot', \`revisionId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRevision', \`snapshot\` varchar(20) NOT NULL COMMENT 'รอบการ Snapshot' DEFAULT 'SNAP1', \`total\` int NOT NULL COMMENT 'จำนวนคนทั้งหมด' DEFAULT '0', \`fifteenPercent\` int NOT NULL COMMENT '15%ของจำนวนคน(จำนวนเต็ม)' DEFAULT '0', \`fifteenPoint\` double NOT NULL COMMENT '15%ของจำนวนคน(จุดทศนิยม)' DEFAULT '0', \`group\` varchar(10) NOT NULL COMMENT 'กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2', \`quantityUsed\` int NOT NULL COMMENT 'เลือกไปแล้ว' DEFAULT '0', \`remainQuota\` int NOT NULL COMMENT 'คงเหลือโควตา' DEFAULT '0', \`currentAmount\` double NOT NULL COMMENT 'จำนวนเงินคนครองปัจจุบัน' DEFAULT '0', \`sixPercentAmount\` double NOT NULL COMMENT 'วงเงิน6%' DEFAULT '0', \`spentAmount\` double NOT NULL COMMENT 'ยอดเงินที่ใช้ไป' DEFAULT '0', \`useAmount\` double NOT NULL COMMENT 'ใช้ไปเท่าไหร่' DEFAULT '0', \`remainingAmount\` double NOT NULL COMMENT 'เหลือเท่าไหร่' DEFAULT '0', \`ownerRecommend\` varchar(255) NULL COMMENT 'คำแนะนำ สกจ', \`headRecommend\` varchar(255) NULL COMMENT 'คำแนะนำ ผอ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`salaryProfileEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`salaryOrgId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง salaryOrg', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`citizenId\` varchar(100) NULL COMMENT 'เลขบัตรประชาชน', \`posMasterNoPrefix\` varchar(100) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)', \`posMasterNo\` int NULL COMMENT 'เลขที่ตำแหน่ง เป็นตัวเลข', \`posMasterNoSuffix\` varchar(100) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.', \`orgShortName\` varchar(100) NULL COMMENT 'ชื่อย่อหน่วยงาน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posType\` varchar(100) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevel\` int NULL COMMENT 'ระดับตำแหน่ง', \`amount\` double NULL COMMENT 'เงินเดือนฐาน', \`amountSpecial\` double NOT NULL COMMENT 'เงินพิเศษ' DEFAULT '0', \`amountUse\` double NOT NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน' DEFAULT '0', \`positionSalaryAmount\` double NOT NULL COMMENT 'เงินเดือนหลังเลื่อน' DEFAULT '0', \`type\` varchar(20) NOT NULL COMMENT 'ประเภทการเลื่อน(ขั้น) PENDING->รายชื่อคนครอง NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น' DEFAULT 'PENDING', \`status\` varchar(20) NOT NULL COMMENT 'สถานะ' DEFAULT 'PENDING', \`revisionId\` varchar(40) NULL COMMENT 'id revision', \`rootId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot', \`root\` varchar(255) NULL COMMENT 'ชื่อของหน่วยงาน', \`child1Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild1', \`child1\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ', \`child2Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild2', \`child2\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ', \`child3Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild3', \`child3\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ', \`child4Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild4', \`child4\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ', \`result\` varchar(255) NULL COMMENT 'ผลการประเมินผลการปฏิบัติราชการ', \`duration\` varchar(255) NULL COMMENT 'ระยะเวลาการปฏิบัติราชการในรอบครึ่งปี', \`isPunish\` tinyint NULL COMMENT 'การลงโทษทางวินัย', \`isSuspension\` tinyint NULL COMMENT 'พักราชการ', \`isAbsent\` tinyint NULL COMMENT 'ขาดราชการ', \`isLeave\` tinyint NULL COMMENT 'วันลา', \`isRetired\` tinyint NULL COMMENT 'เกษียญ' DEFAULT 0, \`isReserve\` tinyint NULL COMMENT 'สำรอง' DEFAULT 0, \`isNext\` tinyint NULL COMMENT 'ทะลุขั้น' DEFAULT 0, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`salaryOrgEmployee\` ADD CONSTRAINT \`FK_34789055fe8c215e333b83ca20d\` FOREIGN KEY (\`salaryPeriodId\`) REFERENCES \`salaryPeriod\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` ADD CONSTRAINT \`FK_ba74e4af9c44fd90032d4724a70\` FOREIGN KEY (\`salaryOrgId\`) REFERENCES \`salaryOrgEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`salaryProfileEmployee\` DROP FOREIGN KEY \`FK_ba74e4af9c44fd90032d4724a70\``);
|
||||
await queryRunner.query(`ALTER TABLE \`salaryOrgEmployee\` DROP FOREIGN KEY \`FK_34789055fe8c215e333b83ca20d\``);
|
||||
await queryRunner.query(`DROP TABLE \`salaryProfileEmployee\``);
|
||||
await queryRunner.query(`DROP TABLE \`salaryOrgEmployee\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue