diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 7768a586..e11c2177 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -1238,7 +1238,7 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { (x: PosMaster) => x.orgRootId == dataId && x.orgChild1Id == null, ) as any) { delete item.id; - const posMaster: any = Object.assign(new PosMaster(), item); + const posMaster = Object.assign(new PosMaster(), item); posMaster.positions = []; if ( @@ -1274,13 +1274,12 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - posMaster.posMasterAssigns = item.posMasterAssigns.map( - ({ id, ...rest }: PosMasterAssign) => ({ + await posMasterAssignRepository.save( + item.posMasterAssigns.map(({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, - }), + })), ); - await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1365,13 +1364,12 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - posMaster.posMasterAssigns = item.posMasterAssigns.map( - ({ id, ...rest }: PosMasterAssign) => ({ + await posMasterAssignRepository.save( + item.posMasterAssigns.map(({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, - }), + })), ); - await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1458,13 +1456,12 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - posMaster.posMasterAssigns = item.posMasterAssigns.map( - ({ id, ...rest }: PosMasterAssign) => ({ + await posMasterAssignRepository.save( + item.posMasterAssigns.map(({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, - }), + })), ); - await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1553,13 +1550,12 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - posMaster.posMasterAssigns = item.posMasterAssigns.map( - ({ id, ...rest }: PosMasterAssign) => ({ + await posMasterAssignRepository.save( + item.posMasterAssigns.map(({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, - }), + })), ); - await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1651,13 +1647,12 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - posMaster.posMasterAssigns = item.posMasterAssigns.map( - ({ id, ...rest }: PosMasterAssign) => ({ + await posMasterAssignRepository.save( + item.posMasterAssigns.map(({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, - }), + })), ); - await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) {