#1305 ลบ posMasterAct
This commit is contained in:
parent
c297572c79
commit
018aae2c57
3 changed files with 57 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ import { ProfileSalary } from "../entities/ProfileSalary";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { CommandRecive } from "../entities/CommandRecive";
|
||||
import { PosMasterAct } from "../entities/PosMasterAct";
|
||||
export function calculateAge(start: Date, end = new Date()) {
|
||||
if (start.getTime() > end.getTime()) return null;
|
||||
|
||||
|
|
@ -331,6 +332,34 @@ export async function removeProfileInOrganize(profileId: string, type: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function removePostMasterAct(profileId: string) {
|
||||
const currentRevision = await AppDataSource.getRepository(OrgRevision)
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
|
||||
if (!currentRevision) {
|
||||
return;
|
||||
}
|
||||
|
||||
const findProfileInposMaster = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: currentRevision?.id })
|
||||
.andWhere("posMaster.current_holderId = :profileId", { profileId })
|
||||
.getOne();
|
||||
|
||||
if (!findProfileInposMaster) {
|
||||
return;
|
||||
}
|
||||
|
||||
const posMasterAct = await AppDataSource.getRepository(PosMasterAct)
|
||||
.createQueryBuilder("posMasterAct")
|
||||
.where("posMasterAct.posMasterChildId = :posMasterChildId", { posMasterChildId: findProfileInposMaster.id })
|
||||
.getMany();
|
||||
await AppDataSource.getRepository(PosMasterAct).remove(posMasterAct);
|
||||
}
|
||||
|
||||
export async function checkReturnCommandType(commandId: string) {
|
||||
const commandRepository = AppDataSource.getRepository(Command);
|
||||
const _type = await commandRepository.findOne({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue