แก้ไขเงินเดือน
This commit is contained in:
parent
f79704c7a7
commit
bf12751bfa
10 changed files with 969 additions and 582 deletions
|
|
@ -32,9 +32,7 @@ import { Not } from "typeorm";
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
|
|
||||||
export class PosLevelController extends Controller {
|
export class PosLevelController extends Controller {
|
||||||
|
|
||||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||||
|
|
||||||
|
|
@ -45,14 +43,12 @@ export class PosLevelController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post()
|
@Post()
|
||||||
@Example(
|
@Example({
|
||||||
{
|
|
||||||
posLevelName: "นักบริหาร",
|
posLevelName: "นักบริหาร",
|
||||||
posLevelRank: 1,
|
posLevelRank: 1,
|
||||||
posLevelAuthority: "HEAD",
|
posLevelAuthority: "HEAD",
|
||||||
posTypeId: "08db9e81-fc46-4e95-8b33-be4ca0016abf"
|
posTypeId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||||
},
|
})
|
||||||
)
|
|
||||||
async createLevel(
|
async createLevel(
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: CreatePosLevel,
|
requestBody: CreatePosLevel,
|
||||||
|
|
@ -62,19 +58,29 @@ export class PosLevelController extends Controller {
|
||||||
if (!posLevel) {
|
if (!posLevel) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
const chkPosTypeId = await this.posTypeRepository.findOne({ where: {
|
const chkPosTypeId = await this.posTypeRepository.findOne({
|
||||||
id: requestBody.posTypeId }
|
where: {
|
||||||
})
|
id: requestBody.posTypeId,
|
||||||
if(!chkPosTypeId){
|
},
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId);
|
});
|
||||||
|
if (!chkPosTypeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chkPosLevelName = await this.posLevelRepository.findOne({ where: {
|
const chkPosLevelName = await this.posLevelRepository.findOne({
|
||||||
|
where: {
|
||||||
posTypeId: requestBody.posTypeId, //ระดับประเภทเดียวกัน ชื่อระดับตำแหน่ง ห้ามซ้ำ
|
posTypeId: requestBody.posTypeId, //ระดับประเภทเดียวกัน ชื่อระดับตำแหน่ง ห้ามซ้ำ
|
||||||
posLevelName: requestBody.posLevelName }
|
posLevelName: requestBody.posLevelName,
|
||||||
})
|
},
|
||||||
if(chkPosLevelName){
|
});
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว");
|
if (chkPosLevelName) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"];
|
const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"];
|
||||||
|
|
@ -105,12 +111,10 @@ export class PosLevelController extends Controller {
|
||||||
* @param {string} id Id ระดับตำแหน่ง
|
* @param {string} id Id ระดับตำแหน่ง
|
||||||
*/
|
*/
|
||||||
@Put("{id}")
|
@Put("{id}")
|
||||||
@Example(
|
@Example({
|
||||||
{
|
|
||||||
positionName: "นักบริหาร",
|
positionName: "นักบริหาร",
|
||||||
posTypeRank: 1,
|
posTypeRank: 1,
|
||||||
},
|
})
|
||||||
)
|
|
||||||
async editLevel(
|
async editLevel(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: UpdatePosLevel,
|
@Body() requestBody: UpdatePosLevel,
|
||||||
|
|
@ -121,20 +125,30 @@ export class PosLevelController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chkPosTypeId = await this.posTypeRepository.findOne({ where: {
|
const chkPosTypeId = await this.posTypeRepository.findOne({
|
||||||
id: requestBody.posTypeId }
|
where: {
|
||||||
})
|
id: requestBody.posTypeId,
|
||||||
if(!chkPosTypeId){
|
},
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId);
|
});
|
||||||
|
if (!chkPosTypeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chkPosLevelName = await this.posLevelRepository.findOne({ where: {
|
const chkPosLevelName = await this.posLevelRepository.findOne({
|
||||||
|
where: {
|
||||||
id: Not(id),
|
id: Not(id),
|
||||||
posTypeId: requestBody.posTypeId,
|
posTypeId: requestBody.posTypeId,
|
||||||
posLevelName: requestBody.posLevelName }
|
posLevelName: requestBody.posLevelName,
|
||||||
})
|
},
|
||||||
if(chkPosLevelName){
|
});
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว");
|
if (chkPosLevelName) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"];
|
const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"];
|
||||||
if (
|
if (
|
||||||
|
|
@ -184,8 +198,7 @@ export class PosLevelController extends Controller {
|
||||||
* @param {string} id Id ระดับตำแหน่ง
|
* @param {string} id Id ระดับตำแหน่ง
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
@Example(
|
@Example({
|
||||||
{
|
|
||||||
id: "00000000-0000-0000-0000-000000000000",
|
id: "00000000-0000-0000-0000-000000000000",
|
||||||
posLevelName: "นักบริหาร",
|
posLevelName: "นักบริหาร",
|
||||||
posLevelRank: 1,
|
posLevelRank: 1,
|
||||||
|
|
@ -195,14 +208,13 @@ export class PosLevelController extends Controller {
|
||||||
posTypeName: "นักบริหาร",
|
posTypeName: "นักบริหาร",
|
||||||
posTypeRank: 1,
|
posTypeRank: 1,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
)
|
|
||||||
async GetLevelDetail(@Path() id: string) {
|
async GetLevelDetail(@Path() id: string) {
|
||||||
// try {
|
// try {
|
||||||
const getPosType = await this.posLevelRepository.findOne({
|
const getPosType = await this.posLevelRepository.findOne({
|
||||||
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority"],
|
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority"],
|
||||||
relations: ["posType"],
|
relations: ["posType"],
|
||||||
where: { id: id }
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!getPosType) {
|
if (!getPosType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||||
|
|
@ -213,12 +225,12 @@ export class PosLevelController extends Controller {
|
||||||
posLevelName: getPosType.posLevelName,
|
posLevelName: getPosType.posLevelName,
|
||||||
posLevelRank: getPosType.posLevelRank,
|
posLevelRank: getPosType.posLevelRank,
|
||||||
posLevelAuthority: getPosType.posLevelAuthority,
|
posLevelAuthority: getPosType.posLevelAuthority,
|
||||||
posTypes:{
|
posTypes: {
|
||||||
id: getPosType.posType.id,
|
id: getPosType.posType.id,
|
||||||
posTypeName: getPosType.posType.posTypeName,
|
posTypeName: getPosType.posType.posTypeName,
|
||||||
posTypeRank: getPosType.posType.posTypeRank
|
posTypeRank: getPosType.posType.posTypeRank,
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
return new HttpSuccess(mapPosLevel);
|
return new HttpSuccess(mapPosLevel);
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
|
|
@ -252,9 +264,7 @@ export class PosLevelController extends Controller {
|
||||||
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority", "posTypeId"],
|
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority", "posTypeId"],
|
||||||
relations: ["posType"],
|
relations: ["posType"],
|
||||||
});
|
});
|
||||||
if (!posLevel) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
const mapPosLevel = posLevel.map((item) => ({
|
const mapPosLevel = posLevel.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
posLevelName: item.posLevelName,
|
posLevelName: item.posLevelName,
|
||||||
|
|
@ -264,7 +274,7 @@ export class PosLevelController extends Controller {
|
||||||
id: item.posType.id,
|
id: item.posType.id,
|
||||||
posTypeName: item.posType.posTypeName,
|
posTypeName: item.posType.posTypeName,
|
||||||
posTypeRank: item.posType.posTypeRank,
|
posTypeRank: item.posType.posTypeRank,
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(mapPosLevel);
|
return new HttpSuccess(mapPosLevel);
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,7 @@ import { Not } from "typeorm";
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
|
|
||||||
export class PosTypeController extends Controller {
|
export class PosTypeController extends Controller {
|
||||||
|
|
||||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||||
|
|
||||||
|
|
@ -45,12 +43,10 @@ export class PosTypeController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post()
|
@Post()
|
||||||
@Example(
|
@Example({
|
||||||
{
|
|
||||||
positionName: "นักบริหาร",
|
positionName: "นักบริหาร",
|
||||||
posTypeRank: 1,
|
posTypeRank: 1,
|
||||||
},
|
})
|
||||||
)
|
|
||||||
async createType(
|
async createType(
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: CreatePosType,
|
requestBody: CreatePosType,
|
||||||
|
|
@ -60,11 +56,16 @@ export class PosTypeController extends Controller {
|
||||||
if (!posType) {
|
if (!posType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
const chkPosTypeName = await this.posTypeRepository.findOne({ where: {
|
const chkPosTypeName = await this.posTypeRepository.findOne({
|
||||||
posTypeName: requestBody.posTypeName }
|
where: {
|
||||||
})
|
posTypeName: requestBody.posTypeName,
|
||||||
if(chkPosTypeName){
|
},
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว");
|
});
|
||||||
|
if (chkPosTypeName) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
posType.createdUserId = request.user.sub;
|
posType.createdUserId = request.user.sub;
|
||||||
|
|
@ -86,12 +87,10 @@ export class PosTypeController extends Controller {
|
||||||
* @param {string} id Id ประเภทตำแหน่ง
|
* @param {string} id Id ประเภทตำแหน่ง
|
||||||
*/
|
*/
|
||||||
@Put("{id}")
|
@Put("{id}")
|
||||||
@Example(
|
@Example({
|
||||||
{
|
|
||||||
positionName: "นักบริหาร",
|
positionName: "นักบริหาร",
|
||||||
posTypeRank: 1,
|
posTypeRank: 1,
|
||||||
},
|
})
|
||||||
)
|
|
||||||
async editType(
|
async editType(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: UpdatePosType,
|
@Body() requestBody: UpdatePosType,
|
||||||
|
|
@ -101,12 +100,17 @@ export class PosTypeController extends Controller {
|
||||||
if (!posType) {
|
if (!posType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||||
}
|
}
|
||||||
const chkPosTypeName = await this.posTypeRepository.findOne({ where: {
|
const chkPosTypeName = await this.posTypeRepository.findOne({
|
||||||
|
where: {
|
||||||
id: Not(id),
|
id: Not(id),
|
||||||
posTypeName: requestBody.posTypeName }
|
posTypeName: requestBody.posTypeName,
|
||||||
})
|
},
|
||||||
if(chkPosTypeName){
|
});
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว");
|
if (chkPosTypeName) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
posType.lastUpdateUserId = request.user.sub;
|
posType.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -133,10 +137,10 @@ export class PosTypeController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||||
}
|
}
|
||||||
const IdExitsInLevel = await this.posLevelRepository.find({
|
const IdExitsInLevel = await this.posLevelRepository.find({
|
||||||
where: { posTypeId: id }
|
where: { posTypeId: id },
|
||||||
})
|
});
|
||||||
if(IdExitsInLevel.length > 0){
|
if (IdExitsInLevel.length > 0) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้ เนื่องจาก id ผูกกับ posLevel",);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้ เนื่องจาก id ผูกกับ posLevel");
|
||||||
}
|
}
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
|
|
@ -165,9 +169,9 @@ export class PosTypeController extends Controller {
|
||||||
id: "00000000-0000-0000-0000-000000000000",
|
id: "00000000-0000-0000-0000-000000000000",
|
||||||
posLevelName: "นักบริหาร",
|
posLevelName: "นักบริหาร",
|
||||||
posLevelRank: 1,
|
posLevelRank: 1,
|
||||||
posLevelAuthority: "HEAD"
|
posLevelAuthority: "HEAD",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
async GetTypeDetail(@Path() id: string) {
|
async GetTypeDetail(@Path() id: string) {
|
||||||
|
|
@ -175,23 +179,23 @@ export class PosTypeController extends Controller {
|
||||||
const getPosType = await this.posTypeRepository.findOne({
|
const getPosType = await this.posTypeRepository.findOne({
|
||||||
select: ["id", "posTypeName", "posTypeRank"],
|
select: ["id", "posTypeName", "posTypeRank"],
|
||||||
relations: ["posLevels"],
|
relations: ["posLevels"],
|
||||||
where: { id: id }
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!getPosType) {
|
if (!getPosType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapGetPosType = {
|
const mapGetPosType = {
|
||||||
id : getPosType.id,
|
id: getPosType.id,
|
||||||
posTypeName : getPosType.posTypeName,
|
posTypeName: getPosType.posTypeName,
|
||||||
posTypeRank : getPosType.posTypeRank,
|
posTypeRank: getPosType.posTypeRank,
|
||||||
posLevels : getPosType.posLevels.map((posLevel) => ({
|
posLevels: getPosType.posLevels.map((posLevel) => ({
|
||||||
id: posLevel.id,
|
id: posLevel.id,
|
||||||
posLevelName: posLevel.posLevelName,
|
posLevelName: posLevel.posLevelName,
|
||||||
posLevelRank: posLevel.posLevelRank,
|
posLevelRank: posLevel.posLevelRank,
|
||||||
posLevelAuthority: posLevel.posLevelAuthority,
|
posLevelAuthority: posLevel.posLevelAuthority,
|
||||||
})),
|
})),
|
||||||
}
|
};
|
||||||
|
|
||||||
return new HttpSuccess(mapGetPosType);
|
return new HttpSuccess(mapGetPosType);
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
|
|
@ -227,9 +231,7 @@ export class PosTypeController extends Controller {
|
||||||
select: ["id", "posTypeName", "posTypeRank"],
|
select: ["id", "posTypeName", "posTypeRank"],
|
||||||
relations: ["posLevels"],
|
relations: ["posLevels"],
|
||||||
});
|
});
|
||||||
if (!posType) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
const mapPosType = posType.map((item) => ({
|
const mapPosType = posType.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
posTypeName: item.posTypeName,
|
posTypeName: item.posTypeName,
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ export class Salary extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const del_SalaryRank = await this.salaryRankRepository.find({
|
const del_SalaryRank = await this.salaryRankRepository.find({
|
||||||
where: { salaryId: chk_Salary.id }
|
where: { salaryId: chk_Salary.id },
|
||||||
});
|
});
|
||||||
await this.salaryRankRepository.remove(del_SalaryRank);
|
await this.salaryRankRepository.remove(del_SalaryRank);
|
||||||
await this.salaryRepository.remove(chk_Salary);
|
await this.salaryRepository.remove(chk_Salary);
|
||||||
|
|
@ -280,6 +280,7 @@ export class Salary extends Controller {
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
//ssss total ผิด
|
||||||
// try {
|
// try {
|
||||||
const [salary, total] = await this.salaryRepository.findAndCount({
|
const [salary, total] = await this.salaryRepository.findAndCount({
|
||||||
relations: ["posLevel_", "posType_"],
|
relations: ["posLevel_", "posType_"],
|
||||||
|
|
@ -321,10 +322,6 @@ export class Salary extends Controller {
|
||||||
return new HttpSuccess({ data: formattedData, total: formattedData.length });
|
return new HttpSuccess({ data: formattedData, total: formattedData.length });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!salary) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const formattedData = salary.map((item) => ({
|
const formattedData = salary.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
salaryType: item.salaryType,
|
salaryType: item.salaryType,
|
||||||
|
|
@ -363,10 +360,7 @@ export class Salary extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!salary) {
|
if (!salary) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเงินเดือนจากไอดีนี้ : " + body.id);
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลเงินเดือนจากไอดีนี้ : " + body.id,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const salaryRank = await this.salaryRankRepository.find({
|
const salaryRank = await this.salaryRankRepository.find({
|
||||||
|
|
|
||||||
|
|
@ -15,18 +15,22 @@ 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 } from "typeorm";
|
import { DeepPartial, In, IsNull, Not, Between, MoreThan } 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";
|
||||||
import { CreateSalaryPeriod, SalaryPeriod, UpdateSalaryPeriod } from "../entities/SalaryPeriod";
|
import { CreateSalaryPeriod, SalaryPeriod, UpdateSalaryPeriod } from "../entities/SalaryPeriod";
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
|
import { SalaryOrg } from "../entities/SalaryOrg";
|
||||||
|
import { CreateSalaryProfile, SalaryProfile } from "../entities/SalaryProfile";
|
||||||
|
|
||||||
@Route("api/v1/salary")
|
@Route("api/v1/salary/period")
|
||||||
@Tags("Salary")
|
@Tags("Salary")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
export class SalaryPeriodController extends Controller {
|
export class SalaryPeriodController extends Controller {
|
||||||
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
||||||
|
private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg);
|
||||||
|
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API สร้างรอบเงินเดือน
|
* API สร้างรอบเงินเดือน
|
||||||
|
|
@ -34,11 +38,12 @@ export class SalaryPeriodController extends Controller {
|
||||||
* @summary SLR_016 - สร้างรอบเงินเดือน #16
|
* @summary SLR_016 - สร้างรอบเงินเดือน #16
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("period")
|
@Post()
|
||||||
async create_salary_period(
|
async create_salary_period(
|
||||||
@Body() requestBody: CreateSalaryPeriod,
|
@Body() requestBody: CreateSalaryPeriod,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
) {
|
) {
|
||||||
|
//ssss ไม่ต้องเช็ค?
|
||||||
const salaryPeriod = Object.assign(new SalaryPeriod(), requestBody);
|
const salaryPeriod = Object.assign(new SalaryPeriod(), requestBody);
|
||||||
if (!salaryPeriod) {
|
if (!salaryPeriod) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -54,12 +59,15 @@ export class SalaryPeriodController extends Controller {
|
||||||
const chk_period = await this.salaryPeriodRepository.findOne({
|
const chk_period = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: salaryPeriod.period,
|
period: salaryPeriod.period,
|
||||||
effectiveDate: Between(startOfYear, endOfYear)
|
effectiveDate: Between(startOfYear, endOfYear),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (chk_period) {
|
if (chk_period) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทผังปี "+ salaryPeriod.effectiveDate.getFullYear() +" ซ้ำ");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ประเภทผังปี " + salaryPeriod.effectiveDate.getFullYear() + " ซ้ำ",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
salaryPeriod.period = salaryPeriod.period.toUpperCase();
|
salaryPeriod.period = salaryPeriod.period.toUpperCase();
|
||||||
|
|
@ -78,7 +86,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Guid, *Id รอบเงินเดือน
|
* @param {string} id Guid, *Id รอบเงินเดือน
|
||||||
*/
|
*/
|
||||||
@Put("period/{id}")
|
@Put("{id}")
|
||||||
async update_salary_period(
|
async update_salary_period(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: UpdateSalaryPeriod,
|
@Body() requestBody: UpdateSalaryPeriod,
|
||||||
|
|
@ -102,12 +110,15 @@ export class SalaryPeriodController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
period: requestBody.period,
|
period: requestBody.period,
|
||||||
id: Not(id),
|
id: Not(id),
|
||||||
effectiveDate: Between(startOfYear, endOfYear)
|
effectiveDate: Between(startOfYear, endOfYear),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (chk_period) {
|
if (chk_period) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทผังปี "+ (requestBody.effectiveDate.getFullYear()+543) +" ซ้ำ");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ประเภทผังปี " + (requestBody.effectiveDate.getFullYear() + 543) + " ซ้ำ",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
chk_SalaryPeriod.period = requestBody.period.toUpperCase();
|
chk_SalaryPeriod.period = requestBody.period.toUpperCase();
|
||||||
|
|
@ -117,7 +128,6 @@ export class SalaryPeriodController extends Controller {
|
||||||
this.salaryPeriodRepository.merge(chk_SalaryPeriod, requestBody);
|
this.salaryPeriodRepository.merge(chk_SalaryPeriod, requestBody);
|
||||||
await this.salaryPeriodRepository.save(chk_SalaryPeriod);
|
await this.salaryPeriodRepository.save(chk_SalaryPeriod);
|
||||||
return new HttpSuccess(id);
|
return new HttpSuccess(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,7 +137,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Guid, *Id รอบเงินเดือน
|
* @param {string} id Guid, *Id รอบเงินเดือน
|
||||||
*/
|
*/
|
||||||
@Delete("period/{id}")
|
@Delete("{id}")
|
||||||
async delete_salary_period(@Path() id: string) {
|
async delete_salary_period(@Path() id: string) {
|
||||||
const SalaryPeriod = await this.salaryPeriodRepository.findOne({
|
const SalaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -146,18 +156,11 @@ export class SalaryPeriodController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Guid, *Id รอบเงินเดือน
|
* @param {string} id Guid, *Id รอบเงินเดือน
|
||||||
*/
|
*/
|
||||||
@Get("period/{id}")
|
@Get("{id}")
|
||||||
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: [
|
select: ["id", "period", "isActive", "effectiveDate", "isActive", "status"],
|
||||||
"id",
|
|
||||||
"period",
|
|
||||||
"isActive",
|
|
||||||
"effectiveDate",
|
|
||||||
"isActive",
|
|
||||||
"status",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
if (!salaryPeriod) {
|
if (!salaryPeriod) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id);
|
||||||
|
|
@ -171,27 +174,27 @@ export class SalaryPeriodController extends Controller {
|
||||||
* @summary SLR_020 - รายการรอบเงินเดือน #20
|
* @summary SLR_020 - รายการรอบเงินเดือน #20
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("period")
|
@Get()
|
||||||
async GetListsSalaryPeriod(
|
async GetListsSalaryPeriod(
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
@Query("year") year: number = 2024,
|
@Query("year") year: number = 2024,
|
||||||
) {
|
) {
|
||||||
|
//ssss total ผิด
|
||||||
let salaryPeriod: any
|
let salaryPeriod: any;
|
||||||
let total: any
|
let total: any;
|
||||||
if(year != 0){
|
if (year != 0) {
|
||||||
const startOfYear = new Date(year, 0, 1);
|
const startOfYear = new Date(year, 0, 1);
|
||||||
const endOfYear = new Date(year, 11, 31);
|
const endOfYear = new Date(year, 11, 31);
|
||||||
[salaryPeriod, total] = await this.salaryPeriodRepository.findAndCount({
|
[salaryPeriod, total] = await this.salaryPeriodRepository.findAndCount({
|
||||||
skip: (page - 1) * pageSize,
|
skip: (page - 1) * pageSize,
|
||||||
take: pageSize,
|
take: pageSize,
|
||||||
where: {
|
where: {
|
||||||
effectiveDate: Between(startOfYear, endOfYear)
|
effectiveDate: Between(startOfYear, endOfYear),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
[salaryPeriod, total] = await this.salaryPeriodRepository.findAndCount({
|
[salaryPeriod, total] = await this.salaryPeriodRepository.findAndCount({
|
||||||
skip: (page - 1) * pageSize,
|
skip: (page - 1) * pageSize,
|
||||||
take: pageSize,
|
take: pageSize,
|
||||||
|
|
@ -200,13 +203,13 @@ export class SalaryPeriodController extends Controller {
|
||||||
|
|
||||||
if (keyword != undefined && keyword !== "") {
|
if (keyword != undefined && keyword !== "") {
|
||||||
const filteredSalaryPeriod = salaryPeriod.filter(
|
const filteredSalaryPeriod = salaryPeriod.filter(
|
||||||
(x:any) =>
|
(x: any) =>
|
||||||
x.period.toString().includes(keyword) ||
|
x.period.toString().includes(keyword) ||
|
||||||
x.isActive.toString().includes(keyword) ||
|
x.isActive.toString().includes(keyword) ||
|
||||||
x.effectiveDate.getFullYear().toString().includes(keyword)
|
x.effectiveDate.getFullYear().toString().includes(keyword),
|
||||||
);
|
);
|
||||||
|
|
||||||
const formattedData = filteredSalaryPeriod.map((item:any) => ({
|
const formattedData = filteredSalaryPeriod.map((item: any) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
period: item.period,
|
period: item.period,
|
||||||
isActive: item.isActive,
|
isActive: item.isActive,
|
||||||
|
|
@ -216,11 +219,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess({ data: formattedData, total: formattedData.length });
|
return new HttpSuccess({ data: formattedData, total: formattedData.length });
|
||||||
}
|
}
|
||||||
if (!salaryPeriod) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const formattedData = salaryPeriod.map((item:any) => ({
|
const formattedData = salaryPeriod.map((item: any) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
period: item.period,
|
period: item.period,
|
||||||
isActive: item.isActive,
|
isActive: item.isActive,
|
||||||
|
|
@ -228,7 +228,311 @@ export class SalaryPeriodController extends Controller {
|
||||||
status: item.status,
|
status: item.status,
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รอบล่าสุด
|
||||||
|
*
|
||||||
|
* @summary SLR_030 - รอบล่าสุด #29
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("latest")
|
||||||
|
async GetGroupSalaryPeriodLatest() {
|
||||||
|
//xxxx รอบเงินเดือนล่าสุดยังไม่แน่ใจเอาจากรอบไหน
|
||||||
|
//xxxx หาสังกัดคนนั้น
|
||||||
|
// const dateNow = new Date();
|
||||||
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
// effectiveDate: MoreThan(dateNow),
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
order: { effectiveDate: "DESC" },
|
||||||
|
relations: ["salaryOrgs"],
|
||||||
|
});
|
||||||
|
if (!salaryPeriod) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
group1id: salaryPeriod.salaryOrgs.find((x) => x.group == "GROUP1")?.id,
|
||||||
|
group2id: salaryPeriod.salaryOrgs.find((x) => x.group == "GROUP2")?.id,
|
||||||
|
effectiveDate: salaryPeriod.effectiveDate,
|
||||||
|
period: salaryPeriod.period,
|
||||||
|
};
|
||||||
|
return new HttpSuccess(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API จำนวนโควตา
|
||||||
|
*
|
||||||
|
* @summary SLR_029 - จำนวนโควตา #28
|
||||||
|
*
|
||||||
|
* @param {string} id Guid, *Id กลุ่ม(salaryOrgId/groupId)
|
||||||
|
*/
|
||||||
|
@Get("quota/{id}")
|
||||||
|
async GetSalaryquotaLatest(@Path() id: string) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: ["total", "fifteenPercent"],
|
||||||
|
relations: ["salaryProfiles"],
|
||||||
|
});
|
||||||
|
if (!salaryOrg) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
total: salaryOrg.total,
|
||||||
|
fifteenPercent: salaryOrg.fifteenPercent,
|
||||||
|
chosen: salaryOrg.salaryProfiles.filter((x) => x.posType == "FULL").length,
|
||||||
|
remaining:
|
||||||
|
salaryOrg.fifteenPercent -
|
||||||
|
salaryOrg.salaryProfiles.filter((x) => x.posType == "FULL").length,
|
||||||
|
};
|
||||||
|
return new HttpSuccess(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ลบคนเลื่อนเงินเดือนในรอบ
|
||||||
|
*
|
||||||
|
* @summary SLR_024 - ลบคนเลื่อนเงินเดือนในรอบ #23
|
||||||
|
*
|
||||||
|
* @param {string} id profile Id
|
||||||
|
*/
|
||||||
|
@Delete("profile/{id}")
|
||||||
|
async deleteSalaryProfile(@Path() id: string) {
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||||
|
where: { id: id },
|
||||||
|
});
|
||||||
|
if (!salaryProfile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||||
|
}
|
||||||
|
await this.salaryProfileRepository.remove(salaryProfile);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขเงินเดือน
|
||||||
|
*
|
||||||
|
* @summary SLR_025 - แก้ไขเงินเดือน #24
|
||||||
|
*
|
||||||
|
* @param {string} id profile Id
|
||||||
|
* @param {string} amount ฐานเงินเดือน
|
||||||
|
*/
|
||||||
|
@Post("change/amount")
|
||||||
|
async changeAmount(@Body() body: { profileId: string; amount: number }) {
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||||
|
where: { id: body.profileId },
|
||||||
|
});
|
||||||
|
if (!salaryProfile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||||
|
}
|
||||||
|
salaryProfile.amount = body.amount;
|
||||||
|
// salaryProfile.amountSpecial = xxxx;
|
||||||
|
// salaryProfile.amountUse = xxxx;
|
||||||
|
// salaryProfile.positionSalaryAmount = xxxx;
|
||||||
|
//xxxxxx คำนวนเงินเดือนใหม่
|
||||||
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ย้ายกลุ่ม
|
||||||
|
*
|
||||||
|
* @summary SLR_026 - ย้ายกลุ่ม #25
|
||||||
|
*
|
||||||
|
* @param {string} id profile Id
|
||||||
|
* @param {string} groupId groupId
|
||||||
|
*/
|
||||||
|
@Post("change/group")
|
||||||
|
async changeGroup(@Body() body: { profileId: string; groupId: string }) {
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||||
|
where: { id: body.profileId },
|
||||||
|
});
|
||||||
|
if (!salaryProfile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||||
|
}
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: body.groupId },
|
||||||
|
});
|
||||||
|
if (!salaryOrg) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มการขอเลื่อนเงินเดือน");
|
||||||
|
}
|
||||||
|
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||||
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขเงินเดือน
|
||||||
|
*
|
||||||
|
* @summary SLR_025 - แก้ไขเงินเดือน #24
|
||||||
|
*
|
||||||
|
* @param {string} id profile Id
|
||||||
|
* @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น
|
||||||
|
*/
|
||||||
|
@Post("change/type")
|
||||||
|
async changeType(@Body() body: { profileId: string; type: string }) {
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||||
|
where: { id: body.profileId },
|
||||||
|
});
|
||||||
|
if (!salaryProfile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||||
|
}
|
||||||
|
body.type = body.type.toUpperCase();
|
||||||
|
//xxxxxx คำนวนเงินเดือนใหม่
|
||||||
|
if (body.type == "NONE") {
|
||||||
|
//xxxx เงินไม่เปลืี่ยน
|
||||||
|
} else if (body.type == "HAFT") {
|
||||||
|
//xxxx เลื่อน0.5ขั้น
|
||||||
|
// salaryProfile.amountSpecial = 0;
|
||||||
|
// salaryProfile.amountUse = 0;
|
||||||
|
// salaryProfile.positionSalaryAmount = 0;
|
||||||
|
} else if (body.type == "FULL") {
|
||||||
|
//xxxx เลื่อน1ขั้น
|
||||||
|
// salaryProfile.amountSpecial = 0;
|
||||||
|
// salaryProfile.amountUse = 0;
|
||||||
|
// salaryProfile.positionSalaryAmount = 0;
|
||||||
|
} else if (body.type == "FULLHAFT") {
|
||||||
|
//xxxx เลื่อน1.0ขั้น
|
||||||
|
// salaryProfile.amountSpecial = 0;
|
||||||
|
// salaryProfile.amountUse = 0;
|
||||||
|
// salaryProfile.positionSalaryAmount = 0;
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
|
}
|
||||||
|
salaryProfile.type = body.type;
|
||||||
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รายการอัตราเงินเดือน
|
||||||
|
*
|
||||||
|
* @summary SLR_023 - รายการอัตราเงินเดือน #22
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Put("org/{id}")
|
||||||
|
async GetListsSalaryProfile(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body() body: { page: number; pageSize: number; keyword?: string; type: string },
|
||||||
|
) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!salaryOrg) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||||
|
}
|
||||||
|
|
||||||
|
const [salaryProfile, total] = await AppDataSource.getRepository(SalaryProfile)
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.andWhere({
|
||||||
|
salaryOrgId: salaryOrg.id,
|
||||||
|
})
|
||||||
|
.andWhere(body.type != null && body.type != "" ? "profile.type LIKE :type" : "1=1", {
|
||||||
|
type: `%${body.type}%`,
|
||||||
|
})
|
||||||
|
//xxxx รอ fe ว่าแสดงค่าไหนบ่างใหเfilterเฉพาะค่านั้น
|
||||||
|
.orWhere("profile.posMasterNoPrefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.posMasterNo LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.posMasterNoSuffix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.orgShortName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
// .orWhere("profile.citizenId 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")
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: salaryProfile, total });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API เพิ่มคนเลื่อนเงินเดือนตามรอบ
|
||||||
|
*
|
||||||
|
* @summary SLR_028 - เพิ่มคนเลื่อนเงินเดือนตามรอบ #27
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("org/profile")
|
||||||
|
async addSalaryProfile(
|
||||||
|
@Body() requestBody: CreateSalaryProfile,
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: requestBody.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!salaryOrg) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||||
|
}
|
||||||
|
const salaryOrgAll = await this.salaryOrgRepository.find({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryOrg.salaryPeriodId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!salaryOrgAll) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||||
|
}
|
||||||
|
const salaryProfileAll = await this.salaryProfileRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryOrgId: In(salaryOrgAll.map((x) => x.id)),
|
||||||
|
citizenId: requestBody.citizenId,
|
||||||
|
// prefix: requestBody.prefix,
|
||||||
|
// firstName: requestBody.firstName,
|
||||||
|
// lastName: requestBody.lastName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (salaryProfileAll != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถเพิ่มรายชื่อนี้ได้ เนื่องจากมีการยื่นของเลื่อนเงินเดือนแล้ว",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const salaryProfile = Object.assign(new SalaryProfile(), requestBody);
|
||||||
|
salaryProfile.type = salaryProfile.type.toUpperCase();
|
||||||
|
//xxxxxx คำนวนเงินเดือนใหม่
|
||||||
|
if (salaryProfile.type == "NONE") {
|
||||||
|
//xxxx เงินไม่เปลืี่ยน
|
||||||
|
} else if (salaryProfile.type == "HAFT") {
|
||||||
|
//xxxx เลื่อน0.5ขั้น
|
||||||
|
// salaryProfile.amountSpecial = 0;
|
||||||
|
// salaryProfile.amountUse = 0;
|
||||||
|
// salaryProfile.positionSalaryAmount = 0;
|
||||||
|
} else if (salaryProfile.type == "FULL") {
|
||||||
|
//xxxx เลื่อน1ขั้น
|
||||||
|
// salaryProfile.amountSpecial = 0;
|
||||||
|
// salaryProfile.amountUse = 0;
|
||||||
|
// salaryProfile.positionSalaryAmount = 0;
|
||||||
|
} else if (salaryProfile.type == "FULLHAFT") {
|
||||||
|
//xxxx เลื่อน1.0ขั้น
|
||||||
|
// salaryProfile.amountSpecial = 0;
|
||||||
|
// salaryProfile.amountUse = 0;
|
||||||
|
// salaryProfile.positionSalaryAmount = 0;
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
|
}
|
||||||
|
|
||||||
|
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||||
|
salaryProfile.createdUserId = request.user.sub;
|
||||||
|
salaryProfile.createdFullName = request.user.name;
|
||||||
|
salaryProfile.lastUpdateUserId = request.user.sub;
|
||||||
|
salaryProfile.lastUpdateFullName = request.user.name;
|
||||||
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
return new HttpSuccess(salaryProfile.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ export class SalaryRanksController extends Controller {
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
//ssss total ผิด
|
||||||
// try {
|
// try {
|
||||||
const [salaryRank, total] = await this.salaryRankRepository.findAndCount({
|
const [salaryRank, total] = await this.salaryRankRepository.findAndCount({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -193,9 +194,6 @@ export class SalaryRanksController extends Controller {
|
||||||
return new HttpSuccess({ data: filteredSalaryRank, total: filteredSalaryRank.length });
|
return new HttpSuccess({ data: filteredSalaryRank, total: filteredSalaryRank.length });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!salaryRank) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
return new HttpSuccess({ data: salaryRank, total });
|
return new HttpSuccess({ data: salaryRank, total });
|
||||||
// } catch (error: any) {
|
// } catch (error: any) {
|
||||||
// throw new Error(error);
|
// throw new Error(error);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { SalaryPeriod } from "./SalaryPeriod";
|
||||||
|
import { SalaryProfile } from "./SalaryProfile";
|
||||||
|
|
||||||
@Entity("salaryOrg")
|
@Entity("salaryOrg")
|
||||||
export class SalaryOrg extends EntityBase {
|
export class SalaryOrg extends EntityBase {
|
||||||
|
|
@ -7,49 +9,58 @@ export class SalaryOrg extends EntityBase {
|
||||||
comment: "",
|
comment: "",
|
||||||
length: 40,
|
length: 40,
|
||||||
})
|
})
|
||||||
salaryPreiodId: string;
|
salaryPeriodId: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment:"",
|
comment: "สถานะ",
|
||||||
})
|
})
|
||||||
status: string;
|
status: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment:"",
|
comment: "id หน่วยงาน",
|
||||||
length: 40,
|
length: 40,
|
||||||
})
|
})
|
||||||
rootId : string;
|
rootId: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment:"สถานะ",
|
comment: "จำนวนคนทั้งหมด",
|
||||||
})
|
})
|
||||||
total : number;
|
total: number;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment:"15%ของจำนวนคน",
|
comment: "15%ของจำนวนคน",
|
||||||
})
|
})
|
||||||
fifteenPercent : number;
|
fifteenPercent: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2",
|
||||||
|
length: 10,
|
||||||
|
})
|
||||||
|
group: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => SalaryPeriod, (salaryPeriod) => salaryPeriod.salaryOrgs)
|
||||||
|
@JoinColumn({ name: "salaryPeriodId" })
|
||||||
|
salaryPeriod: SalaryPeriod;
|
||||||
|
|
||||||
|
@OneToMany(() => SalaryProfile, (salaryProfile) => salaryProfile.salaryOrg)
|
||||||
|
salaryProfiles: SalaryProfile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateSalaryOrg {
|
export class CreateSalaryOrg {
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
salaryPreiodId: string;
|
salaryPeriodId: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
status: string;
|
status: string;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
rootId : string;
|
rootId: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
total : number;
|
total: number;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
fifteenPercent : number;
|
fifteenPercent: number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateSalaryOrg = Partial<CreateSalaryOrg>;
|
export type UpdateSalaryOrg = Partial<CreateSalaryOrg>;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { SalaryOrg } from "./SalaryOrg";
|
||||||
|
|
||||||
@Entity("salaryPeriod")
|
@Entity("salaryPeriod")
|
||||||
export class SalaryPeriod extends EntityBase {
|
export class SalaryPeriod extends EntityBase {
|
||||||
|
|
@ -29,10 +30,11 @@ export class SalaryPeriod extends EntityBase {
|
||||||
})
|
})
|
||||||
status?: string;
|
status?: string;
|
||||||
|
|
||||||
|
@OneToMany(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryPeriod)
|
||||||
|
salaryOrgs: SalaryOrg[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateSalaryPeriod {
|
export class CreateSalaryPeriod {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
period: string;
|
period: string;
|
||||||
|
|
||||||
|
|
@ -41,11 +43,9 @@ export class CreateSalaryPeriod {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
effectiveDate: Date;
|
effectiveDate: Date;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateSalaryPeriod {
|
export class UpdateSalaryPeriod {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
period: string;
|
period: string;
|
||||||
|
|
||||||
|
|
@ -54,5 +54,4 @@ export class UpdateSalaryPeriod {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
effectiveDate: Date;
|
effectiveDate: Date;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { SalaryOrg } from "./SalaryOrg";
|
||||||
|
|
||||||
@Entity("salaryProfile")
|
@Entity("salaryProfile")
|
||||||
export class SalaryProfile extends EntityBase {
|
export class SalaryProfile extends EntityBase {
|
||||||
|
|
@ -34,9 +35,41 @@ export class SalaryProfile extends EntityBase {
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment:"เลขที่ตำแหน่ง",
|
nullable: true,
|
||||||
|
comment: "เลขบัตรประชาชน",
|
||||||
|
length: 100,
|
||||||
|
default: null,
|
||||||
})
|
})
|
||||||
posNumber : number;
|
citizenId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)",
|
||||||
|
length: 100,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterNoPrefix: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "เลขที่ตำแหน่ง เป็นตัวเลข",
|
||||||
|
})
|
||||||
|
posMasterNo: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "Suffix หลังเลขที่ตำแหน่ง เช่น ช.",
|
||||||
|
length: 100,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterNoSuffix: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ชื่อย่อหน่วยงาน",
|
||||||
|
length: 100,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
orgShortName: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
@ -48,21 +81,32 @@ export class SalaryProfile extends EntityBase {
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "ประเภทตำแหน่ง",
|
comment: "ประเภทตำแหน่ง",
|
||||||
length: 40,
|
length: 100,
|
||||||
})
|
})
|
||||||
posTypeId: string;
|
posType: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "ระดับตำแหน่ง",
|
comment: "ระดับตำแหน่ง",
|
||||||
length: 40,
|
length: 100,
|
||||||
})
|
})
|
||||||
posLevelId: string;
|
posLevel: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "ตำแหน่งทางการบริหาร",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
posExecutive: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "เงินเดือนฐาน",
|
comment: "เงินเดือนฐาน",
|
||||||
})
|
})
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "เงินพิเศษ",
|
||||||
|
})
|
||||||
|
amountSpecial: number;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "จำนวนเงินที่ใช้เลื่อน",
|
comment: "จำนวนเงินที่ใช้เลื่อน",
|
||||||
})
|
})
|
||||||
|
|
@ -75,8 +119,9 @@ export class SalaryProfile extends EntityBase {
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น group กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2",
|
comment:
|
||||||
length: 255,
|
"ประเภทการเลื่อน(ขั้น) PENDING->รายชื่อคนครอง NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น",
|
||||||
|
length: 20,
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
type: string;
|
type: string;
|
||||||
|
|
@ -151,12 +196,17 @@ export class SalaryProfile extends EntityBase {
|
||||||
})
|
})
|
||||||
child4: string;
|
child4: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryProfiles)
|
||||||
|
@JoinColumn({ name: "salaryOrgId" })
|
||||||
|
salaryOrg: SalaryOrg;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateSalaryProfile {
|
export class CreateSalaryProfile {
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
salaryOrgId: string;
|
id: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
type: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
prefix: string;
|
prefix: string;
|
||||||
|
|
@ -168,29 +218,32 @@ export class CreateSalaryProfile {
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
posNumber : number;
|
citizenId: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
posMasterNoPrefix: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
posMasterNo: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
posMasterNoSuffix: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
orgShortName: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
position: string;
|
position: string;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column()
|
||||||
posTypeId: string;
|
posType: string;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column()
|
||||||
posLevelId: string;
|
posLevel: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|
||||||
@Column()
|
|
||||||
amountUse: number;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
positionSalaryAmount: number;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
type: string;
|
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
rootId: string;
|
rootId: string;
|
||||||
|
|
||||||
|
|
@ -220,8 +273,4 @@ export class CreateSalaryProfile {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
child4: string;
|
child4: string;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateSalaryProfile = Partial<CreateSalaryProfile>;
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ export class CreateSalaryPeriodTable1708585607075 implements MigrationInterface
|
||||||
name = "CreateSalaryPeriodTable1708585607075";
|
name = "CreateSalaryPeriodTable1708585607075";
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(
|
// await queryRunner.query(
|
||||||
`CREATE TABLE \`salaryPeriod\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`period\` varchar(255) NOT NULL COMMENT 'ประเภทผัง (SPECIAL->รอบพิเศษ,APR->รอบเมษายน,OCT->รอบตุลาคม)', \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0, \`effectiveDate\` datetime NULL COMMENT 'วันที่มีผลบังคับใช้', \`status\` varchar(255) NOT NULL COMMENT 'สถานะ' DEFAULT 'PENDING', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
|
// `CREATE TABLE \`salaryPeriod\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`period\` varchar(255) NOT NULL COMMENT 'ประเภทผัง (SPECIAL->รอบพิเศษ,APR->รอบเมษายน,OCT->รอบตุลาคม)', \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0, \`effectiveDate\` datetime NULL COMMENT 'วันที่มีผลบังคับใช้', \`status\` varchar(255) NOT NULL COMMENT 'สถานะ' DEFAULT 'PENDING', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
|
||||||
);
|
// );
|
||||||
// await queryRunner.query(`ALTER TABLE \`salarys\` ADD CONSTRAINT \`FK_fa211557e2cbee0bb3bbef363f2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
// await queryRunner.query(`ALTER TABLE \`salarys\` ADD CONSTRAINT \`FK_fa211557e2cbee0bb3bbef363f2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
// await queryRunner.query(`ALTER TABLE \`salarys\` ADD CONSTRAINT \`FK_683719e5363cc977da591556731\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
// await queryRunner.query(`ALTER TABLE \`salarys\` ADD CONSTRAINT \`FK_683719e5363cc977da591556731\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
}
|
}
|
||||||
|
|
@ -14,6 +14,6 @@ export class CreateSalaryPeriodTable1708585607075 implements MigrationInterface
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
// await queryRunner.query(`ALTER TABLE \`salarys\` DROP FOREIGN KEY \`FK_683719e5363cc977da591556731\``);
|
// await queryRunner.query(`ALTER TABLE \`salarys\` DROP FOREIGN KEY \`FK_683719e5363cc977da591556731\``);
|
||||||
// await queryRunner.query(`ALTER TABLE \`salarys\` DROP FOREIGN KEY \`FK_fa211557e2cbee0bb3bbef363f2\``);
|
// await queryRunner.query(`ALTER TABLE \`salarys\` DROP FOREIGN KEY \`FK_fa211557e2cbee0bb3bbef363f2\``);
|
||||||
await queryRunner.query(`DROP TABLE \`salaryPeriod\``);
|
// await queryRunner.query(`DROP TABLE \`salaryPeriod\``);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
src/migration/1708952006038-add_table_SalaryProfile.ts
Normal file
20
src/migration/1708952006038-add_table_SalaryProfile.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTableSalaryProfile1708952006038 implements MigrationInterface {
|
||||||
|
name = 'AddTableSalaryProfile1708952006038'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TABLE \`salaryOrg\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`salaryPeriodId\` varchar(40) NOT NULL, \`status\` varchar(255) NOT NULL COMMENT 'สถานะ', \`rootId\` varchar(40) NOT NULL COMMENT 'id หน่วยงาน', \`total\` int NOT NULL COMMENT 'จำนวนคนทั้งหมด', \`fifteenPercent\` int NOT NULL COMMENT '15%ของจำนวนคน', \`group\` varchar(10) NOT NULL COMMENT 'กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`CREATE TABLE \`salaryProfile\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`salaryOrgId\` varchar(40) NOT NULL, \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`citizenId\` varchar(100) NULL COMMENT 'เลขบัตรประชาชน', \`posMasterNoPrefix\` varchar(100) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)', \`posMasterNo\` int NOT NULL COMMENT 'เลขที่ตำแหน่ง เป็นตัวเลข', \`posMasterNoSuffix\` varchar(100) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.', \`orgShortName\` varchar(100) NULL COMMENT 'ชื่อย่อหน่วยงาน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posType\` varchar(100) NOT NULL COMMENT 'ประเภทตำแหน่ง', \`posLevel\` varchar(100) NOT NULL COMMENT 'ระดับตำแหน่ง', \`posExecutive\` varchar(255) NOT NULL COMMENT 'ตำแหน่งทางการบริหาร', \`amount\` int NOT NULL COMMENT 'เงินเดือนฐาน', \`amountSpecial\` int NOT NULL COMMENT 'เงินพิเศษ', \`amountUse\` int NOT NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน', \`positionSalaryAmount\` int NOT NULL COMMENT 'เงินเดือนหลังเลื่อน', \`type\` varchar(20) NULL COMMENT 'ประเภทการเลื่อน(ขั้น) PENDING->รายชื่อคนครอง NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น', \`rootId\` varchar(40) NOT NULL, \`root\` varchar(255) NULL, \`child1Id\` varchar(40) NOT NULL, \`child1\` varchar(255) NULL, \`child2Id\` varchar(40) NOT NULL, \`child2\` varchar(255) NULL, \`child3Id\` varchar(40) NOT NULL, \`child3\` varchar(255) NULL, \`child4Id\` varchar(40) NOT NULL, \`child4\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD CONSTRAINT \`FK_7fd317035fe8d0e03dc2443cf36\` FOREIGN KEY (\`salaryPeriodId\`) REFERENCES \`salaryPeriod\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD CONSTRAINT \`FK_d925088feca62ab41c131a87914\` FOREIGN KEY (\`salaryOrgId\`) REFERENCES \`salaryOrg\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP FOREIGN KEY \`FK_d925088feca62ab41c131a87914\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP FOREIGN KEY \`FK_7fd317035fe8d0e03dc2443cf36\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`salaryProfile\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`salaryOrg\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue