checkpoint

This commit is contained in:
AdisakKanthawilang 2025-04-11 11:53:51 +07:00
parent f19d3ce70e
commit e585e41a70
4 changed files with 228 additions and 0 deletions

View file

@ -293,6 +293,216 @@ export class OrganizationUnauthorizeController extends Controller {
return new HttpSuccess({ data: formattedData, total: total });
}
/**
* API TEST (unauthorize)
*
* @summary TEST #76 (unauthorize)
*
*/
@Post("testsalary/gen")
async testsalaryGen(
@Body()
body: {
page: number;
pageSize: number;
keyword?: string;
year: number;
period: string;
},
) {
const findRevision = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsCurrent: true },
});
if (!findRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
}
const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster)
.createQueryBuilder("viewPosMaster")
.where({orgRevisionId: findRevision?.id})
.andWhere(
new Brackets((qb) => {
qb.where(
body.keyword != null && body.keyword != ""
? "prefix LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "firstName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "lastName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "position LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "posTypeName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "posLevelName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
);
}),
)
.orderBy("citizenId", "ASC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
if (!findPosMaster) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
}
const formattedData = findPosMaster.map((item) => {
let orgShortName = "";
if (item.orgChild1Id === null) {
orgShortName = item?.orgRootShortName;
} else if (item.orgChild2Id === null) {
orgShortName = item?.orgChild1ShortName;
} else if (item.orgChild3Id === null) {
orgShortName = item?.orgChild2ShortName;
} else if (item.orgChild4Id === null) {
orgShortName = item?.orgChild3ShortName;
} else {
orgShortName = item?.orgChild4ShortName;
}
// const posExecutive =
// item.positions == null ||
// item.positions?.find((position) => position.positionIsSelected == true) == null ||
// item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
// null ||
// item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
// ?.posExecutiveName == null
// ? null
// : item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
// .posExecutiveName;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);
let datePeriodEnd = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);
if (body.period.toLocaleUpperCase() == "APR") {
datePeriodStart = new Date(`${body.year}-03-31T00:00:00.000Z`);
datePeriodEnd = new Date(`${body.year}-03-31T00:00:00.000Z`);
}
if (body.period.toLocaleUpperCase() == "OCT") {
datePeriodStart = new Date(`${body.year}-09-30T00:00:00.000Z`);
datePeriodEnd = new Date(`${body.year}-09-30T00:00:00.000Z`);
}
datePeriodStart = new Date(
new Date(datePeriodStart.setDate(datePeriodStart.getDate() + 1)).setMonth(
datePeriodStart.getMonth() - 6,
),
);
// const specialPosition = item.positions.find(
// (position) => position.positionIsSelected === true,
// );
// const isSpecial = specialPosition ? specialPosition.isSpecial : null;
const pointSum = item.pointSum
? `(${this.textPointSummaryKpi(item.pointSum)})${item.pointSum}` //่join ธรรมดาดึง row ล่าสุดอยู่แล้ว
: null;
return {
id: item.id,
profileId: item.profileId,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
citizenId: item.citizenId,
posMasterNoPrefix: item.posMasterNoPrefix,
posMasterNo: item.posMasterNo,
posMasterNoSuffix: item.posMasterNoSuffix,
orgShortName: orgShortName,
position: item.position,
posType: item.posTypeName,
posLevel: item.posLevelName,
posExecutive: item.posExecutiveName,
amount: item.amount,
rootId: item.orgRootId,
root: item.orgRootName,
rootOrder: item.orgRootOrder,
child1Id: item.orgChild1Id,
child1: item.orgChild1Name,
child1Order: item.orgChild1Order,
child2Id: item.orgChild2Id,
child2: item.orgChild2Name,
child2Order: item.orgChild2Order,
child3Id: item.orgChild3Id,
child3: item.orgChild3Name,
child3Order: item.orgChild3Order,
child4Id: item.orgChild4Id,
child4: item.orgChild4Name,
child4Order: item.orgChild4Order,
result: pointSum,
duration: null,
// isPunish:
// item.current_holder.profileDisciplines.filter(
// (x: any) =>
// new Date(
// `${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
// ) >= datePeriodStart &&
// new Date(
// `${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
// ) <= datePeriodEnd,
// ).length > 0
// ? true
// : false,
isSuspension: item.dateRetire == null ? false : true,
isAbsent: item.profileDisciplineId ? true : false,
isLeave: item.profileLeaveId ? true : false,
isRetired:
item.birthDate == null ||
calculateRetireDate(item.birthDate).getFullYear() != body.year
? false
: true,
// isSpecial: isSpecial,
};
});
return new HttpSuccess({ data: formattedData, total: total });
}
/**
* API (unauthorize)
*

View file

@ -375,6 +375,7 @@ export class ProfileSalaryEmployeeController extends Controller {
profile.amountSpecial = body.amountSpecial ?? _null;
profile.positionSalaryAmount = body.positionSalaryAmount ?? _null;
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null;
profile.salaryLevel = body.salaryLevel ?? _null;
await this.profileRepo.save(profile);
return new HttpSuccess();
}

View file

@ -355,6 +355,7 @@ export class CreateProfileSalaryEmployee {
commandName?: string | null;
posNumCodeSit?: string | null;
posNumCodeSitAbb?: string | null;
salaryLevel?: number | null;
}
export class UpdateProfileSalaryEmployee {
@ -387,6 +388,7 @@ export class UpdateProfileSalaryEmployee {
commandName?: string | null;
posNumCodeSit?: string | null;
posNumCodeSitAbb?: string | null;
salaryLevel?: number | null;
}
export type UpdateProfileSalary = {

View file

@ -24,18 +24,23 @@ import { ViewColumn, ViewEntity } from "typeorm";
profile.birthDate,
orgRoot.id as rootId,
orgRoot.orgRootShortName,
orgRoot.orgRootOrder,
orgRoot.orgRootName,
orgChild1.id as child1Id,
orgChild1.orgChild1ShortName,
orgChild1.orgChild1Order,
orgChild1.orgChild1Name,
orgChild2.id as child2Id,
orgChild2.orgChild2ShortName,
orgChild2.orgChild2Order,
orgChild2.orgChild2Name,
orgChild3.id as child3Id,
orgChild3.orgChild3ShortName,
orgChild3.orgChild3Order,
orgChild3.orgChild3Name,
orgChild4.id as child4Id,
orgChild4.orgChild4ShortName,
orgChild4.orgChild4Order,
orgChild4.orgChild4Name,
position.id as positionId,
position.positionIsSelected,
@ -133,30 +138,40 @@ export class viewPosMaster {
@ViewColumn()
orgRootShortName: string;
@ViewColumn()
orgRootOrder: string;
@ViewColumn()
orgRootName: string;
@ViewColumn()
child1Id: string;
@ViewColumn()
orgChild1ShortName: string;
@ViewColumn()
orgChild1Order: string;
@ViewColumn()
orgChild1Name: string;
@ViewColumn()
child2Id: string;
@ViewColumn()
orgChild2ShortName: string;
@ViewColumn()
orgChild2Order: string;
@ViewColumn()
orgChild2Name: string;
@ViewColumn()
child3Id: string;
@ViewColumn()
orgChild3ShortName: string;
@ViewColumn()
orgChild3Order: string;
@ViewColumn()
orgChild3Name: string;
@ViewColumn()
child4Id: string;
@ViewColumn()
orgChild4ShortName: string;
@ViewColumn()
orgChild4Order: string;
@ViewColumn()
orgChild4Name: string;
@ViewColumn()
positionId: string;