แก้ 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, "ระดับของตำแหน่ง ไม่ถูกต้อง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ระดับของตำแหน่ง ไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
|
||||||
const chk_3fields = await this.salaryRepository.findOne({
|
let chk_fields: any
|
||||||
where: {
|
if(salarys.isSpecial){
|
||||||
posTypeId: salarys.posTypeId,
|
chk_fields = await this.salaryRepository.findOne({
|
||||||
posLevelId: salarys.posLevelId,
|
where: {
|
||||||
},
|
posTypeId: salarys.posTypeId,
|
||||||
});
|
posLevelId: salarys.posLevelId,
|
||||||
if (chk_3fields && salarys.isActive) {
|
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.isActive = false;
|
||||||
}
|
}
|
||||||
salarys.name = salarys.name;
|
salarys.name = salarys.name;
|
||||||
|
|
@ -129,22 +142,36 @@ export class SalaryController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chk_3fields = await this.salaryRepository.find({
|
let chk_fields: any
|
||||||
where: {
|
if(chk_Salary.isSpecial){
|
||||||
posTypeId: requestBody.posTypeId,
|
chk_fields = await this.salaryRepository.find({
|
||||||
posLevelId: requestBody.posLevelId,
|
where: {
|
||||||
isActive: true,
|
posTypeId: requestBody.posTypeId,
|
||||||
id: Not(id),
|
posLevelId: requestBody.posLevelId,
|
||||||
},
|
isActive: true,
|
||||||
});
|
isSpecial: true,
|
||||||
|
id: Not(id),
|
||||||
if (chk_3fields.length > 0 && requestBody.isActive) {
|
},
|
||||||
chk_3fields.forEach(async (item) => {
|
});
|
||||||
|
}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.isActive = false;
|
||||||
item.lastUpdateUserId = request.user.sub;
|
item.lastUpdateUserId = request.user.sub;
|
||||||
item.lastUpdateFullName = request.user.name;
|
item.lastUpdateFullName = request.user.name;
|
||||||
item.lastUpdatedAt = new Date();
|
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