เพิ่มเหตุผล posmaster
This commit is contained in:
parent
7a2ed91612
commit
013ccf60e6
7 changed files with 433 additions and 72 deletions
|
|
@ -242,6 +242,7 @@ export class EmployeePositionController extends Controller {
|
|||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
reason: posMaster.reason,
|
||||
positions: positions.map((position) => ({
|
||||
id: position.id,
|
||||
positionName: position.positionName,
|
||||
|
|
@ -612,6 +613,7 @@ export class EmployeePositionController extends Controller {
|
|||
posMaster.posMasterNo = requestBody.posMasterNo;
|
||||
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
|
||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||
posMaster.reason = requestBody.reason;
|
||||
posMaster.orgRootId = null;
|
||||
posMaster.orgChild1Id = null;
|
||||
posMaster.orgChild2Id = null;
|
||||
|
|
@ -1122,6 +1124,7 @@ export class EmployeePositionController extends Controller {
|
|||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
reason: posMaster.reason,
|
||||
fullNameCurrentHolder:
|
||||
posMaster.current_holder == null
|
||||
? null
|
||||
|
|
@ -1353,6 +1356,7 @@ export class EmployeePositionController extends Controller {
|
|||
posMasterNoPrefix: item.posMasterNoPrefix ? item.posMasterNoPrefix : null,
|
||||
posMasterNo: item.posMasterNo ? item.posMasterNo : null,
|
||||
posMasterNoSuffix: item.posMasterNoSuffix ? item.posMasterNoSuffix : null,
|
||||
reason: item.reason ? item.reason : null,
|
||||
}));
|
||||
return new HttpSuccess(_data);
|
||||
}
|
||||
|
|
@ -1440,6 +1444,14 @@ export class EmployeePositionController extends Controller {
|
|||
where: { id: requestBody.id },
|
||||
});
|
||||
if (org != null) {
|
||||
const _posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { orgRootId: org.id, posMasterNo: posMaster.posMasterNo },
|
||||
});
|
||||
if (_posMaster != null)
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
`เลขที่ตำแหน่ง ${org.orgRootShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||
);
|
||||
if (
|
||||
posMaster.orgRootId == org.id &&
|
||||
posMaster.orgChild1Id == null &&
|
||||
|
|
@ -1461,6 +1473,14 @@ export class EmployeePositionController extends Controller {
|
|||
where: { id: requestBody.id },
|
||||
});
|
||||
if (org != null) {
|
||||
const _posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { orgChild1Id: org.id, posMasterNo: posMaster.posMasterNo },
|
||||
});
|
||||
if (_posMaster != null)
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
`เลขที่ตำแหน่ง ${org.orgChild1ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||
);
|
||||
if (
|
||||
posMaster.orgChild1Id == org.id &&
|
||||
posMaster.orgChild2Id == null &&
|
||||
|
|
@ -1481,6 +1501,14 @@ export class EmployeePositionController extends Controller {
|
|||
where: { id: requestBody.id },
|
||||
});
|
||||
if (org != null) {
|
||||
const _posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { orgChild2Id: org.id, posMasterNo: posMaster.posMasterNo },
|
||||
});
|
||||
if (_posMaster != null)
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
`เลขที่ตำแหน่ง ${org.orgChild2ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||
);
|
||||
if (
|
||||
posMaster.orgChild2Id == org.id &&
|
||||
posMaster.orgChild3Id == null &&
|
||||
|
|
@ -1500,6 +1528,14 @@ export class EmployeePositionController extends Controller {
|
|||
where: { id: requestBody.id },
|
||||
});
|
||||
if (org != null) {
|
||||
const _posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { orgChild3Id: org.id, posMasterNo: posMaster.posMasterNo },
|
||||
});
|
||||
if (_posMaster != null)
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
`เลขที่ตำแหน่ง ${org.orgChild3ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||
);
|
||||
if (posMaster.orgChild3Id == org.id && posMaster.orgChild4Id == null) change = false;
|
||||
posMaster.orgRootId = org.orgRootId;
|
||||
posMaster.orgChild1Id = org.orgChild1Id;
|
||||
|
|
@ -1514,6 +1550,14 @@ export class EmployeePositionController extends Controller {
|
|||
where: { id: requestBody.id },
|
||||
});
|
||||
if (org != null) {
|
||||
const _posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { orgChild4Id: org.id, posMasterNo: posMaster.posMasterNo },
|
||||
});
|
||||
if (_posMaster != null)
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
`เลขที่ตำแหน่ง ${org.orgChild4ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||
);
|
||||
if (posMaster.orgChild4Id == org.id) change = false;
|
||||
posMaster.orgRootId = org.orgRootId;
|
||||
posMaster.orgChild1Id = org.orgChild1Id;
|
||||
|
|
@ -1524,7 +1568,7 @@ export class EmployeePositionController extends Controller {
|
|||
}
|
||||
}
|
||||
if (change == true) {
|
||||
posMaster.posMasterNo = maxPosMasterNo += 1;
|
||||
// posMaster.posMasterNo = maxPosMasterNo += 1;
|
||||
posMaster.posMasterOrder = maxPosMasterOrder += 1;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue