แก้ isActive
This commit is contained in:
parent
9b1ce59201
commit
866dd91d81
1 changed files with 46 additions and 19 deletions
|
|
@ -73,13 +73,26 @@ export class SalaryController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ระดับของตำแหน่ง ไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
const chk_3fields = await this.salaryRepository.findOne({
|
||||
where: {
|
||||
posTypeId: salarys.posTypeId,
|
||||
posLevelId: salarys.posLevelId,
|
||||
},
|
||||
});
|
||||
if (chk_3fields && salarys.isActive) {
|
||||
let chk_fields: any
|
||||
if(salarys.isSpecial){
|
||||
chk_fields = await this.salaryRepository.findOne({
|
||||
where: {
|
||||
posTypeId: salarys.posTypeId,
|
||||
posLevelId: salarys.posLevelId,
|
||||
isSpecial: true
|
||||
},
|
||||
});
|
||||
}else{
|
||||
chk_fields = await this.salaryRepository.findOne({
|
||||
where: {
|
||||
posTypeId: salarys.posTypeId,
|
||||
posLevelId: salarys.posLevelId,
|
||||
isSpecial: false
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (chk_fields && salarys.isActive) {
|
||||
salarys.isActive = false;
|
||||
}
|
||||
salarys.name = salarys.name;
|
||||
|
|
@ -129,22 +142,36 @@ export class SalaryController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
const chk_3fields = await this.salaryRepository.find({
|
||||
where: {
|
||||
posTypeId: requestBody.posTypeId,
|
||||
posLevelId: requestBody.posLevelId,
|
||||
isActive: true,
|
||||
id: Not(id),
|
||||
},
|
||||
});
|
||||
|
||||
if (chk_3fields.length > 0 && requestBody.isActive) {
|
||||
chk_3fields.forEach(async (item) => {
|
||||
let chk_fields: any
|
||||
if(chk_Salary.isSpecial){
|
||||
chk_fields = await this.salaryRepository.find({
|
||||
where: {
|
||||
posTypeId: requestBody.posTypeId,
|
||||
posLevelId: requestBody.posLevelId,
|
||||
isActive: true,
|
||||
isSpecial: true,
|
||||
id: Not(id),
|
||||
},
|
||||
});
|
||||
}else{
|
||||
chk_fields = await this.salaryRepository.find({
|
||||
where: {
|
||||
posTypeId: requestBody.posTypeId,
|
||||
posLevelId: requestBody.posLevelId,
|
||||
isActive: true,
|
||||
isSpecial: false,
|
||||
id: Not(id),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (chk_fields.length > 0 && requestBody.isActive) {
|
||||
chk_fields.forEach(async (item:any) => {
|
||||
item.isActive = false;
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
item.lastUpdatedAt = new Date();
|
||||
await this.salaryRepository.save(chk_3fields);
|
||||
await this.salaryRepository.save(chk_fields);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue