Merge branch 'develop' into develop-Bright
This commit is contained in:
commit
0f28e9d531
7 changed files with 476 additions and 125 deletions
|
|
@ -15,7 +15,7 @@ import {
|
||||||
Query,
|
Query,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { DeepPartial, In, IsNull, Not, Between, MoreThan } from "typeorm";
|
import { DeepPartial, In, IsNull, Not, Between, MoreThan, Like, Brackets } from "typeorm";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
|
|
@ -46,14 +46,13 @@ export class SalaryPeriodController extends Controller {
|
||||||
* @summary SLR_030 - รอบล่าสุด #29
|
* @summary SLR_030 - รอบล่าสุด #29
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("latest/{id}")
|
@Post("latest")
|
||||||
async GetGroupSalaryPeriodLatest(@Path() id: string) {
|
async GetGroupSalaryPeriodLatest(
|
||||||
//xxxx รอบเงินเดือนล่าสุดยังไม่แน่ใจเอาจากรอบไหน
|
@Body() body: { rootId: string; salaryPeriodId: string; snapshot: string },
|
||||||
//xxxx หาสังกัดคนนั้น
|
) {
|
||||||
// const dateNow = new Date();
|
|
||||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
// effectiveDate: MoreThan(dateNow),
|
id: body.salaryPeriodId,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
order: { effectiveDate: "DESC" },
|
order: { effectiveDate: "DESC" },
|
||||||
|
|
@ -65,13 +64,33 @@ export class SalaryPeriodController extends Controller {
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
group1id:
|
group1id:
|
||||||
salaryPeriod.salaryOrgs.find((x) => x.group == "GROUP1" && x.rootId == id) == null
|
salaryPeriod.salaryOrgs.find(
|
||||||
|
(x) =>
|
||||||
|
x.group == "GROUP1" &&
|
||||||
|
x.rootId == body.rootId &&
|
||||||
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
|
) == null
|
||||||
? null
|
? null
|
||||||
: salaryPeriod.salaryOrgs.find((x) => x.group == "GROUP1" && x.rootId == id)?.id,
|
: salaryPeriod.salaryOrgs.find(
|
||||||
|
(x) =>
|
||||||
|
x.group == "GROUP1" &&
|
||||||
|
x.rootId == body.rootId &&
|
||||||
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
|
)?.id,
|
||||||
group2id:
|
group2id:
|
||||||
salaryPeriod.salaryOrgs.find((x) => x.group == "GROUP2" && x.rootId == id) == null
|
salaryPeriod.salaryOrgs.find(
|
||||||
|
(x) =>
|
||||||
|
x.group == "GROUP2" &&
|
||||||
|
x.rootId == body.rootId &&
|
||||||
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
|
) == null
|
||||||
? null
|
? null
|
||||||
: salaryPeriod.salaryOrgs.find((x) => x.group == "GROUP2" && x.rootId == id)?.id,
|
: salaryPeriod.salaryOrgs.find(
|
||||||
|
(x) =>
|
||||||
|
x.group == "GROUP2" &&
|
||||||
|
x.rootId == body.rootId &&
|
||||||
|
x.snapshot == body.snapshot.toLocaleUpperCase(),
|
||||||
|
)?.id,
|
||||||
effectiveDate: salaryPeriod.effectiveDate,
|
effectiveDate: salaryPeriod.effectiveDate,
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
};
|
};
|
||||||
|
|
@ -164,36 +183,62 @@ export class SalaryPeriodController extends Controller {
|
||||||
}
|
}
|
||||||
//Salary
|
//Salary
|
||||||
const salarys = await this.salaryRepository.findOne({
|
const salarys = await this.salaryRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeId : Level.posTypeId,
|
posTypeId: Level.posTypeId,
|
||||||
posLevelId : Level.id,
|
posLevelId: Level.id,
|
||||||
isActive : true
|
isActive: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
//SalaryRank
|
if (!salarys) {
|
||||||
const SalaryRanks = await this.salaryRankRepository.findOne({
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
where: {
|
}
|
||||||
salaryId: salarys?.id,
|
//SalaryRank
|
||||||
salary: salaryProfile.amount
|
let salaryRanks: any = null;
|
||||||
}
|
if (salaryProfile.amount != null) {
|
||||||
});
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
if (!SalaryRanks) {
|
where: {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบผังเงินเดือน");
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (salaryProfile.type == "NONE") {
|
|
||||||
|
|
||||||
|
if (salaryProfile.type == "NONE") {
|
||||||
|
salaryProfile.amountSpecial = 0;
|
||||||
|
salaryProfile.amountUse = 0;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryProfile.amount;
|
||||||
} else if (salaryProfile.type == "HAFT") {
|
} else if (salaryProfile.type == "HAFT") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryHalfSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryHalf) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryHalf);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryHalf == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryHalf;
|
||||||
} else if (salaryProfile.type == "FULL") {
|
} else if (salaryProfile.type == "FULL") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryFullSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryFull) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryFull);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryFull == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFull;
|
||||||
} else if (salaryProfile.type == "FULLHAFT") {
|
} else if (salaryProfile.type == "FULLHAFT") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryFullHalfSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryFullHalf) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryFullHalf);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFullHalf;
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.salaryProfileRepository.save(salaryProfile);
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
|
@ -264,34 +309,59 @@ export class SalaryPeriodController extends Controller {
|
||||||
}
|
}
|
||||||
//Salary
|
//Salary
|
||||||
const salarys = await this.salaryRepository.findOne({
|
const salarys = await this.salaryRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeId : Level.posTypeId,
|
posTypeId: Level.posTypeId,
|
||||||
posLevelId : Level.id,
|
posLevelId: Level.id,
|
||||||
isActive : true
|
isActive: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
if (!salarys) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
|
}
|
||||||
//SalaryRank
|
//SalaryRank
|
||||||
const SalaryRanks = await this.salaryRankRepository.findOne({
|
let salaryRanks: any = null;
|
||||||
where: {
|
if (salaryProfile.amount != null) {
|
||||||
salaryId: salarys?.id,
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
salary: salaryProfile.amount
|
where: {
|
||||||
}
|
salaryId: salarys.id,
|
||||||
});
|
salary: salaryProfile.amount,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
if (body.type == "NONE") {
|
if (body.type == "NONE") {
|
||||||
|
salaryProfile.amountSpecial = 0;
|
||||||
|
salaryProfile.amountUse = 0;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryProfile.amount;
|
||||||
} else if (body.type == "HAFT") {
|
} else if (body.type == "HAFT") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryHalfSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryHalf) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryHalf);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryHalf == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryHalf;
|
||||||
} else if (body.type == "FULL") {
|
} else if (body.type == "FULL") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryFullSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryFull) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryFull);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryFull == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFull;
|
||||||
} else if (body.type == "FULLHAFT") {
|
} else if (body.type == "FULLHAFT") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryFullHalfSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryFullHalf) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryFullHalf);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFullHalf;
|
||||||
} else {
|
} else {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
|
@ -319,32 +389,44 @@ export class SalaryPeriodController extends Controller {
|
||||||
if (!salaryOrg) {
|
if (!salaryOrg) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [salaryProfile, total] = await AppDataSource.getRepository(SalaryProfile)
|
const [salaryProfile, total] = await AppDataSource.getRepository(SalaryProfile)
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.andWhere({
|
.orWhere(
|
||||||
salaryOrgId: salaryOrg.id,
|
new Brackets((qb) => {
|
||||||
})
|
qb.andWhere(body.type != null && body.type != "" ? "profile.type LIKE :type" : "1=1", {
|
||||||
.andWhere(body.type != null && body.type != "" ? "profile.type LIKE :type" : "1=1", {
|
type: `%${body.type.toUpperCase()}%`,
|
||||||
type: `%${body.type}%`,
|
})
|
||||||
})
|
.andWhere({
|
||||||
//xxxx รอ fe ว่าแสดงค่าไหนบ่างใหเfilterเฉพาะค่านั้น
|
salaryOrgId: salaryOrg.id,
|
||||||
.orWhere("profile.posMasterNoPrefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
})
|
||||||
.orWhere("profile.posMasterNo LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.andWhere(
|
||||||
.orWhere("profile.posMasterNoSuffix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
new Brackets((qb) => {
|
||||||
.orWhere("profile.orgShortName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
qb.orWhere("profile.posMasterNoPrefix LIKE :keyword", {
|
||||||
.orWhere("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
keyword: `%${body.keyword}%`,
|
||||||
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
})
|
||||||
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.posMasterNo LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
// .orWhere("profile.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.posMasterNoSuffix LIKE :keyword", {
|
||||||
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
keyword: `%${body.keyword}%`,
|
||||||
// .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` })
|
})
|
||||||
// .orWhere("profile.posLevel LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.orgShortName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
// .orWhere("profile.posExecutive LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere("profile.amount LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere("profile.amountSpecial LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere("profile.amountUse LIKE :keyword", { keyword: `%${body.keyword}%` })
|
// .orWhere("profile.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere("profile.positionSalaryAmount LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
// .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
// .orWhere("profile.posLevel LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
// .orWhere("profile.posExecutive LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.amount LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.amountSpecial LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.amountUse LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.positionSalaryAmount LIKE :keyword", {
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
.orderBy("profile.citizenId", "ASC")
|
.orderBy("profile.citizenId", "ASC")
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
|
|
@ -399,52 +481,79 @@ export class SalaryPeriodController extends Controller {
|
||||||
const salaryProfile = Object.assign(new SalaryProfile(), requestBody);
|
const salaryProfile = Object.assign(new SalaryProfile(), requestBody);
|
||||||
salaryProfile.type = salaryProfile.type.toUpperCase();
|
salaryProfile.type = salaryProfile.type.toUpperCase();
|
||||||
//Type & Level
|
//Type & Level
|
||||||
const Type = await this.posTypeRepository.findOne({
|
const type = await this.posTypeRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeName: salaryProfile.posType,
|
posTypeName: salaryProfile.posType,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!Type) {
|
if (!type) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทตำแหน่ง");
|
||||||
}
|
}
|
||||||
const Level = await this.posLevelRepository.findOne({
|
const level = await this.posLevelRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeId: Type.id,
|
posTypeId: type.id,
|
||||||
posLevelName: salaryProfile.posLevel,
|
posLevelName: salaryProfile.posLevel,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!Level) {
|
if (!level) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
//Salary
|
//Salary
|
||||||
const salarys = await this.salaryRepository.findOne({
|
const salarys = await this.salaryRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeId : Level.posTypeId,
|
posTypeId: level.posTypeId,
|
||||||
posLevelId : Level.id,
|
posLevelId: level.id,
|
||||||
isActive : true
|
isActive: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
if (!salarys) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
|
}
|
||||||
//SalaryRank
|
//SalaryRank
|
||||||
const SalaryRanks = await this.salaryRankRepository.findOne({
|
let salaryRanks: any = null;
|
||||||
where: {
|
if (salaryProfile.amount != null) {
|
||||||
salaryId: salarys?.id,
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
salary: salaryProfile.amount
|
where: {
|
||||||
}
|
salaryId: salarys.id,
|
||||||
});
|
salary: salaryProfile.amount,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (salaryProfile.type == "NONE") {
|
if (salaryProfile.type == "NONE") {
|
||||||
|
salaryProfile.amountSpecial = 0;
|
||||||
|
salaryProfile.amountUse = 0;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryProfile.amount;
|
||||||
} else if (salaryProfile.type == "HAFT") {
|
} else if (salaryProfile.type == "HAFT") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryHalfSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryHalfSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryHalf) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryHalf);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryHalf == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryHalf;
|
||||||
} else if (salaryProfile.type == "FULL") {
|
} else if (salaryProfile.type == "FULL") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryFullSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryFullSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryFull) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryFull);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryFull == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFull;
|
||||||
} else if (salaryProfile.type == "FULLHAFT") {
|
} else if (salaryProfile.type == "FULLHAFT") {
|
||||||
salaryProfile.amountSpecial = Number(SalaryRanks?.salaryFullHalfSpecial);
|
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryFullHalfSpecial;
|
||||||
salaryProfile.amountUse = Number(SalaryRanks?.salaryFullHalf) - salaryProfile.amount;
|
salaryProfile.amountUse =
|
||||||
salaryProfile.positionSalaryAmount = Number(SalaryRanks?.salaryFullHalf);
|
salaryRanks == null ||
|
||||||
|
salaryProfile == null ||
|
||||||
|
salaryRanks.salaryFullHalf == null ||
|
||||||
|
salaryProfile.amount == null
|
||||||
|
? 0
|
||||||
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
|
salaryProfile.positionSalaryAmount = salaryRanks == null ? 0 : salaryRanks.salaryFullHalf;
|
||||||
} else {
|
} else {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
|
@ -563,9 +672,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี");
|
||||||
}
|
}
|
||||||
const SalaryOrg = await this.salaryOrgRepository.findOne({
|
const SalaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
where: { salaryPeriodId: SalaryPeriod.id }
|
where: { salaryPeriodId: SalaryPeriod.id },
|
||||||
})
|
});
|
||||||
if(SalaryOrg){
|
if (SalaryOrg) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้");
|
||||||
}
|
}
|
||||||
await this.salaryPeriodRepository.remove(SalaryPeriod);
|
await this.salaryPeriodRepository.remove(SalaryPeriod);
|
||||||
|
|
@ -583,7 +692,16 @@ export class SalaryPeriodController extends Controller {
|
||||||
async GetSalaryPeriod_ById(@Path() id: string) {
|
async GetSalaryPeriod_ById(@Path() id: string) {
|
||||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["id", "period", "isActive", "effectiveDate", "isActive", "status", "year"],
|
select: [
|
||||||
|
"id",
|
||||||
|
"period",
|
||||||
|
"isActive",
|
||||||
|
"effectiveDate",
|
||||||
|
"isActive",
|
||||||
|
"status",
|
||||||
|
"year",
|
||||||
|
"revisionId",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
if (!salaryPeriod) {
|
if (!salaryPeriod) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี");
|
||||||
|
|
@ -605,24 +723,152 @@ export class SalaryPeriodController extends Controller {
|
||||||
@Query("year") year: number = 2024,
|
@Query("year") year: number = 2024,
|
||||||
) {
|
) {
|
||||||
const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod)
|
const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod)
|
||||||
.createQueryBuilder("SalaryPeriod")
|
.createQueryBuilder("salaryPeriod")
|
||||||
.andWhere(year != 0 ? "SalaryPeriod.year LIKE :year" : "1=1", { year: `%${year}%` })
|
.andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `%${year}%` })
|
||||||
.orWhere("SalaryPeriod.period LIKE :keyword", { keyword: `%${keyword}%` })
|
.orWhere("salaryPeriod.period LIKE :keyword", { keyword: `%${keyword}%` })
|
||||||
.orWhere("SalaryPeriod.isActive LIKE :keyword", { keyword: `%${keyword}%` })
|
.orWhere("salaryPeriod.isActive LIKE :keyword", { keyword: `%${keyword}%` })
|
||||||
.orWhere("SalaryPeriod.year LIKE :keyword", { keyword: `%${year}%` })
|
.orWhere("salaryPeriod.year LIKE :keyword", { keyword: `%${year}%` })
|
||||||
.select([
|
.select([
|
||||||
"SalaryPeriod.id",
|
"salaryPeriod.id",
|
||||||
"SalaryPeriod.period",
|
"salaryPeriod.period",
|
||||||
"SalaryPeriod.isActive",
|
"salaryPeriod.isActive",
|
||||||
"SalaryPeriod.effectiveDate",
|
"salaryPeriod.effectiveDate",
|
||||||
"SalaryPeriod.status",
|
"salaryPeriod.status",
|
||||||
"SalaryPeriod.year",
|
"salaryPeriod.year",
|
||||||
|
"salaryPeriod.revisionId",
|
||||||
])
|
])
|
||||||
.orderBy("SalaryPeriod.effectiveDate", "DESC")
|
.orderBy("salaryPeriod.effectiveDate", "DESC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
return new HttpSuccess({ data: salaryPeriod, total });
|
return new HttpSuccess({ data: salaryPeriod, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รายการรอบเงินเดือน
|
||||||
|
*
|
||||||
|
* @summary SLR_020 - รายการรอบเงินเดือน #20
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("snapshot/{snaphot}/{salaryPeriodId}")
|
||||||
|
async SnapshotSalary(
|
||||||
|
@Path() snaphot: string,
|
||||||
|
salaryPeriodId: string,
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
snaphot = snaphot.toLocaleUpperCase();
|
||||||
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: { id: salaryPeriodId },
|
||||||
|
});
|
||||||
|
if (!salaryPeriod) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการสร้างเงินเดือน");
|
||||||
|
}
|
||||||
|
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.find({
|
||||||
|
where: { salaryPeriodId: salaryPeriod.id, snapshot: snaphot },
|
||||||
|
});
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.find({
|
||||||
|
where: { salaryOrgId: In(salaryOrg.map((x) => x.id)) },
|
||||||
|
});
|
||||||
|
await this.salaryOrgRepository.remove(salaryOrg);
|
||||||
|
await this.salaryProfileRepository.remove(salaryProfile);
|
||||||
|
|
||||||
|
let orgs: any;
|
||||||
|
let orgProfiles: any;
|
||||||
|
let revisionId: any;
|
||||||
|
|
||||||
|
salaryPeriod.revisionId = revisionId;
|
||||||
|
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
orgs.map(async (rootId: string) => {
|
||||||
|
let salaryOrgNew = Object.assign(new SalaryOrg());
|
||||||
|
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
|
||||||
|
salaryOrgNew.status = "PENDING";
|
||||||
|
salaryOrgNew.rootId = rootId;
|
||||||
|
salaryOrgNew.revisionId = salaryPeriod.revisionId;
|
||||||
|
salaryOrgNew.snapshot = snaphot;
|
||||||
|
salaryOrgNew.group = "GROUP1";
|
||||||
|
salaryOrgNew.createdUserId = request.user.sub;
|
||||||
|
salaryOrgNew.createdFullName = request.user.name;
|
||||||
|
salaryOrgNew.lastUpdateUserId = request.user.sub;
|
||||||
|
salaryOrgNew.lastUpdateFullName = request.user.name;
|
||||||
|
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||||
|
delete salaryOrgNew.id;
|
||||||
|
salaryOrgNew.group = "GROUP2";
|
||||||
|
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
let salaryProfileOld: SalaryProfile[] = [];
|
||||||
|
if (snaphot == "SNAP2") {
|
||||||
|
const salaryOrgOld = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { salaryPeriodId: salaryPeriod.id, snapshot: snaphot },
|
||||||
|
relations: ["salaryProfiles"],
|
||||||
|
});
|
||||||
|
if (salaryOrgOld != null) salaryProfileOld = salaryOrgOld.salaryProfiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
orgProfiles.map(async (profile: any) => {
|
||||||
|
let group = "GROUP1";
|
||||||
|
if (
|
||||||
|
(profile.posType == "ทั่วไป" && profile.posLevel == "ทักษะพิเศษ") ||
|
||||||
|
(profile.posType == "วิชาการ" && profile.posLevel == "เชี่ยวชาญ") ||
|
||||||
|
(profile.posType == "วิชาการ" && profile.posLevel == "ทรงคุณวุฒิ") ||
|
||||||
|
(profile.posType == "อำนวยการ" && profile.posLevel == "สูง") ||
|
||||||
|
(profile.posType == "บริหาร" && profile.posLevel == "ต้น") ||
|
||||||
|
(profile.posType == "บริหาร" && profile.posLevel == "สูง")
|
||||||
|
) {
|
||||||
|
group = "GROUP2";
|
||||||
|
}
|
||||||
|
const salaryOrgNew = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryPeriod.id,
|
||||||
|
rootId: profile.rootId,
|
||||||
|
snapshot: snaphot,
|
||||||
|
group: group,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (salaryOrgNew != null) {
|
||||||
|
let salaryProfileNew = Object.assign(new SalaryProfile(), 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 (snaphot == "SNAP2") {
|
||||||
|
const salaryOld = salaryProfileOld.find(
|
||||||
|
(x) => x.citizenId == salaryProfileNew.citizenId,
|
||||||
|
);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||||
|
where: { salaryPeriodId: salaryPeriod.id, snapshot: snaphot },
|
||||||
|
relations: ["salaryProfiles"],
|
||||||
|
});
|
||||||
|
await Promise.all(
|
||||||
|
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||||
|
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||||
|
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||||
|
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||||
|
await this.salaryOrgRepository.save(_salaryOrg);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,20 @@ export class SalaryOrg extends EntityBase {
|
||||||
})
|
})
|
||||||
rootId: string;
|
rootId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "id revision",
|
||||||
|
length: 40,
|
||||||
|
})
|
||||||
|
revisionId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "รอบการ Snapshot",
|
||||||
|
length: 20,
|
||||||
|
default: "SNAP1",
|
||||||
|
})
|
||||||
|
snapshot: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "จำนวนคนทั้งหมด",
|
comment: "จำนวนคนทั้งหมด",
|
||||||
})
|
})
|
||||||
|
|
@ -37,7 +51,7 @@ export class SalaryOrg extends EntityBase {
|
||||||
type: "double",
|
type: "double",
|
||||||
default: 0,
|
default: 0,
|
||||||
})
|
})
|
||||||
fifteenPoint: Double;
|
fifteenPoint: number;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2",
|
comment: "กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2",
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ export class SalaryPeriod extends EntityBase {
|
||||||
})
|
})
|
||||||
year: number;
|
year: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "id revision",
|
||||||
|
length: 40,
|
||||||
|
})
|
||||||
|
revisionId: string;
|
||||||
|
|
||||||
@OneToMany(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryPeriod)
|
@OneToMany(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryPeriod)
|
||||||
salaryOrgs: SalaryOrg[];
|
salaryOrgs: SalaryOrg[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ export class SalaryProfile extends EntityBase {
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
type: "double",
|
||||||
comment: "เงินเดือนฐาน",
|
comment: "เงินเดือนฐาน",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
|
|
@ -114,6 +115,7 @@ export class SalaryProfile extends EntityBase {
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
type: "double",
|
||||||
comment: "เงินพิเศษ",
|
comment: "เงินพิเศษ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
|
|
@ -121,17 +123,19 @@ export class SalaryProfile extends EntityBase {
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
type: "double",
|
||||||
comment: "จำนวนเงินที่ใช้เลื่อน",
|
comment: "จำนวนเงินที่ใช้เลื่อน",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
amountUse: number;
|
amountUse: number | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
type: "double",
|
||||||
comment: "เงินเดือนหลังเลื่อน",
|
comment: "เงินเดือนหลังเลื่อน",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
positionSalaryAmount: number;
|
positionSalaryAmount: number | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment:
|
comment:
|
||||||
|
|
@ -141,6 +145,20 @@ export class SalaryProfile extends EntityBase {
|
||||||
})
|
})
|
||||||
type: string;
|
type: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "สถานะ",
|
||||||
|
length: 20,
|
||||||
|
default: "PENDING",
|
||||||
|
})
|
||||||
|
status: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "id revision",
|
||||||
|
length: 40,
|
||||||
|
})
|
||||||
|
revisionId: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "",
|
comment: "",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableSalaryProfileAddIsresult11709033553523 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableSalaryProfileAddIsresult11709033553523'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryPeriod\` CHANGE \`year\` \`year\` int NULL COMMENT 'ปีงบประมาณ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`amount\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`amount\` double NULL COMMENT 'เงินเดือนฐาน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`amountSpecial\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`amountUse\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`amountUse\` double NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`positionSalaryAmount\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`positionSalaryAmount\` double NULL COMMENT 'เงินเดือนหลังเลื่อน'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`positionSalaryAmount\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`positionSalaryAmount\` int NULL COMMENT 'เงินเดือนหลังเลื่อน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`amountUse\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`amountUse\` int NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`amountSpecial\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`amountSpecial\` int NULL COMMENT 'เงินพิเศษ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`amount\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`amount\` int NULL COMMENT 'เงินเดือนฐาน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryPeriod\` CHANGE \`year\` \`year\` int NULL COMMENT 'ปีงบหระมาณ'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableSalaryProfileAddRevision1709080437599 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableSalaryProfileAddRevision1709080437599'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`revisionId\` varchar(40) NULL COMMENT 'id revision'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD \`revisionId\` varchar(40) NULL COMMENT 'id revision'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD \`snapshot\` varchar(20) NOT NULL COMMENT 'รอบการ Snapshot' DEFAULT 'SHAP1'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryPeriod\` ADD \`revisionId\` varchar(40) NULL COMMENT 'id revision'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryPeriod\` DROP COLUMN \`revisionId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP COLUMN \`snapshot\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP COLUMN \`revisionId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`revisionId\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableSalaryProfileAddRevision21709090519266 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableSalaryProfileAddRevision21709090519266'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`status\` varchar(20) NOT NULL COMMENT 'สถานะ' DEFAULT 'PENDING'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`snapshot\` \`snapshot\` varchar(20) NOT NULL COMMENT 'รอบการ Snapshot' DEFAULT 'SNAP1'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` CHANGE \`snapshot\` \`snapshot\` varchar(20) NOT NULL COMMENT 'รอบการ Snapshot' DEFAULT 'SHAP1'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`status\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue