This commit is contained in:
parent
508cb56430
commit
aeecbd8ae9
1 changed files with 381 additions and 146 deletions
|
|
@ -72,68 +72,68 @@ export class SalaryPeriodController extends Controller {
|
||||||
const data = {
|
const data = {
|
||||||
group1id:
|
group1id:
|
||||||
salaryPeriod.salaryOrgs &&
|
salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP1" &&
|
x.group == "GROUP1" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
) == null
|
) == null
|
||||||
? null
|
? null
|
||||||
: salaryPeriod.salaryOrgs &&
|
: salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP1" &&
|
x.group == "GROUP1" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
)?.id,
|
)?.id,
|
||||||
group1IsClose:
|
group1IsClose:
|
||||||
salaryPeriod.salaryOrgs &&
|
salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP1" &&
|
x.group == "GROUP1" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
) == null
|
) == null
|
||||||
? null
|
? null
|
||||||
: salaryPeriod.salaryOrgs &&
|
: salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP1" &&
|
x.group == "GROUP1" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
)?.isClose,
|
)?.isClose,
|
||||||
group2id:
|
group2id:
|
||||||
salaryPeriod.salaryOrgs &&
|
salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP2" &&
|
x.group == "GROUP2" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
) == null
|
) == null
|
||||||
? null
|
? null
|
||||||
: salaryPeriod.salaryOrgs &&
|
: salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP2" &&
|
x.group == "GROUP2" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
)?.id,
|
)?.id,
|
||||||
group2IsClose:
|
group2IsClose:
|
||||||
salaryPeriod.salaryOrgs &&
|
salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP2" &&
|
x.group == "GROUP2" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
) == null
|
) == null
|
||||||
? null
|
? null
|
||||||
: salaryPeriod.salaryOrgs &&
|
: salaryPeriod.salaryOrgs &&
|
||||||
salaryPeriod.salaryOrgs.find(
|
salaryPeriod.salaryOrgs.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.group == "GROUP2" &&
|
x.group == "GROUP2" &&
|
||||||
x.rootId == body.rootId &&
|
x.rootId == body.rootId &&
|
||||||
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
)?.isClose,
|
)?.isClose,
|
||||||
effectiveDate: salaryPeriod.effectiveDate,
|
effectiveDate: salaryPeriod.effectiveDate,
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
};
|
};
|
||||||
|
|
@ -192,8 +192,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
_salaryOrgGROUP2 == null
|
_salaryOrgGROUP2 == null
|
||||||
? 0
|
? 0
|
||||||
: _salaryOrgGROUP2.salaryProfiles.reduce((accumulator, object) => {
|
: _salaryOrgGROUP2.salaryProfiles.reduce((accumulator, object) => {
|
||||||
return accumulator + object.amountSpecial;
|
return accumulator + object.amountSpecial;
|
||||||
}, 0);
|
}, 0);
|
||||||
const data = {
|
const data = {
|
||||||
org: item.root,
|
org: item.root,
|
||||||
total: item.total + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.total),
|
total: item.total + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.total),
|
||||||
|
|
@ -489,7 +489,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
let type = salaryProfile.type;
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRanks
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
salaryRanks = await this.salaryRankRepository.findOne({
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
|
@ -583,9 +583,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalfSpecial;
|
: salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryHalf == null ||
|
salaryRanks.salaryHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -598,9 +598,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullSpecial;
|
: salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFull == null ||
|
salaryRanks.salaryFull == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -613,9 +613,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalfSpecial;
|
: salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFullHalf == null ||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -957,7 +957,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
salaryProfile.remark = body.remark == null ? _null : body.remark;
|
salaryProfile.remark = body.remark == null ? _null : body.remark;
|
||||||
let type = salaryProfile.type;
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRanks
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
salaryRanks = await this.salaryRankRepository.findOne({
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
|
@ -1051,9 +1051,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalfSpecial;
|
: salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryHalf == null ||
|
salaryRanks.salaryHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1066,9 +1066,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullSpecial;
|
: salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFull == null ||
|
salaryRanks.salaryFull == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1081,9 +1081,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalfSpecial;
|
: salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFullHalf == null ||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1200,6 +1200,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//OLD CHANGE TYPE-MULTI
|
||||||
/**
|
/**
|
||||||
* API แก้ไขขั้น
|
* API แก้ไขขั้น
|
||||||
*
|
*
|
||||||
|
|
@ -1208,8 +1209,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
* @param {string} id profile Id
|
* @param {string} id profile Id
|
||||||
* @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น
|
* @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น
|
||||||
*/
|
*/
|
||||||
@Post("change/type-multi")
|
@Post("oldchange/type-multi")
|
||||||
async changeTypeMulti(
|
async oldchangeTypeMulti(
|
||||||
@Body() body: { profileId: string[]; type: string; isReserve: boolean; remark?: string | null },
|
@Body() body: { profileId: string[]; type: string; isReserve: boolean; remark?: string | null },
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
|
|
@ -1293,7 +1294,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
salaryProfile.remark = body.remark == null ? _null : body.remark;
|
salaryProfile.remark = body.remark == null ? _null : body.remark;
|
||||||
let type = salaryProfile.type;
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRanks
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
salaryRanks = await this.salaryRankRepository.findOne({
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
|
@ -1391,9 +1392,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalfSpecial;
|
: salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryHalf == null ||
|
salaryRanks.salaryHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1406,9 +1407,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullSpecial;
|
: salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFull == null ||
|
salaryRanks.salaryFull == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1421,9 +1422,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalfSpecial;
|
: salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFullHalf == null ||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1542,6 +1543,240 @@ export class SalaryPeriodController extends Controller {
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NEW CHANGE TYPE-MULTI
|
||||||
|
@Post("change/type-multi")
|
||||||
|
async changeTypeMulti(
|
||||||
|
@Body() body: { profileId: string[]; type: string; isReserve: boolean; remark?: string | null },
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
|
await new permission().PermissionCreate(req, "SYS_SALARY_OFFICER");
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// 1) ดึง salaryProfiles ทีเดียว
|
||||||
|
// -----------------------------
|
||||||
|
const salaryProfiles = await this.salaryProfileRepository.find({
|
||||||
|
where: { id: In(body.profileId) },
|
||||||
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!salaryProfiles.length) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล salaryProfile");
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// 2) โหลด PosType, PosLevel, Salary, SalaryRanks ทั้งหมดทีเดียว
|
||||||
|
// -----------------------------
|
||||||
|
const posTypes = await this.posTypeRepository.find();
|
||||||
|
const posLevels = await this.posLevelRepository.find();
|
||||||
|
const salaries = await this.salaryRepository.find({ where: { isActive: true } });
|
||||||
|
const salaryRanks = await this.salaryRankRepository.find();
|
||||||
|
|
||||||
|
const posTypeMap = new Map(posTypes.map(x => [x.posTypeName, x]));
|
||||||
|
const posLevelMap = new Map(posLevels.map(x => [`${x.posTypeId}|${x.posLevelName}`, x]));
|
||||||
|
const salaryMap = new Map(
|
||||||
|
salaries.map(x => [`${x.posTypeId}|${x.posLevelId}|${x.isSpecial ? 1 : 0}`, x]),
|
||||||
|
);
|
||||||
|
|
||||||
|
const ranksBySalaryId = salaryRanks.reduce((acc, r: any) => {
|
||||||
|
if (!acc[r.salaryId]) acc[r.salaryId] = [];
|
||||||
|
acc[r.salaryId].push(r);
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<number, SalaryRanks[]>);
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// 3) Loop profiles
|
||||||
|
// -----------------------------
|
||||||
|
const profilesToSave: SalaryProfile[] = [];
|
||||||
|
const orgNeedRecalc = new Set<string>();
|
||||||
|
|
||||||
|
for (const profile of salaryProfiles) {
|
||||||
|
const bodyType = body.type?.toUpperCase() ?? profile.type;
|
||||||
|
|
||||||
|
// --- ตรวจ FULLHAFT → หา APR snapshot2 (เหมือนเดิม) ---
|
||||||
|
if (bodyType === "FULLHAFT" && profile.salaryOrg.salaryPeriod.period === "OCT") {
|
||||||
|
const checkPrev = await this.salaryProfileRepository.findOne({
|
||||||
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
|
where: {
|
||||||
|
citizenId: profile.citizenId,
|
||||||
|
salaryOrg: {
|
||||||
|
salaryPeriod: { period: "APR", year: profile.salaryOrg.salaryPeriod.year },
|
||||||
|
snapshot: "SNAP2",
|
||||||
|
},
|
||||||
|
type: "FULL",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkPrev) {
|
||||||
|
throw new HttpError(404, "ไม่สามารถเลื่อนขั้นเกิน 2 ครั้งในปีเดียวกันได้");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// reserve & remark
|
||||||
|
profile.type = bodyType;
|
||||||
|
profile.isReserve = bodyType === "FULL" ? body.isReserve : false;
|
||||||
|
profile.remark = body.remark ?? "";
|
||||||
|
|
||||||
|
// --- apply posType/posLevel/salary ---
|
||||||
|
const posType = posTypeMap.get(profile.posType);
|
||||||
|
if (!posType) throw new HttpError(404, "ไม่พบประเภทตำแหน่ง");
|
||||||
|
|
||||||
|
const posLevel = posLevelMap.get(`${posType.id}|${profile.posLevel}`);
|
||||||
|
if (!posLevel) throw new HttpError(404, "ไม่พบระดับตำแหน่ง");
|
||||||
|
|
||||||
|
const salaryBase = salaryMap.get(`${posLevel.posTypeId}|${posLevel.id}|${profile.isSpecial ? 1 : 0}`);
|
||||||
|
if (!salaryBase) throw new HttpError(404, "ไม่พบระดับเงินเดือน");
|
||||||
|
|
||||||
|
const salaryId = Number(salaryBase.id);
|
||||||
|
const ranks = ranksBySalaryId[salaryId] ?? [];
|
||||||
|
|
||||||
|
// --- หา rank ---
|
||||||
|
let rank: SalaryRanks | null = null;
|
||||||
|
|
||||||
|
if (profile.amount != null) {
|
||||||
|
const amount = profile.amount;
|
||||||
|
|
||||||
|
// หา rank ที่ใช้ type เดิม (เหมือนเดิม)
|
||||||
|
const possible = ranks
|
||||||
|
.filter((r: any) => r.salary >= amount && !r.isNext)
|
||||||
|
.sort((a: any, b: any) => a.salary - b.salary);
|
||||||
|
rank = possible[0] ?? null;
|
||||||
|
|
||||||
|
if (!rank) {
|
||||||
|
const next = ranks
|
||||||
|
.filter((r: any) => r.salary > amount && r.isNext)
|
||||||
|
.sort((a: any, b: any) => a.salary - b.salary);
|
||||||
|
rank = next[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- FULLHAFT dynamic type adjustment (เหมือนเดิม) ---
|
||||||
|
if (bodyType === "FULLHAFT" && rank) {
|
||||||
|
const halfSpecial = rank.salaryHalfSpecial ?? 0;
|
||||||
|
const fullSpecial = rank.salaryFullSpecial ?? 0;
|
||||||
|
const fullHalfSpecial = rank.salaryFullHalfSpecial ?? 0;
|
||||||
|
|
||||||
|
if (fullHalfSpecial > 0) {
|
||||||
|
if (fullSpecial === 0) profile.type = "HAFT";
|
||||||
|
else if (halfSpecial === 0) profile.type = "FULL";
|
||||||
|
else profile.type = "FULLHAFT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- คำนวณเงินเดือน (logic เหมือนเดิม) ---
|
||||||
|
const calc = (sp: keyof SalaryRanks, next: keyof SalaryRanks) => {
|
||||||
|
const amountNext = rank?.[next] ?? 0;
|
||||||
|
return {
|
||||||
|
amountSpecial: rank?.[sp] ?? 0,
|
||||||
|
amountUse: profile.amount != null ? Number(amountNext) - Number(profile.amount) : 0,
|
||||||
|
positionSalaryAmount: amountNext,
|
||||||
|
isNext: rank?.isNext ?? 0,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (profile.type) {
|
||||||
|
case "NONE":
|
||||||
|
profile.amountSpecial = 0;
|
||||||
|
profile.amountUse = 0;
|
||||||
|
profile.positionSalaryAmount = profile.amount ?? 0;
|
||||||
|
break;
|
||||||
|
case "PENDING":
|
||||||
|
profile.amountSpecial = 0;
|
||||||
|
profile.amountUse = 0;
|
||||||
|
profile.positionSalaryAmount = 0;
|
||||||
|
break;
|
||||||
|
case "HAFT":
|
||||||
|
Object.assign(profile, calc("salaryHalfSpecial", "salaryHalf"));
|
||||||
|
break;
|
||||||
|
case "FULL":
|
||||||
|
Object.assign(profile, calc("salaryFullSpecial", "salaryFull"));
|
||||||
|
break;
|
||||||
|
case "FULLHAFT":
|
||||||
|
Object.assign(profile, calc("salaryFullHalfSpecial", "salaryFullHalf"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.lastUpdateUserId = req.user.sub;
|
||||||
|
profile.lastUpdateFullName = req.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
|
// --- log diff (เหมือนเดิม) ---
|
||||||
|
const before = structuredClone(profile);
|
||||||
|
profilesToSave.push(profile);
|
||||||
|
setLogDataDiff(req, { before, after: profile });
|
||||||
|
|
||||||
|
orgNeedRecalc.add(profile.salaryOrg.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// 4) Save batch
|
||||||
|
// -----------------------------
|
||||||
|
await this.salaryProfileRepository.save(profilesToSave);
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// 5) Recalculate SalaryOrg (คง logic เดิม)
|
||||||
|
// -----------------------------
|
||||||
|
for (const orgId of orgNeedRecalc) {
|
||||||
|
const org = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: orgId },
|
||||||
|
relations: ["salaryProfiles", "salaryPeriod"],
|
||||||
|
});
|
||||||
|
if (!org) continue;
|
||||||
|
|
||||||
|
const beforeOrg = structuredClone(org);
|
||||||
|
|
||||||
|
// SNAP1 / APR
|
||||||
|
if (org.snapshot === "SNAP1" && org.salaryPeriod.period === "APR") {
|
||||||
|
const countFull = org.salaryProfiles.filter(p => p.type === "FULL").length;
|
||||||
|
org.total = org.salaryProfiles.length;
|
||||||
|
org.fifteenPercent = Math.floor(org.total * 0.15);
|
||||||
|
org.quantityUsed = countFull;
|
||||||
|
org.remainQuota = org.fifteenPercent - countFull;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SNAP1 / OCT
|
||||||
|
if (org.snapshot === "SNAP1" && org.salaryPeriod.period === "OCT") {
|
||||||
|
const total = org.salaryProfiles.reduce((sum, p) => sum + (p.amount ?? 0), 0);
|
||||||
|
org.currentAmount = total;
|
||||||
|
org.sixPercentAmount = total * 0.06;
|
||||||
|
|
||||||
|
const useAmount = org.salaryProfiles
|
||||||
|
.filter(p => ["HAFT", "FULL", "FULLHAFT"].includes(p.type))
|
||||||
|
.reduce((s, p) => s + (p.amountUse ?? 0), 0);
|
||||||
|
|
||||||
|
org.useAmount = useAmount;
|
||||||
|
org.remainingAmount = org.sixPercentAmount - useAmount;
|
||||||
|
|
||||||
|
// --- SNAP2 APR recalc (เหมือนเดิม) ---
|
||||||
|
const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: { period: "APR", year: org.salaryPeriod.year }
|
||||||
|
});
|
||||||
|
if (salaryPeriodAPROld) {
|
||||||
|
const orgSnap2Old: any = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { salaryPeriodId: salaryPeriodAPROld.id, rootId: org.rootId, group: org.group, snapshot: "SNAP2" },
|
||||||
|
relations: ["salaryProfiles"]
|
||||||
|
});
|
||||||
|
if (orgSnap2Old) {
|
||||||
|
const spent = orgSnap2Old.salaryProfiles.reduce((sum: number, p: any) => sum + (p.amountUse ?? 0), 0);
|
||||||
|
org.spentAmount = spent;
|
||||||
|
org.remainingAmount = (org.sixPercentAmount - useAmount) - spent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
org.lastUpdateUserId = req.user.sub;
|
||||||
|
org.lastUpdateFullName = req.user.name;
|
||||||
|
org.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
|
await this.salaryOrgRepository.save(org);
|
||||||
|
setLogDataDiff(req, { before: beforeOrg, after: org });
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายการอัตราเงินเดือน
|
* API รายการอัตราเงินเดือน
|
||||||
|
|
@ -1689,25 +1924,25 @@ export class SalaryPeriodController extends Controller {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if (body.sortBy) {
|
if (body.sortBy) {
|
||||||
if(body.sortBy === "posExecutive"){
|
if (body.sortBy === "posExecutive") {
|
||||||
query = query
|
query = query
|
||||||
.orderBy( `profile.posExecutive`,body.descending ? "DESC" : "ASC")
|
.orderBy(`profile.posExecutive`, body.descending ? "DESC" : "ASC")
|
||||||
.addOrderBy( `profile.positionExecutiveField`,body.descending ? "DESC" : "ASC");
|
.addOrderBy(`profile.positionExecutiveField`, body.descending ? "DESC" : "ASC");
|
||||||
}else{
|
} else {
|
||||||
query = query.orderBy(
|
query = query.orderBy(
|
||||||
`profile.${body.sortBy}`,
|
`profile.${body.sortBy}`,
|
||||||
body.descending ? "DESC" : "ASC"
|
body.descending ? "DESC" : "ASC"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
query = query.orderBy("profile.rootOrder", "ASC")
|
query = query.orderBy("profile.rootOrder", "ASC")
|
||||||
.addOrderBy("profile.child1Order", "ASC")
|
.addOrderBy("profile.child1Order", "ASC")
|
||||||
.addOrderBy("profile.child2Order", "ASC")
|
.addOrderBy("profile.child2Order", "ASC")
|
||||||
.addOrderBy("profile.child3Order", "ASC")
|
.addOrderBy("profile.child3Order", "ASC")
|
||||||
.addOrderBy("profile.child4Order", "ASC")
|
.addOrderBy("profile.child4Order", "ASC")
|
||||||
.addOrderBy("profile.posMasterNo", "ASC")
|
.addOrderBy("profile.posMasterNo", "ASC")
|
||||||
}
|
}
|
||||||
|
|
||||||
const [salaryProfile, total] = await query
|
const [salaryProfile, total] = await query
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
|
@ -1846,7 +2081,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
let type = salaryProfile.type;
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRanks
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
salaryRanks = await this.salaryRankRepository.findOne({
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
|
@ -1940,9 +2175,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalfSpecial;
|
: salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryHalf == null ||
|
salaryRanks.salaryHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1955,9 +2190,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullSpecial;
|
: salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFull == null ||
|
salaryRanks.salaryFull == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -1970,9 +2205,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalfSpecial;
|
: salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse =
|
salaryProfile.amountUse =
|
||||||
salaryRanks == null ||
|
salaryRanks == null ||
|
||||||
salaryProfile == null ||
|
salaryProfile == null ||
|
||||||
salaryRanks.salaryFullHalf == null ||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
salaryProfile.amount == null
|
salaryProfile.amount == null
|
||||||
? 0
|
? 0
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
|
|
@ -2537,17 +2772,17 @@ export class SalaryPeriodController extends Controller {
|
||||||
"salaryPeriod.revisionId",
|
"salaryPeriod.revisionId",
|
||||||
])
|
])
|
||||||
|
|
||||||
if (sortBy) {
|
if (sortBy) {
|
||||||
query = query.orderBy(
|
query = query.orderBy(
|
||||||
`salaryPeriod.${sortBy}`,
|
`salaryPeriod.${sortBy}`,
|
||||||
descending ? "DESC" : "ASC"
|
descending ? "DESC" : "ASC"
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
query = query.orderBy("salaryPeriod.year", "DESC")
|
query = query.orderBy("salaryPeriod.year", "DESC")
|
||||||
.addOrderBy("salaryPeriod.effectiveDate", "DESC")
|
.addOrderBy("salaryPeriod.effectiveDate", "DESC")
|
||||||
}
|
}
|
||||||
|
|
||||||
const [salaryPeriod, total] = await query
|
const [salaryPeriod, total] = await query
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -2794,27 +3029,27 @@ export class SalaryPeriodController extends Controller {
|
||||||
const [salaryProfileCount, salaryProfileEmployeeCount] = await Promise.all([
|
const [salaryProfileCount, salaryProfileEmployeeCount] = await Promise.all([
|
||||||
salaryOrgCount > 0
|
salaryOrgCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
SELECT COUNT(*) as count FROM salaryProfile
|
SELECT COUNT(*) as count FROM salaryProfile
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrg
|
SELECT id FROM salaryOrg
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
).then((result) => result[0]?.count || 0)
|
).then((result) => result[0]?.count || 0)
|
||||||
: Promise.resolve(0),
|
: Promise.resolve(0),
|
||||||
salaryOrgEmployeeCount > 0
|
salaryOrgEmployeeCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
SELECT COUNT(*) as count FROM salaryProfileEmployee
|
SELECT COUNT(*) as count FROM salaryProfileEmployee
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrgEmployee
|
SELECT id FROM salaryOrgEmployee
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
).then((result) => result[0]?.count || 0)
|
).then((result) => result[0]?.count || 0)
|
||||||
: Promise.resolve(0),
|
: Promise.resolve(0),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -2827,27 +3062,27 @@ export class SalaryPeriodController extends Controller {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
salaryOrgCount > 0
|
salaryOrgCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
DELETE FROM salaryProfile
|
DELETE FROM salaryProfile
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrg
|
SELECT id FROM salaryOrg
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
)
|
)
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
salaryOrgEmployeeCount > 0
|
salaryOrgEmployeeCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
DELETE FROM salaryProfileEmployee
|
DELETE FROM salaryProfileEmployee
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrgEmployee
|
SELECT id FROM salaryOrgEmployee
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
)
|
)
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -3823,27 +4058,27 @@ export class SalaryPeriodController extends Controller {
|
||||||
const [salaryProfileCount, salaryProfileEmployeeCount] = await Promise.all([
|
const [salaryProfileCount, salaryProfileEmployeeCount] = await Promise.all([
|
||||||
salaryOrgCount > 0
|
salaryOrgCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
SELECT COUNT(*) as count FROM salaryProfile
|
SELECT COUNT(*) as count FROM salaryProfile
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrg
|
SELECT id FROM salaryOrg
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
).then((result) => result[0]?.count || 0)
|
).then((result) => result[0]?.count || 0)
|
||||||
: Promise.resolve(0),
|
: Promise.resolve(0),
|
||||||
salaryOrgEmployeeCount > 0
|
salaryOrgEmployeeCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
SELECT COUNT(*) as count FROM salaryProfileEmployee
|
SELECT COUNT(*) as count FROM salaryProfileEmployee
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrgEmployee
|
SELECT id FROM salaryOrgEmployee
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
).then((result) => result[0]?.count || 0)
|
).then((result) => result[0]?.count || 0)
|
||||||
: Promise.resolve(0),
|
: Promise.resolve(0),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -3856,27 +4091,27 @@ export class SalaryPeriodController extends Controller {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
salaryOrgCount > 0
|
salaryOrgCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
DELETE FROM salaryProfile
|
DELETE FROM salaryProfile
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrg
|
SELECT id FROM salaryOrg
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
)
|
)
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
salaryOrgEmployeeCount > 0
|
salaryOrgEmployeeCount > 0
|
||||||
? AppDataSource.query(
|
? AppDataSource.query(
|
||||||
`
|
`
|
||||||
DELETE FROM salaryProfileEmployee
|
DELETE FROM salaryProfileEmployee
|
||||||
WHERE salaryOrgId IN (
|
WHERE salaryOrgId IN (
|
||||||
SELECT id FROM salaryOrgEmployee
|
SELECT id FROM salaryOrgEmployee
|
||||||
WHERE salaryPeriodId = ? AND snapshot = ?
|
WHERE salaryPeriodId = ? AND snapshot = ?
|
||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
[salaryPeriod.id, snapshot],
|
[salaryPeriod.id, snapshot],
|
||||||
)
|
)
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -3928,22 +4163,22 @@ export class SalaryPeriodController extends Controller {
|
||||||
// Parallel loading of initial data and API calls
|
// Parallel loading of initial data and API calls
|
||||||
console.time("⏱ API: Load initial data");
|
console.time("⏱ API: Load initial data");
|
||||||
const [orgs, revisionId, _orgProfiles, _orgProfileEmployees] = await Promise.all([
|
const [orgs, revisionId, _orgProfiles, _orgProfileEmployees] = await Promise.all([
|
||||||
new CallAPI().GetData({ headers: { authorization: request } }, "/org/unauthorize/active/root/id",false),
|
new CallAPI().GetData({ headers: { authorization: request } }, "/org/unauthorize/active/root/id", false),
|
||||||
new CallAPI().GetData({ headers: { authorization: request } }, "/org/unauthorize/revision/latest",false),
|
new CallAPI().GetData({ headers: { authorization: request } }, "/org/unauthorize/revision/latest", false),
|
||||||
new CallAPI().PostData({ headers: { authorization: request } }, "/org/unauthorize/new-salary/gen", {
|
new CallAPI().PostData({ headers: { authorization: request } }, "/org/unauthorize/new-salary/gen", {
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 1000,
|
pageSize: 1000,
|
||||||
keyword: "",
|
keyword: "",
|
||||||
year: salaryPeriod.year,
|
year: salaryPeriod.year,
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
},false),
|
}, false),
|
||||||
new CallAPI().PostData({ headers: { authorization: request } }, "/org/unauthorize/new-salary/employee/gen", {
|
new CallAPI().PostData({ headers: { authorization: request } }, "/org/unauthorize/new-salary/employee/gen", {
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 1000,
|
pageSize: 1000,
|
||||||
keyword: "",
|
keyword: "",
|
||||||
year: salaryPeriod.year,
|
year: salaryPeriod.year,
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
},false),
|
}, false),
|
||||||
]);
|
]);
|
||||||
console.timeEnd("⏱ API: Load initial data");
|
console.timeEnd("⏱ API: Load initial data");
|
||||||
|
|
||||||
|
|
@ -3964,7 +4199,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
keyword: "",
|
keyword: "",
|
||||||
year: salaryPeriod.year,
|
year: salaryPeriod.year,
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
},false),
|
}, false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const results = await Promise.all(promises);
|
const results = await Promise.all(promises);
|
||||||
|
|
@ -3989,7 +4224,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
keyword: "",
|
keyword: "",
|
||||||
year: salaryPeriod.year,
|
year: salaryPeriod.year,
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
},false),
|
}, false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const results = await Promise.all(promises);
|
const results = await Promise.all(promises);
|
||||||
|
|
@ -4713,8 +4948,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let request:any = response.data.access_token;
|
let request: any = response.data.access_token;
|
||||||
|
|
||||||
if (current.getDate() == 1 && current.getMonth() == 2) { //snap1 วันที่ 1 มีนา
|
if (current.getDate() == 1 && current.getMonth() == 2) { //snap1 วันที่ 1 มีนา
|
||||||
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue