@things-factory/warehouse-base 7.1.28 → 7.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ export * from './pallet-count/pallet-count-types';
25
25
  export * from './pallet-history/pallet-history-types';
26
26
  export * from './warehouse/warehouse-types';
27
27
  export * from './tote/tote-types';
28
- export declare const entities: (typeof import("./warehouse/warehouse").Warehouse | typeof import("./location/location").Location | typeof import("./pallet/pallet").Pallet | typeof import("./inventory/inventory").Inventory | typeof import("./inventory-history/inventory-history").InventoryHistory | typeof import("./inventory-item/inventory-item").InventoryItem | typeof import("./inventory-item-change/inventory-item-change").InventoryItemChange | typeof import("./inventory-change/inventory-change").InventoryChange | typeof import("./movement/movement").Movement | typeof import("./pallet-history/pallet-history").PalletHistory | typeof import("./pallet-count/pallet-count").PalletCount | typeof import("./reduced-inventory-history/reduced-inventory-history").ReducedInventoryHistory | typeof import("./tote/tote").Tote)[];
28
+ export declare const entities: (typeof import("./inventory/inventory").Inventory | typeof import("./inventory-change/inventory-change").InventoryChange | typeof import("./inventory-history/inventory-history").InventoryHistory | typeof import("./inventory-item/inventory-item").InventoryItem | typeof import("./inventory-item-change/inventory-item-change").InventoryItemChange | typeof import("./location/location").Location | typeof import("./movement/movement").Movement | typeof import("./pallet/pallet").Pallet | typeof import("./pallet-count/pallet-count").PalletCount | typeof import("./pallet-history/pallet-history").PalletHistory | typeof import("./warehouse/warehouse").Warehouse | typeof import("./reduced-inventory-history/reduced-inventory-history").ReducedInventoryHistory | typeof import("./tote/tote").Tote)[];
29
29
  export declare const schema: {
30
- resolverClasses: (typeof import("./location/location-mutation").LocationMutation | typeof import("./warehouse/warehouse-mutation").WarehouseMutation | typeof import("./inventory/inventory-mutation").InventoryMutation | typeof import("..").InventoryQuery | typeof import("./inventory-item/inventory-item-query").InventoryItemQuery | typeof import("./inventory-change/inventory-change-mutation").InventoryChangeMutation | typeof import("./inventory-change/inventory-change-query").InventoryChangeQuery | typeof import("./inventory-history/inventory-history-mutation").InventoryHistoryMutation | typeof import("./inventory-history/inventory-history-query").InventoryHistoryQuery | typeof import("./inventory-item/inventory-item-mutation").InventoryItemMutation | typeof import("./inventory-item-change/inventory-item-change-query").InventoryItemChangeQuery | typeof import("./inventory-item-change/inventory-item-change-mutation").InventoryItemChangeMutation | typeof import("./location/location-query").LocationQuery | typeof import("./movement/movement-mutation").MovementMutation | typeof import("./movement/movement-query").MovementQuery | typeof import("./pallet/pallet-mutation").PalletMutation | typeof import("./pallet/pallet-query").PalletQuery | typeof import("./pallet-count/pallet-count-mutation").PalletCountMutation | typeof import("./pallet-count/pallet-count-query").PalletCountQuery | typeof import("./pallet-history/pallet-history-mutation").PalletHistoryMutation | typeof import("./pallet-history/pallet-history-query").PalletHistoryQuery | typeof import("./warehouse/warehouse-query").WarehouseQuery | typeof import("./tote/tote-mutation").ToteMutation | typeof import("./tote/tote-query").ToteQuery)[];
30
+ resolverClasses: (typeof import("./inventory/inventory-mutation").InventoryMutation | typeof import("..").InventoryQuery | typeof import("./inventory-change/inventory-change-query").InventoryChangeQuery | typeof import("./inventory-change/inventory-change-mutation").InventoryChangeMutation | typeof import("./inventory-history/inventory-history-query").InventoryHistoryQuery | typeof import("./inventory-history/inventory-history-mutation").InventoryHistoryMutation | typeof import("./inventory-item/inventory-item-query").InventoryItemQuery | typeof import("./inventory-item/inventory-item-mutation").InventoryItemMutation | typeof import("./inventory-item-change/inventory-item-change-query").InventoryItemChangeQuery | typeof import("./inventory-item-change/inventory-item-change-mutation").InventoryItemChangeMutation | typeof import("./location/location-query").LocationQuery | typeof import("./location/location-mutation").LocationMutation | typeof import("./movement/movement-query").MovementQuery | typeof import("./movement/movement-mutation").MovementMutation | typeof import("./pallet/pallet-query").PalletQuery | typeof import("./pallet/pallet-mutation").PalletMutation | typeof import("./pallet-count/pallet-count-query").PalletCountQuery | typeof import("./pallet-count/pallet-count-mutation").PalletCountMutation | typeof import("./pallet-history/pallet-history-query").PalletHistoryQuery | typeof import("./pallet-history/pallet-history-mutation").PalletHistoryMutation | typeof import("./warehouse/warehouse-query").WarehouseQuery | typeof import("./warehouse/warehouse-mutation").WarehouseMutation | typeof import("./tote/tote-query").ToteQuery | typeof import("./tote/tote-mutation").ToteMutation)[];
31
31
  };
@@ -9,6 +9,8 @@ const biz_base_1 = require("@things-factory/biz-base");
9
9
  const id_rule_base_1 = require("@things-factory/id-rule-base");
10
10
  const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
11
11
  const product_base_1 = require("@things-factory/product-base");
12
+ // @ts-ignore
13
+ const sales_base_1 = require("@things-factory/sales-base");
12
14
  const constants_1 = require("../../constants");
13
15
  const controllers_1 = require("../../controllers");
14
16
  const utils_1 = require("../../utils");
@@ -93,6 +95,12 @@ let InventoryMutation = class InventoryMutation {
93
95
  let inventory = await invQb.getOne();
94
96
  if (!inventory)
95
97
  throw new Error('Inventory not found');
98
+ const arrivalNotice = await tx.getRepository(sales_base_1.ArrivalNotice).findOne({
99
+ where: {
100
+ domain: { id: domain.id },
101
+ id: (0, typeorm_1.Equal)(inventory.refOrderId)
102
+ }
103
+ });
96
104
  if (qty > inventory.qty - ((inventory === null || inventory === void 0 ? void 0 : inventory.lockedQty) > 0 ? inventory.lockedQty : 0))
97
105
  throw new Error('Transfer quantity exceeded inventory quantity');
98
106
  if (toLocation.name == inventory.location.name)
@@ -124,8 +132,8 @@ let InventoryMutation = class InventoryMutation {
124
132
  else {
125
133
  newInventory.originInventory = { id: inventory.id };
126
134
  }
127
- await transactionInventory.transactionInventory(Object.assign(Object.assign({}, inventory), { qty: inventory.qty - transferQty, uomValue: inventory.uomValue - transferUomValue }), null, -transferQty, -transferUomValue, constants_1.INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null);
128
- await transactionInventory.transactionInventory(newInventory, null, transferQty, transferUomValue, constants_1.INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null);
135
+ await transactionInventory.transactionInventory(Object.assign(Object.assign({}, inventory), { qty: inventory.qty - transferQty, uomValue: inventory.uomValue - transferUomValue }), arrivalNotice, -transferQty, -transferUomValue, constants_1.INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null);
136
+ await transactionInventory.transactionInventory(newInventory, arrivalNotice, transferQty, transferUomValue, constants_1.INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null);
129
137
  if (sellercraft) {
130
138
  const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
131
139
  await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory);
@@ -144,7 +152,7 @@ let InventoryMutation = class InventoryMutation {
144
152
  if ((isEmptyLocation.length = 1)) {
145
153
  await tx.getRepository(location_1.Location).save(Object.assign(Object.assign({}, fromLocation), { status: constants_1.LOCATION_STATUS.EMPTY }));
146
154
  }
147
- await transactionInventory.transactionInventory(inventory, null, 0, 0, constants_1.INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null);
155
+ await transactionInventory.transactionInventory(inventory, arrivalNotice, 0, 0, constants_1.INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null);
148
156
  if (sellercraft) {
149
157
  const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
150
158
  await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory);
@@ -366,7 +374,10 @@ async function updateMultipleInventory(patches, context) {
366
374
  if (newRecord.product && newRecord.product.id) {
367
375
  newRecord.product = (await tx.getRepository(product_base_1.Product).findOneBy({ id: newRecord.product.id }));
368
376
  }
369
- if ((newRecord.product && newRecord.product.id) || (newRecord.bizplace && newRecord.bizplace.id) || newRecord.batchId || newRecord.packingType) {
377
+ if ((newRecord.product && newRecord.product.id) ||
378
+ (newRecord.bizplace && newRecord.bizplace.id) ||
379
+ newRecord.batchId ||
380
+ newRecord.packingType) {
370
381
  if (inventory.bizplace.id !== (newRecord.bizplace ? newRecord.bizplace.id : '') ||
371
382
  inventory.product.id !== (newRecord.product ? newRecord.product.id : '') ||
372
383
  inventory.batchId !== newRecord.batchId ||
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,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,OAAO,IAChB,CAAA;YAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In, MoreThan, SelectQueryBuilder } from 'typeorm'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { generateId } from '@things-factory/id-rule-base'\nimport { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'\nimport { Product } from '@things-factory/product-base'\n\nimport { INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, LOCATION_STATUS, RULE_TYPE } from '../../constants'\nimport { SellercraftController } from '../../controllers'\nimport { DateGenerator, InventoryNoGenerator, InventoryUtil } from '../../utils'\nimport { InventoryHistory } from '../inventory-history/inventory-history'\nimport { Location } from '../location/location'\nimport { Inventory } from './inventory'\nimport { InventoryPatch, NewInventory } from './inventory-types'\n\n@Resolver(Inventory)\nexport class InventoryMutation {\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Inventory)\n async createInventory(@Arg('inventory') inventory: NewInventory, @Ctx() context: ResolverContext): Promise<Inventory> {\n const { tx } = context.state\n\n return await tx.getRepository(Inventory).save({\n domain: context.state.domain,\n creator: context.state.user,\n updater: context.state.user,\n ...inventory\n })\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Inventory)\n async updateInventory(@Arg('patch') patch: InventoryPatch, @Ctx() context: ResolverContext): Promise<Inventory> {\n const { domain, user, tx } = context.state\n\n const invQb: SelectQueryBuilder<Inventory> = await tx\n .getRepository(Inventory)\n .createQueryBuilder('INV')\n .where('INV.domain_id = :domainId', { domainId: domain.id })\n .andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: patch.bizplace.id })\n .andWhere('INV.batch_id = :batchId', { batchId: patch.batchId })\n .andWhere('INV.product_id = :productId', { productId: patch.product.id })\n .andWhere('INV.packing_type = :packingType', { packingType: patch.packingType })\n .andWhere('INV.packing_size = :packingSize', { packingSize: patch.packingSize })\n\n if (patch?.cartonId) invQb.andWhere('INV.carton_id = :cartonId', { cartonId: patch.cartonId })\n else invQb.andWhere('INV.pallet_id = :palletId', { palletId: patch.palletId })\n\n const inventory = await invQb.getOne()\n\n return await tx.getRepository(Inventory).save({\n ...inventory,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Inventory)\n async updateInventoryRemark(@Arg('id') id: string, @Arg('remark') remark: string, @Ctx() context: ResolverContext): Promise<Inventory> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Inventory)\n const inventory = await repository.findOne({ where: { domain: { id: domain.id }, id } })\n\n return await repository.save({\n ...inventory,\n remark,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteInventory(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { tx } = context.state\n\n await tx.getRepository(Inventory).delete({ domain: { id: context.state.domain.id }, name })\n return true\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => [Inventory])\n async updateMultipleInventory(@Arg('patches', type => [InventoryPatch]) patches: InventoryPatch[], @Ctx() context: ResolverContext): Promise<Inventory[]> {\n return await updateMultipleInventory(patches, context)\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteInventories(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<Boolean> {\n const { tx } = context.state\n\n await tx.getRepository(Inventory).delete({\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async inventoryTransfer(\n @Arg('originPalletId') originPalletId: string,\n @Arg('palletId', { nullable: true }) palletId: string,\n @Arg('cartonId', { nullable: true }) cartonId: string,\n @Arg('fromLocationName') fromLocationName: string,\n @Arg('toLocationName') toLocationName: string,\n @Arg('qty') qty: number,\n @Arg('reason', { nullable: true }) reason: string,\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user, tx } = context.state\n\n const fromLocation: Location = await tx.getRepository(Location).findOne({\n where: { domain: { id: domain.id }, name: fromLocationName },\n relations: ['domain', 'warehouse']\n })\n // 1. check toLocation exist\n const toLocation: Location = await tx.getRepository(Location).findOne({\n where: { domain: { id: domain.id }, name: toLocationName },\n relations: ['domain', 'warehouse']\n })\n if (!toLocation) throw new Error(context.t(`error.To_location_does_not_exists`))\n\n if (qty < 0) throw new Error(`Invalid quantity`)\n\n // 2. search for related inventory\n const invQb: SelectQueryBuilder<Inventory> = await tx\n .getRepository(Inventory)\n .createQueryBuilder('INV')\n .innerJoinAndSelect('INV.location', 'loc')\n .innerJoinAndSelect('INV.product', 'product')\n .innerJoinAndSelect('INV.bizplace', 'bizplace')\n .leftJoinAndSelect('INV.refInventory', 'refInventory')\n .leftJoinAndSelect('INV.reusablePallet', 'reusablePallet')\n .leftJoinAndSelect('INV.productDetail', 'productDetail')\n .leftJoinAndSelect('bizplace.domain', 'domain')\n .leftJoinAndSelect('product.productDetails', 'productDetails')\n .leftJoinAndSelect('INV.originInventory', 'originInventory')\n .where('INV.domain_id = :domainId', { domainId: domain.id })\n .andWhere('INV.pallet_id = :palletId', { palletId: originPalletId })\n\n let inventory: Inventory = await invQb.getOne()\n if (!inventory) throw new Error('Inventory not found')\n\n if (qty > inventory.qty - (inventory?.lockedQty > 0 ? inventory.lockedQty : 0)) throw new Error('Transfer quantity exceeded inventory quantity')\n\n if (toLocation.name == inventory.location.name) throw new Error('Inventory is in current location')\n\n let transactionInventory = new InventoryUtil(tx, domain, user)\n\n const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({\n where: { domain: { id: inventory.bizplace.domain.id }, status: SellercraftStatus.ACTIVE },\n relations: ['domain']\n })\n\n const partialTransferFunc = async function (inventory, qty, fromLocation, toLocation, cartonId, palletId, context) {\n const { user, tx } = context.state\n\n if (qty < inventory.qty - (inventory?.lockedQty > 0 ? inventory.lockedQty : 0)) {\n if (!palletId || palletId.trim() == '') throw new Error('Require new lot id for partial transfer')\n\n let transferQty = qty\n let transferUomValue = (inventory.uomValue / inventory.qty) * qty\n let newInventory = {\n ...inventory,\n palletId,\n location: toLocation,\n warehouse: toLocation.warehouse,\n zone: toLocation.zone,\n creator: user,\n updater: user\n }\n\n delete newInventory.id\n delete newInventory.updatedAt\n\n newInventory.cartonId = cartonId\n newInventory.qty = transferQty\n newInventory.lockedQty = 0\n newInventory.uomValue = transferUomValue\n newInventory.lockedUomValue = 0\n if (inventory.originInventory?.id) {\n newInventory.originInventory = { id: inventory.originInventory.id }\n } else {\n newInventory.originInventory = { id: inventory.id }\n }\n\n await transactionInventory.transactionInventory(\n { ...inventory, qty: inventory.qty - transferQty, uomValue: inventory.uomValue - transferUomValue },\n null,\n -transferQty,\n -transferUomValue,\n INVENTORY_TRANSACTION_TYPE.RELOCATE,\n reason || null\n )\n\n await transactionInventory.transactionInventory(newInventory, null, transferQty, transferUomValue, INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null)\n\n if (sellercraft) {\n const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)\n await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)\n await sellercraftCtrl.updateSellercraftStock(sellercraft, newInventory)\n }\n } else {\n inventory.warehouse = toLocation.warehouse\n inventory.location = toLocation\n inventory.zone = toLocation.zone\n inventory.updater = user\n inventory.cartonId = cartonId\n\n let isEmptyLocation = await tx.getRepository(Inventory).find({\n where: { location: { id: fromLocation.id } }\n })\n\n if ((isEmptyLocation.length = 1)) {\n await tx.getRepository(Location).save({\n ...fromLocation,\n status: LOCATION_STATUS.EMPTY\n })\n }\n\n await transactionInventory.transactionInventory(inventory, null, 0, 0, INVENTORY_TRANSACTION_TYPE.RELOCATE, reason || null)\n\n if (sellercraft) {\n const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)\n await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)\n }\n }\n }\n\n if (inventory.cartonId && inventory.cartonId != '') {\n if (!cartonId) throw new Error('Require carton id')\n\n if (qty < inventory.qty - (inventory?.lockedQty > 0 ? inventory.lockedQty : 0)) {\n palletId = await generateId({\n domain: domain,\n type: RULE_TYPE.LOT_NUMBER_ID,\n seed: { date: DateGenerator.generateDate() }\n })\n }\n\n await partialTransferFunc(inventory, qty, fromLocation, toLocation, cartonId, palletId, context)\n } else {\n if (!palletId) {\n palletId = await generateId({\n domain: domain,\n type: RULE_TYPE.LOT_NUMBER_ID,\n seed: { date: DateGenerator.generateDate() }\n })\n }\n await partialTransferFunc(inventory, qty, fromLocation, toLocation, null, palletId, context)\n }\n\n return true\n }\n}\n\nexport async function updateMultipleInventory(patches: InventoryPatch[], context: ResolverContext): Promise<Inventory[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => !patch.id)\n const _updateRecords = patches.filter((patch: any) => patch.id)\n\n const inventoryRepo = tx.getRepository(Inventory)\n if (_createRecords.length > 0) {\n let today = new Date()\n let year = today.getFullYear()\n let month = today.getMonth()\n let date = today.getDate()\n\n for (let i = 0; i < _createRecords.length; i++) {\n const total = await tx.getRepository(Inventory).countBy({\n createdAt: MoreThan(new Date(year, month, date))\n })\n\n const newRecord = _createRecords[i]\n\n if (newRecord.location && newRecord.location.id) {\n var location = await tx.getRepository(Location).findOne({\n where: { id: newRecord.location.id },\n relations: ['warehouse']\n })\n newRecord.location = location\n newRecord.zone = location.zone\n newRecord.warehouse = location.warehouse\n }\n\n if (newRecord.bizplace && newRecord.bizplace.id) {\n newRecord.bizplace = (await tx.getRepository(Bizplace).findOneBy({ id: newRecord.bizplace.id })) as any\n }\n\n if (newRecord.product && newRecord.product.id) {\n var product = (await tx.getRepository(Product).findOneBy({ id: newRecord.product.id })) as any\n newRecord.product = product\n }\n\n let palletId =\n 'P' +\n year.toString().substr(year.toString().length - 2) +\n ('0' + (month + 1).toString()).substr(('0' + (month + 1).toString()).toString().length - 2) +\n ('0' + date.toString()).substr(('0' + date.toString()).length - 2) +\n ('0000' + (total + 1).toString()).substr(('0000' + (total + 1).toString()).length - 4)\n\n newRecord.name = palletId\n newRecord.status = newRecord.qty < 1 ? 'TERMINATED' : 'STORED'\n newRecord.palletId = palletId\n\n const result = await inventoryRepo.save({\n domain: domain,\n creator: user,\n updater: user,\n lastSeq: 0,\n ...newRecord\n } as any)\n\n await tx.getRepository(InventoryHistory).save({\n ...newRecord,\n domain: domain,\n creator: user,\n updater: user,\n name: InventoryNoGenerator.inventoryHistoryName(),\n seq: 0,\n transactionType: 'NEW',\n productId: newRecord.product.id,\n warehouseId: newRecord.warehouse.id,\n locationId: newRecord.location.id\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const newHistoryRecord = JSON.parse(JSON.stringify(_updateRecords[i]))\n let transactionType = ''\n\n let inventory = await inventoryRepo.findOne({\n where: { id: newRecord.id },\n relations: ['warehouse', 'location', 'product', 'bizplace']\n })\n newHistoryRecord.openingQty = inventory.qty\n newHistoryRecord.openingUomValue = inventory.uomValue\n\n // Get last sequence from InventoryHistory\n let latestEntry = await tx.getRepository(InventoryHistory).find({\n where: { palletId: inventory.palletId },\n order: { seq: 'DESC' },\n take: 1\n })\n let lastSeq = latestEntry[0].seq\n\n // Condition 1: Change location (RELOCATE)\n if (newRecord.location && newRecord.location.id) {\n var location = await tx.getRepository(Location).findOne({\n where: { id: newRecord.location.id },\n relations: ['warehouse']\n })\n newRecord.location = location\n newRecord.zone = location.zone\n newRecord.warehouse = location.warehouse\n\n newHistoryRecord.location = location\n newHistoryRecord.zone = location.zone\n newHistoryRecord.warehouse = location.warehouse\n\n transactionType = 'RELOCATE'\n }\n\n // Condition 2: Change of qty or uomValue.\n // Set qty movement for inventory history\n if (typeof newRecord.qty != 'undefined') {\n transactionType = 'ADJUSTMENT'\n newHistoryRecord.qty = newRecord.qty - inventory.qty\n if (newRecord.qty < 1) {\n newRecord.status = 'TERMINATED'\n newRecord.qty = 0\n newRecord.uomValue = 0\n }\n } else {\n newHistoryRecord.qty = 0\n }\n // Set uomValue movement for inventory history\n if (typeof newRecord.uomValue != 'undefined') {\n transactionType = 'ADJUSTMENT'\n newHistoryRecord.uomValue = newRecord.uomValue - inventory.uomValue\n if (newRecord.uomValue < 1) {\n newRecord.uomValue = 0\n }\n } else {\n newHistoryRecord.uomValue = 0\n }\n\n // Condition 3: Change of bizplace or product or batch id or packing type\n if (newRecord.bizplace && newRecord.bizplace.id) {\n newRecord.bizplace = (await tx.getRepository(Bizplace).findOneBy({ id: newRecord.bizplace.id })) as any\n }\n\n if (newRecord.product && newRecord.product.id) {\n newRecord.product = (await tx.getRepository(Product).findOneBy({ id: newRecord.product.id })) as any\n }\n\n if ((newRecord.product && newRecord.product.id) || (newRecord.bizplace && newRecord.bizplace.id) || newRecord.batchId || newRecord.packingType) {\n if (\n inventory.bizplace.id !== (newRecord.bizplace ? newRecord.bizplace.id : '') ||\n inventory.product.id !== (newRecord.product ? newRecord.product.id : '') ||\n inventory.batchId !== newRecord.batchId ||\n inventory.packingType !== newRecord.packingType\n ) {\n transactionType = 'ADJUSTMENT'\n lastSeq = lastSeq + 1\n let inventoryHistory: any = {\n ...inventory,\n domain: domain,\n bizplace: inventory.bizplace.id,\n openingQty: inventory.qty,\n openingUomValue: inventory.uomValue,\n qty: -inventory.qty || 0,\n uomValue: -inventory.uomValue || 0,\n name: InventoryNoGenerator.inventoryHistoryName(),\n seq: lastSeq,\n inventory,\n transactionType: transactionType,\n status: INVENTORY_STATUS.TERMINATED,\n productId: inventory.product.id,\n warehouseId: inventory.warehouse.id,\n locationId: inventory.location.id,\n creator: user,\n updater: user\n }\n\n delete inventoryHistory.id\n await tx.getRepository(InventoryHistory).save(inventoryHistory as any)\n\n newHistoryRecord.qty = newRecord.qty || inventory.qty\n newHistoryRecord.uomValue = newRecord.uomValue || inventory.uomValue || 0\n newHistoryRecord.openingQty = 0\n newHistoryRecord.openingUomValue = 0\n newHistoryRecord.batchId = newRecord.batchId || inventory.batchId || '-'\n }\n }\n\n //Transaction type will be RELOCATE if there is only location change. Any other changes will be considered Adjustment.\n lastSeq = lastSeq + 1\n let inventoryHistory = {\n ...inventory,\n ...newHistoryRecord,\n domain: domain,\n creator: user,\n updater: user,\n name: InventoryNoGenerator.inventoryHistoryName(),\n seq: lastSeq,\n inventory,\n transactionType: transactionType == '' ? 'ADJUSTMENT' : transactionType,\n productId: newHistoryRecord.product ? newHistoryRecord.product.id : inventory.product.id,\n warehouseId: newHistoryRecord.warehouse ? newHistoryRecord.warehouse.id : inventory.warehouse.id,\n locationId: newHistoryRecord.location ? newHistoryRecord.location.id : inventory.location.id\n }\n\n delete inventoryHistory.id\n await tx.getRepository(InventoryHistory).save(inventoryHistory)\n\n const result = await inventoryRepo.save({\n ...inventory,\n ...newRecord,\n updater: user,\n lastSeq: lastSeq\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n}\n"]}
1
+ {"version":3,"file":"inventory-mutation.js","sourceRoot":"","sources":["../../../server/service/inventory/inventory-mutation.ts"],"names":[],"mappings":";;;AA8SA,0DAmOC;;AAjhBD,+CAAsE;AACtE,qCAAiE;AAEjE,uDAAmD;AACnD,+DAAyD;AACzD,qFAAwF;AACxF,+DAAsD;AACtD,aAAa;AACb,2DAA0D;AAE1D,+CAA0G;AAC1G,mDAAyD;AACzD,uCAAgF;AAChF,8EAAyE;AACzE,mDAA+C;AAC/C,2CAAuC;AACvC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I,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In, MoreThan, SelectQueryBuilder, Equal } from 'typeorm'\n\nimport { Bizplace } from '@things-factory/biz-base'\nimport { generateId } from '@things-factory/id-rule-base'\nimport { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'\nimport { Product } from '@things-factory/product-base'\n// @ts-ignore\nimport { ArrivalNotice } from '@things-factory/sales-base'\n\nimport { INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, LOCATION_STATUS, RULE_TYPE } from '../../constants'\nimport { SellercraftController } from '../../controllers'\nimport { DateGenerator, InventoryNoGenerator, InventoryUtil } from '../../utils'\nimport { InventoryHistory } from '../inventory-history/inventory-history'\nimport { Location } from '../location/location'\nimport { Inventory } from './inventory'\nimport { InventoryPatch, NewInventory } from './inventory-types'\n\n@Resolver(Inventory)\nexport class InventoryMutation {\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Inventory)\n async createInventory(\n @Arg('inventory') inventory: NewInventory,\n @Ctx() context: ResolverContext\n ): Promise<Inventory> {\n const { tx } = context.state\n\n return await tx.getRepository(Inventory).save({\n domain: context.state.domain,\n creator: context.state.user,\n updater: context.state.user,\n ...inventory\n })\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Inventory)\n async updateInventory(@Arg('patch') patch: InventoryPatch, @Ctx() context: ResolverContext): Promise<Inventory> {\n const { domain, user, tx } = context.state\n\n const invQb: SelectQueryBuilder<Inventory> = await tx\n .getRepository(Inventory)\n .createQueryBuilder('INV')\n .where('INV.domain_id = :domainId', { domainId: domain.id })\n .andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: patch.bizplace.id })\n .andWhere('INV.batch_id = :batchId', { batchId: patch.batchId })\n .andWhere('INV.product_id = :productId', { productId: patch.product.id })\n .andWhere('INV.packing_type = :packingType', { packingType: patch.packingType })\n .andWhere('INV.packing_size = :packingSize', { packingSize: patch.packingSize })\n\n if (patch?.cartonId) invQb.andWhere('INV.carton_id = :cartonId', { cartonId: patch.cartonId })\n else invQb.andWhere('INV.pallet_id = :palletId', { palletId: patch.palletId })\n\n const inventory = await invQb.getOne()\n\n return await tx.getRepository(Inventory).save({\n ...inventory,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Inventory)\n async updateInventoryRemark(\n @Arg('id') id: string,\n @Arg('remark') remark: string,\n @Ctx() context: ResolverContext\n ): Promise<Inventory> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Inventory)\n const inventory = await repository.findOne({ where: { domain: { id: domain.id }, id } })\n\n return await repository.save({\n ...inventory,\n remark,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteInventory(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { tx } = context.state\n\n await tx.getRepository(Inventory).delete({ domain: { id: context.state.domain.id }, name })\n return true\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => [Inventory])\n async updateMultipleInventory(\n @Arg('patches', type => [InventoryPatch]) patches: InventoryPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Inventory[]> {\n return await updateMultipleInventory(patches, context)\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteInventories(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { tx } = context.state\n\n await tx.getRepository(Inventory).delete({\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@privilege(category: \"inventory\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async inventoryTransfer(\n @Arg('originPalletId') originPalletId: string,\n @Arg('palletId', { nullable: true }) palletId: string,\n @Arg('cartonId', { nullable: true }) cartonId: string,\n @Arg('fromLocationName') fromLocationName: string,\n @Arg('toLocationName') toLocationName: string,\n @Arg('qty') qty: number,\n @Arg('reason', { nullable: true }) reason: string,\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user, tx } = context.state\n\n const fromLocation: Location = await tx.getRepository(Location).findOne({\n where: { domain: { id: domain.id }, name: fromLocationName },\n relations: ['domain', 'warehouse']\n })\n // 1. check toLocation exist\n const toLocation: Location = await tx.getRepository(Location).findOne({\n where: { domain: { id: domain.id }, name: toLocationName },\n relations: ['domain', 'warehouse']\n })\n if (!toLocation) throw new Error(context.t(`error.To_location_does_not_exists`))\n\n if (qty < 0) throw new Error(`Invalid quantity`)\n\n // 2. search for related inventory\n const invQb: SelectQueryBuilder<Inventory> = await tx\n .getRepository(Inventory)\n .createQueryBuilder('INV')\n .innerJoinAndSelect('INV.location', 'loc')\n .innerJoinAndSelect('INV.product', 'product')\n .innerJoinAndSelect('INV.bizplace', 'bizplace')\n .leftJoinAndSelect('INV.refInventory', 'refInventory')\n .leftJoinAndSelect('INV.reusablePallet', 'reusablePallet')\n .leftJoinAndSelect('INV.productDetail', 'productDetail')\n .leftJoinAndSelect('bizplace.domain', 'domain')\n .leftJoinAndSelect('product.productDetails', 'productDetails')\n .leftJoinAndSelect('INV.originInventory', 'originInventory')\n .where('INV.domain_id = :domainId', { domainId: domain.id })\n .andWhere('INV.pallet_id = :palletId', { palletId: originPalletId })\n\n let inventory: Inventory = await invQb.getOne()\n if (!inventory) throw new Error('Inventory not found')\n const arrivalNotice: ArrivalNotice = await tx.getRepository(ArrivalNotice).findOne({\n where: {\n domain: { id: domain.id },\n id: Equal(inventory.refOrderId)\n }\n })\n\n if (qty > inventory.qty - (inventory?.lockedQty > 0 ? inventory.lockedQty : 0))\n throw new Error('Transfer quantity exceeded inventory quantity')\n\n if (toLocation.name == inventory.location.name) throw new Error('Inventory is in current location')\n\n let transactionInventory = new InventoryUtil(tx, domain, user)\n\n const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({\n where: { domain: { id: inventory.bizplace.domain.id }, status: SellercraftStatus.ACTIVE },\n relations: ['domain']\n })\n\n const partialTransferFunc = async function (inventory, qty, fromLocation, toLocation, cartonId, palletId, context) {\n const { user, tx } = context.state\n\n if (qty < inventory.qty - (inventory?.lockedQty > 0 ? inventory.lockedQty : 0)) {\n if (!palletId || palletId.trim() == '') throw new Error('Require new lot id for partial transfer')\n\n let transferQty = qty\n let transferUomValue = (inventory.uomValue / inventory.qty) * qty\n let newInventory = {\n ...inventory,\n palletId,\n location: toLocation,\n warehouse: toLocation.warehouse,\n zone: toLocation.zone,\n creator: user,\n updater: user\n }\n\n delete newInventory.id\n delete newInventory.updatedAt\n\n newInventory.cartonId = cartonId\n newInventory.qty = transferQty\n newInventory.lockedQty = 0\n newInventory.uomValue = transferUomValue\n newInventory.lockedUomValue = 0\n if (inventory.originInventory?.id) {\n newInventory.originInventory = { id: inventory.originInventory.id }\n } else {\n newInventory.originInventory = { id: inventory.id }\n }\n\n await transactionInventory.transactionInventory(\n { ...inventory, qty: inventory.qty - transferQty, uomValue: inventory.uomValue - transferUomValue },\n arrivalNotice,\n -transferQty,\n -transferUomValue,\n INVENTORY_TRANSACTION_TYPE.RELOCATE,\n reason || null\n )\n\n await transactionInventory.transactionInventory(\n newInventory,\n arrivalNotice,\n transferQty,\n transferUomValue,\n INVENTORY_TRANSACTION_TYPE.RELOCATE,\n reason || null\n )\n\n if (sellercraft) {\n const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)\n await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)\n await sellercraftCtrl.updateSellercraftStock(sellercraft, newInventory)\n }\n } else {\n inventory.warehouse = toLocation.warehouse\n inventory.location = toLocation\n inventory.zone = toLocation.zone\n inventory.updater = user\n inventory.cartonId = cartonId\n\n let isEmptyLocation = await tx.getRepository(Inventory).find({\n where: { location: { id: fromLocation.id } }\n })\n\n if ((isEmptyLocation.length = 1)) {\n await tx.getRepository(Location).save({\n ...fromLocation,\n status: LOCATION_STATUS.EMPTY\n })\n }\n\n await transactionInventory.transactionInventory(\n inventory,\n arrivalNotice,\n 0,\n 0,\n INVENTORY_TRANSACTION_TYPE.RELOCATE,\n reason || null\n )\n\n if (sellercraft) {\n const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)\n await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)\n }\n }\n }\n\n if (inventory.cartonId && inventory.cartonId != '') {\n if (!cartonId) throw new Error('Require carton id')\n\n if (qty < inventory.qty - (inventory?.lockedQty > 0 ? inventory.lockedQty : 0)) {\n palletId = await generateId({\n domain: domain,\n type: RULE_TYPE.LOT_NUMBER_ID,\n seed: { date: DateGenerator.generateDate() }\n })\n }\n\n await partialTransferFunc(inventory, qty, fromLocation, toLocation, cartonId, palletId, context)\n } else {\n if (!palletId) {\n palletId = await generateId({\n domain: domain,\n type: RULE_TYPE.LOT_NUMBER_ID,\n seed: { date: DateGenerator.generateDate() }\n })\n }\n await partialTransferFunc(inventory, qty, fromLocation, toLocation, null, palletId, context)\n }\n\n return true\n }\n}\n\nexport async function updateMultipleInventory(\n patches: InventoryPatch[],\n context: ResolverContext\n): Promise<Inventory[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => !patch.id)\n const _updateRecords = patches.filter((patch: any) => patch.id)\n\n const inventoryRepo = tx.getRepository(Inventory)\n if (_createRecords.length > 0) {\n let today = new Date()\n let year = today.getFullYear()\n let month = today.getMonth()\n let date = today.getDate()\n\n for (let i = 0; i < _createRecords.length; i++) {\n const total = await tx.getRepository(Inventory).countBy({\n createdAt: MoreThan(new Date(year, month, date))\n })\n\n const newRecord = _createRecords[i]\n\n if (newRecord.location && newRecord.location.id) {\n var location = await tx.getRepository(Location).findOne({\n where: { id: newRecord.location.id },\n relations: ['warehouse']\n })\n newRecord.location = location\n newRecord.zone = location.zone\n newRecord.warehouse = location.warehouse\n }\n\n if (newRecord.bizplace && newRecord.bizplace.id) {\n newRecord.bizplace = (await tx.getRepository(Bizplace).findOneBy({ id: newRecord.bizplace.id })) as any\n }\n\n if (newRecord.product && newRecord.product.id) {\n var product = (await tx.getRepository(Product).findOneBy({ id: newRecord.product.id })) as any\n newRecord.product = product\n }\n\n let palletId =\n 'P' +\n year.toString().substr(year.toString().length - 2) +\n ('0' + (month + 1).toString()).substr(('0' + (month + 1).toString()).toString().length - 2) +\n ('0' + date.toString()).substr(('0' + date.toString()).length - 2) +\n ('0000' + (total + 1).toString()).substr(('0000' + (total + 1).toString()).length - 4)\n\n newRecord.name = palletId\n newRecord.status = newRecord.qty < 1 ? 'TERMINATED' : 'STORED'\n newRecord.palletId = palletId\n\n const result = await inventoryRepo.save({\n domain: domain,\n creator: user,\n updater: user,\n lastSeq: 0,\n ...newRecord\n } as any)\n\n await tx.getRepository(InventoryHistory).save({\n ...newRecord,\n domain: domain,\n creator: user,\n updater: user,\n name: InventoryNoGenerator.inventoryHistoryName(),\n seq: 0,\n transactionType: 'NEW',\n productId: newRecord.product.id,\n warehouseId: newRecord.warehouse.id,\n locationId: newRecord.location.id\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const newHistoryRecord = JSON.parse(JSON.stringify(_updateRecords[i]))\n let transactionType = ''\n\n let inventory = await inventoryRepo.findOne({\n where: { id: newRecord.id },\n relations: ['warehouse', 'location', 'product', 'bizplace']\n })\n newHistoryRecord.openingQty = inventory.qty\n newHistoryRecord.openingUomValue = inventory.uomValue\n\n // Get last sequence from InventoryHistory\n let latestEntry = await tx.getRepository(InventoryHistory).find({\n where: { palletId: inventory.palletId },\n order: { seq: 'DESC' },\n take: 1\n })\n let lastSeq = latestEntry[0].seq\n\n // Condition 1: Change location (RELOCATE)\n if (newRecord.location && newRecord.location.id) {\n var location = await tx.getRepository(Location).findOne({\n where: { id: newRecord.location.id },\n relations: ['warehouse']\n })\n newRecord.location = location\n newRecord.zone = location.zone\n newRecord.warehouse = location.warehouse\n\n newHistoryRecord.location = location\n newHistoryRecord.zone = location.zone\n newHistoryRecord.warehouse = location.warehouse\n\n transactionType = 'RELOCATE'\n }\n\n // Condition 2: Change of qty or uomValue.\n // Set qty movement for inventory history\n if (typeof newRecord.qty != 'undefined') {\n transactionType = 'ADJUSTMENT'\n newHistoryRecord.qty = newRecord.qty - inventory.qty\n if (newRecord.qty < 1) {\n newRecord.status = 'TERMINATED'\n newRecord.qty = 0\n newRecord.uomValue = 0\n }\n } else {\n newHistoryRecord.qty = 0\n }\n // Set uomValue movement for inventory history\n if (typeof newRecord.uomValue != 'undefined') {\n transactionType = 'ADJUSTMENT'\n newHistoryRecord.uomValue = newRecord.uomValue - inventory.uomValue\n if (newRecord.uomValue < 1) {\n newRecord.uomValue = 0\n }\n } else {\n newHistoryRecord.uomValue = 0\n }\n\n // Condition 3: Change of bizplace or product or batch id or packing type\n if (newRecord.bizplace && newRecord.bizplace.id) {\n newRecord.bizplace = (await tx.getRepository(Bizplace).findOneBy({ id: newRecord.bizplace.id })) as any\n }\n\n if (newRecord.product && newRecord.product.id) {\n newRecord.product = (await tx.getRepository(Product).findOneBy({ id: newRecord.product.id })) as any\n }\n\n if (\n (newRecord.product && newRecord.product.id) ||\n (newRecord.bizplace && newRecord.bizplace.id) ||\n newRecord.batchId ||\n newRecord.packingType\n ) {\n if (\n inventory.bizplace.id !== (newRecord.bizplace ? newRecord.bizplace.id : '') ||\n inventory.product.id !== (newRecord.product ? newRecord.product.id : '') ||\n inventory.batchId !== newRecord.batchId ||\n inventory.packingType !== newRecord.packingType\n ) {\n transactionType = 'ADJUSTMENT'\n lastSeq = lastSeq + 1\n let inventoryHistory: any = {\n ...inventory,\n domain: domain,\n bizplace: inventory.bizplace.id,\n openingQty: inventory.qty,\n openingUomValue: inventory.uomValue,\n qty: -inventory.qty || 0,\n uomValue: -inventory.uomValue || 0,\n name: InventoryNoGenerator.inventoryHistoryName(),\n seq: lastSeq,\n inventory,\n transactionType: transactionType,\n status: INVENTORY_STATUS.TERMINATED,\n productId: inventory.product.id,\n warehouseId: inventory.warehouse.id,\n locationId: inventory.location.id,\n creator: user,\n updater: user\n }\n\n delete inventoryHistory.id\n await tx.getRepository(InventoryHistory).save(inventoryHistory as any)\n\n newHistoryRecord.qty = newRecord.qty || inventory.qty\n newHistoryRecord.uomValue = newRecord.uomValue || inventory.uomValue || 0\n newHistoryRecord.openingQty = 0\n newHistoryRecord.openingUomValue = 0\n newHistoryRecord.batchId = newRecord.batchId || inventory.batchId || '-'\n }\n }\n\n //Transaction type will be RELOCATE if there is only location change. Any other changes will be considered Adjustment.\n lastSeq = lastSeq + 1\n let inventoryHistory = {\n ...inventory,\n ...newHistoryRecord,\n domain: domain,\n creator: user,\n updater: user,\n name: InventoryNoGenerator.inventoryHistoryName(),\n seq: lastSeq,\n inventory,\n transactionType: transactionType == '' ? 'ADJUSTMENT' : transactionType,\n productId: newHistoryRecord.product ? newHistoryRecord.product.id : inventory.product.id,\n warehouseId: newHistoryRecord.warehouse ? newHistoryRecord.warehouse.id : inventory.warehouse.id,\n locationId: newHistoryRecord.location ? newHistoryRecord.location.id : inventory.location.id\n }\n\n delete inventoryHistory.id\n await tx.getRepository(InventoryHistory).save(inventoryHistory)\n\n const result = await inventoryRepo.save({\n ...inventory,\n ...newRecord,\n updater: user,\n lastSeq: lastSeq\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n}\n"]}
@@ -2,4 +2,4 @@ import { InventoryChange } from './inventory-change';
2
2
  import { InventoryChangeMutation } from './inventory-change-mutation';
3
3
  import { InventoryChangeQuery } from './inventory-change-query';
4
4
  export declare const entities: (typeof InventoryChange)[];
5
- export declare const resolvers: (typeof InventoryChangeMutation | typeof InventoryChangeQuery)[];
5
+ export declare const resolvers: (typeof InventoryChangeQuery | typeof InventoryChangeMutation)[];
@@ -2,4 +2,4 @@ import { InventoryHistory } from './inventory-history';
2
2
  import { InventoryHistoryMutation } from './inventory-history-mutation';
3
3
  import { InventoryHistoryQuery } from './inventory-history-query';
4
4
  export declare const entities: (typeof InventoryHistory)[];
5
- export declare const resolvers: (typeof InventoryHistoryMutation | typeof InventoryHistoryQuery)[];
5
+ export declare const resolvers: (typeof InventoryHistoryQuery | typeof InventoryHistoryMutation)[];
@@ -2,4 +2,4 @@ import { Location } from './location';
2
2
  import { LocationMutation } from './location-mutation';
3
3
  import { LocationQuery } from './location-query';
4
4
  export declare const entities: (typeof Location)[];
5
- export declare const resolvers: (typeof LocationMutation | typeof LocationQuery)[];
5
+ export declare const resolvers: (typeof LocationQuery | typeof LocationMutation)[];
@@ -2,4 +2,4 @@ import { Movement } from './movement';
2
2
  import { MovementMutation } from './movement-mutation';
3
3
  import { MovementQuery } from './movement-query';
4
4
  export declare const entities: (typeof Movement)[];
5
- export declare const resolvers: (typeof MovementMutation | typeof MovementQuery)[];
5
+ export declare const resolvers: (typeof MovementQuery | typeof MovementMutation)[];
@@ -2,4 +2,4 @@ import { Pallet } from './pallet';
2
2
  import { PalletMutation } from './pallet-mutation';
3
3
  import { PalletQuery } from './pallet-query';
4
4
  export declare const entities: (typeof Pallet)[];
5
- export declare const resolvers: (typeof PalletMutation | typeof PalletQuery)[];
5
+ export declare const resolvers: (typeof PalletQuery | typeof PalletMutation)[];
@@ -2,4 +2,4 @@ import { PalletCount } from './pallet-count';
2
2
  import { PalletCountMutation } from './pallet-count-mutation';
3
3
  import { PalletCountQuery } from './pallet-count-query';
4
4
  export declare const entities: (typeof PalletCount)[];
5
- export declare const resolvers: (typeof PalletCountMutation | typeof PalletCountQuery)[];
5
+ export declare const resolvers: (typeof PalletCountQuery | typeof PalletCountMutation)[];
@@ -2,4 +2,4 @@ import { PalletHistory } from './pallet-history';
2
2
  import { PalletHistoryMutation } from './pallet-history-mutation';
3
3
  import { PalletHistoryQuery } from './pallet-history-query';
4
4
  export declare const entities: (typeof PalletHistory)[];
5
- export declare const resolvers: (typeof PalletHistoryMutation | typeof PalletHistoryQuery)[];
5
+ export declare const resolvers: (typeof PalletHistoryQuery | typeof PalletHistoryMutation)[];
@@ -2,4 +2,4 @@ import { Tote } from './tote';
2
2
  import { ToteMutation } from './tote-mutation';
3
3
  import { ToteQuery } from './tote-query';
4
4
  export declare const entities: (typeof Tote)[];
5
- export declare const resolvers: (typeof ToteMutation | typeof ToteQuery)[];
5
+ export declare const resolvers: (typeof ToteQuery | typeof ToteMutation)[];
@@ -2,4 +2,4 @@ import { Warehouse } from './warehouse';
2
2
  import { WarehouseMutation } from './warehouse-mutation';
3
3
  import { WarehouseQuery } from './warehouse-query';
4
4
  export declare const entities: (typeof Warehouse)[];
5
- export declare const resolvers: (typeof WarehouseMutation | typeof WarehouseQuery)[];
5
+ export declare const resolvers: (typeof WarehouseQuery | typeof WarehouseMutation)[];