diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 08eacd6c..d6345ac0 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -6312,4 +6312,50 @@ export class ImportDataController extends Controller { } return new HttpSuccess(); } + + @Post("updateRetireClearOrg") + async updateRetireClearOrg(@Request() request: { user: Record }) { + 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(); + } }