fix test created
This commit is contained in:
parent
142c2b60fa
commit
748c89294b
1 changed files with 78 additions and 93 deletions
|
|
@ -702,6 +702,83 @@ export class PositionController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let fullPosName = String((requestBody.posMasterNoPrefix).trim() + (requestBody.posMasterNo) + (requestBody.posMasterNoSuffix).trim());
|
||||||
|
let filterName = `CONCAT(posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||||
|
|
||||||
|
const chk_FullName0 = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("posMaster")
|
||||||
|
.from("posMaster", "posMaster")
|
||||||
|
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||||
|
.andWhere("posMaster.orgRootShortName = :orgRootShortName", { orgRootShortName: SName })
|
||||||
|
.andWhere("posMaster.orgChild1Id IS NULL")
|
||||||
|
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||||
|
|
||||||
|
if (chk_FullName0 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const chk_FullName1 = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("posMaster")
|
||||||
|
.from("posMaster", "posMaster")
|
||||||
|
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||||
|
.andWhere("posMaster.orgChild1ShortName = :orgChild1ShortName", { orgChild1ShortName: SName })
|
||||||
|
.andWhere("posMaster.orgChild2Id IS NULL")
|
||||||
|
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||||
|
|
||||||
|
if (chk_FullName1 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const chk_FullName2 = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("posMaster")
|
||||||
|
.from("posMaster", "posMaster")
|
||||||
|
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||||
|
.andWhere("posMaster.orgChild2ShortName = :orgChild2ShortName", { orgChild2ShortName: SName })
|
||||||
|
.andWhere("posMaster.orgChild3Id IS NULL")
|
||||||
|
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||||
|
|
||||||
|
if (chk_FullName2 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const chk_FullName3 = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("posMaster")
|
||||||
|
.from("posMaster", "posMaster")
|
||||||
|
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||||
|
.andWhere("posMaster.orgChild3ShortName = :orgChild3ShortName", { orgChild3ShortName: SName })
|
||||||
|
.andWhere("posMaster.orgChild4Id IS NULL")
|
||||||
|
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||||
|
|
||||||
|
if (chk_FullName3 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const chk_FullName4 = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("posMaster")
|
||||||
|
.from("posMaster", "posMaster")
|
||||||
|
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||||
|
.andWhere("posMaster.orgChild4ShortName = :orgChild4ShortName", { orgChild4ShortName: SName })
|
||||||
|
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||||
|
|
||||||
|
if (chk_FullName4 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
posMaster.createdUserId = request.user.sub;
|
posMaster.createdUserId = request.user.sub;
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
|
|
@ -922,98 +999,6 @@ export class PositionController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let fullPosMasterNo = String((requestBody.posMasterNoPrefix).trim() + (requestBody.posMasterNo) + (requestBody.posMasterNoSuffix).trim());
|
|
||||||
// if (fullPosMasterNo === String(requestBody.posMasterNo)) {
|
|
||||||
// throw new HttpError(
|
|
||||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
// "ไม่สามารถเพิ่มข้อมูลชื่อตำแหน่งซ้ำกันได้",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const chk_SName0 = await this.posMasterRepository.findOne({
|
|
||||||
// where: {
|
|
||||||
// orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
// orgRoot: { orgRootShortName: SName },
|
|
||||||
// orgChild1Id: IsNull(),
|
|
||||||
// posMasterNo: requestBody.posMasterNo,
|
|
||||||
// id: Not(posMaster.id),
|
|
||||||
// },
|
|
||||||
// relations: ["orgRoot"],
|
|
||||||
// });
|
|
||||||
// if (chk_SName0 != null) {
|
|
||||||
// throw new HttpError(
|
|
||||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
// "ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const chk_SName1 = await this.posMasterRepository.findOne({
|
|
||||||
// where: {
|
|
||||||
// orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
// orgChild1: { orgChild1ShortName: SName },
|
|
||||||
// orgChild2Id: IsNull(),
|
|
||||||
// posMasterNo: requestBody.posMasterNo,
|
|
||||||
// id: Not(posMaster.id),
|
|
||||||
// },
|
|
||||||
// relations: ["orgChild1"],
|
|
||||||
// });
|
|
||||||
// if (chk_SName1 != null) {
|
|
||||||
// throw new HttpError(
|
|
||||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
// "ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const chk_SName2 = await this.posMasterRepository.findOne({
|
|
||||||
// where: {
|
|
||||||
// orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
// orgChild2: { orgChild2ShortName: SName },
|
|
||||||
// orgChild3Id: IsNull(),
|
|
||||||
// posMasterNo: requestBody.posMasterNo,
|
|
||||||
// id: Not(posMaster.id),
|
|
||||||
// },
|
|
||||||
// relations: ["orgChild2"],
|
|
||||||
// });
|
|
||||||
// if (chk_SName2 != null) {
|
|
||||||
// throw new HttpError(
|
|
||||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
// "ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const chk_SName3 = await this.posMasterRepository.findOne({
|
|
||||||
// where: {
|
|
||||||
// orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
// orgChild3: { orgChild3ShortName: SName },
|
|
||||||
// orgChild4Id: IsNull(),
|
|
||||||
// posMasterNo: requestBody.posMasterNo,
|
|
||||||
// id: Not(posMaster.id),
|
|
||||||
// },
|
|
||||||
// relations: ["orgChild3"],
|
|
||||||
// });
|
|
||||||
// if (chk_SName3 != null) {
|
|
||||||
// throw new HttpError(
|
|
||||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
// "ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const chk_SName4 = await this.posMasterRepository.findOne({
|
|
||||||
// where: {
|
|
||||||
// orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
// orgChild4: { orgChild4ShortName: SName },
|
|
||||||
// posMasterNo: requestBody.posMasterNo,
|
|
||||||
// id: Not(posMaster.id),
|
|
||||||
// },
|
|
||||||
// relations: ["orgChild4"],
|
|
||||||
// });
|
|
||||||
// if (chk_SName4 != null) {
|
|
||||||
// throw new HttpError(
|
|
||||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
// "ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
posMaster.createdUserId = request.user.sub;
|
posMaster.createdUserId = request.user.sub;
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue