update Retire Clear Org

This commit is contained in:
mamoss 2025-11-03 14:51:42 +07:00
parent 0c523a55a4
commit dcff08db6f

View file

@ -6312,4 +6312,50 @@ export class ImportDataController extends Controller {
}
return new HttpSuccess();
}
@Post("updateRetireClearOrg")
async updateRetireClearOrg(@Request() request: { user: Record<string, any> }) {
const profiles = await this.profileRepo.find({
where: {
isLeave: true,
},
});
for (const item of profiles) {
const posmaster = await this.posMasterRepo.findOne({
where: {
orgRevision: {
orgRevisionIsCurrent: false,
orgRevisionIsDraft: true,
},
next_holderId: item.id,
},
});
if (!posmaster) continue;
posmaster.next_holderId = null;
await this.posMasterRepo.save(posmaster);
}
const profileEmps = await this.profileEmpRepo.find({
where: {
isLeave: true,
},
});
for (const item of profileEmps) {
const posmaster = await this.posMasterEmpRepo.findOne({
where: {
orgRevision: {
orgRevisionIsCurrent: false,
orgRevisionIsDraft: true,
},
next_holderId: item.id,
},
});
if (!posmaster) continue;
posmaster.next_holderId = null;
await this.posMasterEmpRepo.save(posmaster);
}
return new HttpSuccess();
}
}