Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-03-26 17:00:06 +07:00
commit df264107d1
3 changed files with 132 additions and 27 deletions

View file

@ -2487,33 +2487,73 @@ export class ReportController extends Controller {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
period: "APR",
isActive: true
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
year: salaryPeriod.year - 1,
period: "APR",
isActive: true
},
});
const salaryPeriodOCT = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
year: salaryPeriod.year - 1,
period: "OCT",
isActive: true
},
});
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg",],
where: {
salaryOrg: {
snapshot: "SNAP1",
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
type: "NONE"
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
if (!_salaryProfileEmp) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const _salaryProfileEmpAPR = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg",],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodAPR?.id,
}
}
});
const _salaryProfileEmpOCT = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg",],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodOCT?.id,
}
}
});
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
const formattedData = _salaryProfileEmp.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
@ -2530,11 +2570,37 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
posLevel: profile.posLevel,
position: profile.position,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "",
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" ? "๑ ขั้น" : "ไม่ได้เลื่อนขั้นฯ",
score: null, //ผลการประเมิน
remark: null, //หมายเหตุ
};
});
@ -2543,11 +2609,14 @@ export class ReportController extends Controller {
reportName: "emp1-09",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearBeforeSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1)).slice(-2)),
yearSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2)),
agency: agency,
data: formattedData,
},
});
}
// /**
// * API 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น
// *

View file

@ -227,16 +227,20 @@ export class SalaryFormulaEmployeeController extends Controller {
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
) {
let whereClause: any = {};
if (keyword != undefined && keyword !== "") {
whereClause = {
where: [
{ details: Like(`%${keyword}%`) },
{ position: Like(`%${keyword}%`) },
{ posType: { posTypeName: Like(`%${keyword}%`)} },
{ posLevel: { posLevelName: Like(`%${keyword}%`)} },
],
};
}
const [getFormula, total] = await this.salaryFormulaEmployeeRepository.findAndCount({
relations: ["salaryEmployee", "posType", "posLevel", "salaryEmployeeMins"],
where: {
details: Like(`%${keyword}%`),
position: Like(`%${keyword}%`),
// posLevel: { posLevelName: keyword },
posType: { posTypeName: Like(`%${keyword}%`) },
// salaryEmployeeMins: { group: keyword },
// salaryEmployee: { group: keyword },
},
...whereClause,
order: {
lastUpdatedAt: "DESC",
},
@ -245,16 +249,13 @@ export class SalaryFormulaEmployeeController extends Controller {
const mapFormula = getFormula.map((item) => ({
id: item.id,
// posLevelId: item.posLevelId,
posLevel: item.posLevel != null ? item.posLevel.posLevelName : null,
position: item.position, ////
// posTypeId: item.posTypeId,
position: item.position,
posType: item.posType != null ? item.posType.posTypeName : null,
details: item.details, ////
salaryMin: item.salaryMin, //
salary: item.salary, //
salaryMax: item.salaryMax, //
// salaryEmployeeId: item.salaryEmployeeId,
details: item.details,
salaryMin: item.salaryMin,
salary: item.salary,
salaryMax: item.salaryMax,
group: item.salaryEmployee != null ? item.salaryEmployee.group : null,
salaryEmployeeMin:
item.salaryEmployeeMins != null ? item.salaryEmployeeMins.map((x) => x.group) : null,

View file

@ -1418,6 +1418,41 @@ export class SalaryPeriodController extends Controller {
return new HttpSuccess(salaryPeriod);
}
/**
* API by year
*
* @summary SLR_020 - by year
*
*/
@Get("active/{year}")
async GetListsSalaryPeriodByYear(
@Path() year: number,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
) {
const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod)
.createQueryBuilder("salaryPeriod")
.andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` })
.andWhere({ isActive: true })
.select([
"salaryPeriod.id",
"salaryPeriod.period",
"salaryPeriod.isActive",
"salaryPeriod.isClose",
"salaryPeriod.effectiveDate",
"salaryPeriod.status",
"salaryPeriod.year",
"salaryPeriod.revisionId",
])
.orderBy("salaryPeriod.effectiveDate", "DESC")
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
return new HttpSuccess({ data: salaryPeriod, total });
}
/**
* API
*