This commit is contained in:
parent
489b67945b
commit
d58464ce91
1 changed files with 20 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
||||||
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||||
import { PosMasterEmployeeTempHistory } from "../entities/PosMasterEmployeeTempHistory";
|
import { PosMasterEmployeeTempHistory } from "../entities/PosMasterEmployeeTempHistory";
|
||||||
|
|
@ -17,6 +18,7 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
await AppDataSource.transaction(async (manager) => {
|
await AppDataSource.transaction(async (manager) => {
|
||||||
const repoPosmaster = manager.getRepository(PosMaster);
|
const repoPosmaster = manager.getRepository(PosMaster);
|
||||||
const repoHistory = manager.getRepository(PosMasterHistory);
|
const repoHistory = manager.getRepository(PosMasterHistory);
|
||||||
|
const repoOrgRevision = manager.getRepository(OrgRevision);
|
||||||
|
|
||||||
const pm = await repoPosmaster.findOne({
|
const pm = await repoPosmaster.findOne({
|
||||||
where: { id: posMasterId },
|
where: { id: posMasterId },
|
||||||
|
|
@ -31,11 +33,20 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
"orgChild3",
|
"orgChild3",
|
||||||
"orgChild4",
|
"orgChild4",
|
||||||
"current_holder",
|
"current_holder",
|
||||||
|
"next_holder",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!pm) return false;
|
if (!pm) return false;
|
||||||
if (!pm.ancestorDNA) return false;
|
if (!pm.ancestorDNA) return false;
|
||||||
|
|
||||||
|
const checkCurrentRevision = await repoOrgRevision.findOne({
|
||||||
|
where:{
|
||||||
|
id: pm.orgRevisionId,
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
orgRevisionIsDraft: false
|
||||||
|
}
|
||||||
|
})
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
const h = new PosMasterHistory();
|
const h = new PosMasterHistory();
|
||||||
const selectedPosition =
|
const selectedPosition =
|
||||||
|
|
@ -44,9 +55,15 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
: null;
|
: null;
|
||||||
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
||||||
if(!type || type != "DELETE"){
|
if(!type || type != "DELETE"){
|
||||||
h.prefix = pm.current_holder?.prefix || _null;
|
if(checkCurrentRevision){
|
||||||
h.firstName = pm.current_holder?.firstName || _null;
|
h.prefix = pm.current_holder?.prefix || _null;
|
||||||
h.lastName = pm.current_holder?.lastName || _null;
|
h.firstName = pm.current_holder?.firstName || _null;
|
||||||
|
h.lastName = pm.current_holder?.lastName || _null;
|
||||||
|
}else{
|
||||||
|
h.prefix = pm.next_holder?.prefix || _null;
|
||||||
|
h.firstName = pm.next_holder?.firstName || _null;
|
||||||
|
h.lastName = pm.next_holder?.lastName || _null;
|
||||||
|
}
|
||||||
h.position = selectedPosition?.positionName ?? _null;
|
h.position = selectedPosition?.positionName ?? _null;
|
||||||
h.posType = selectedPosition?.posType?.posTypeName ?? _null;
|
h.posType = selectedPosition?.posType?.posTypeName ?? _null;
|
||||||
h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null;
|
h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue