@things-factory/warehouse-base 5.0.14 → 6.0.0-alpha.3

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.
Files changed (142) hide show
  1. package/dist-server/controllers/ecommerce/ecommerce-controller.js +1 -1
  2. package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +1 -1
  3. package/dist-server/controllers/ecommerce/sellercraft-controller.js +64 -60
  4. package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
  5. package/dist-server/controllers/warehouse-controller.js +7 -5
  6. package/dist-server/controllers/warehouse-controller.js.map +1 -1
  7. package/dist-server/service/inventory/inventory-mutation.js +6 -6
  8. package/dist-server/service/inventory/inventory-mutation.js.map +1 -1
  9. package/dist-server/service/inventory/inventory-query.js +217 -195
  10. package/dist-server/service/inventory/inventory-query.js.map +1 -1
  11. package/dist-server/service/inventory/inventory-types.js +14 -15
  12. package/dist-server/service/inventory/inventory-types.js.map +1 -1
  13. package/dist-server/service/inventory/inventory.js +62 -42
  14. package/dist-server/service/inventory/inventory.js.map +1 -1
  15. package/dist-server/service/inventory-change/inventory-change-mutation.js +252 -216
  16. package/dist-server/service/inventory-change/inventory-change-mutation.js.map +1 -1
  17. package/dist-server/service/inventory-change/inventory-change-query.js +6 -7
  18. package/dist-server/service/inventory-change/inventory-change-query.js.map +1 -1
  19. package/dist-server/service/inventory-change/inventory-change.js +7 -7
  20. package/dist-server/service/inventory-change/inventory-change.js.map +1 -1
  21. package/dist-server/service/inventory-history/inventory-history-mutation.js +1 -1
  22. package/dist-server/service/inventory-history/inventory-history-mutation.js.map +1 -1
  23. package/dist-server/service/inventory-history/inventory-history-query.js +89 -99
  24. package/dist-server/service/inventory-history/inventory-history-query.js.map +1 -1
  25. package/dist-server/service/inventory-history/inventory-history-types.js +3 -3
  26. package/dist-server/service/inventory-history/inventory-history-types.js.map +1 -1
  27. package/dist-server/service/inventory-history/inventory-history.js +7 -7
  28. package/dist-server/service/inventory-history/inventory-history.js.map +1 -1
  29. package/dist-server/service/inventory-item/inventory-item-mutation.js +10 -10
  30. package/dist-server/service/inventory-item/inventory-item-mutation.js.map +1 -1
  31. package/dist-server/service/inventory-item/inventory-item-query.js +18 -17
  32. package/dist-server/service/inventory-item/inventory-item-query.js.map +1 -1
  33. package/dist-server/service/inventory-item/inventory-item-type.js +4 -5
  34. package/dist-server/service/inventory-item/inventory-item-type.js.map +1 -1
  35. package/dist-server/service/inventory-item/inventory-item.js +5 -5
  36. package/dist-server/service/inventory-item/inventory-item.js.map +1 -1
  37. package/dist-server/service/inventory-item-change/inventory-item-change-mutation.js +4 -4
  38. package/dist-server/service/inventory-item-change/inventory-item-change-mutation.js.map +1 -1
  39. package/dist-server/service/inventory-item-change/inventory-item-change-query.js +7 -9
  40. package/dist-server/service/inventory-item-change/inventory-item-change-query.js.map +1 -1
  41. package/dist-server/service/inventory-item-change/inventory-item-change-type.js +6 -7
  42. package/dist-server/service/inventory-item-change/inventory-item-change-type.js.map +1 -1
  43. package/dist-server/service/inventory-item-change/inventory-item-change.js +3 -4
  44. package/dist-server/service/inventory-item-change/inventory-item-change.js.map +1 -1
  45. package/dist-server/service/inventory-product/inventory-product-mutation.js +4 -4
  46. package/dist-server/service/inventory-product/inventory-product-mutation.js.map +1 -1
  47. package/dist-server/service/inventory-product/inventory-product-query.js +7 -9
  48. package/dist-server/service/inventory-product/inventory-product-query.js.map +1 -1
  49. package/dist-server/service/inventory-product/inventory-product-type.js +1 -2
  50. package/dist-server/service/inventory-product/inventory-product-type.js.map +1 -1
  51. package/dist-server/service/inventory-product/inventory-product.js +5 -5
  52. package/dist-server/service/inventory-product/inventory-product.js.map +1 -1
  53. package/dist-server/service/location/location-mutation.js +5 -5
  54. package/dist-server/service/location/location-mutation.js.map +1 -1
  55. package/dist-server/service/location/location-query.js +17 -19
  56. package/dist-server/service/location/location-query.js.map +1 -1
  57. package/dist-server/service/location/location-types.js +3 -3
  58. package/dist-server/service/location/location-types.js.map +1 -1
  59. package/dist-server/service/location/location.js +14 -14
  60. package/dist-server/service/location/location.js.map +1 -1
  61. package/dist-server/service/movement/movement-mutation.js +6 -5
  62. package/dist-server/service/movement/movement-mutation.js.map +1 -1
  63. package/dist-server/service/movement/movement-query.js +15 -15
  64. package/dist-server/service/movement/movement-query.js.map +1 -1
  65. package/dist-server/service/movement/movement-types.js +4 -5
  66. package/dist-server/service/movement/movement-types.js.map +1 -1
  67. package/dist-server/service/movement/movement.js +5 -5
  68. package/dist-server/service/movement/movement.js.map +1 -1
  69. package/dist-server/service/pallet/pallet-mutation.js +5 -5
  70. package/dist-server/service/pallet/pallet-mutation.js.map +1 -1
  71. package/dist-server/service/pallet/pallet-query.js +9 -11
  72. package/dist-server/service/pallet/pallet-query.js.map +1 -1
  73. package/dist-server/service/pallet/pallet-types.js +5 -6
  74. package/dist-server/service/pallet/pallet-types.js.map +1 -1
  75. package/dist-server/service/pallet/pallet.js +6 -6
  76. package/dist-server/service/pallet/pallet.js.map +1 -1
  77. package/dist-server/service/pallet-count/pallet-count-mutation.js +1 -1
  78. package/dist-server/service/pallet-count/pallet-count-mutation.js.map +1 -1
  79. package/dist-server/service/pallet-count/pallet-count-query.js +6 -8
  80. package/dist-server/service/pallet-count/pallet-count-query.js.map +1 -1
  81. package/dist-server/service/pallet-count/pallet-count.js +3 -4
  82. package/dist-server/service/pallet-count/pallet-count.js.map +1 -1
  83. package/dist-server/service/pallet-history/pallet-history-mutation.js +1 -1
  84. package/dist-server/service/pallet-history/pallet-history-mutation.js.map +1 -1
  85. package/dist-server/service/pallet-history/pallet-history-query.js +6 -8
  86. package/dist-server/service/pallet-history/pallet-history-query.js.map +1 -1
  87. package/dist-server/service/pallet-history/pallet-history.js +6 -6
  88. package/dist-server/service/pallet-history/pallet-history.js.map +1 -1
  89. package/dist-server/service/reduced-inventory-history/reduced-inventory-history.js +1 -1
  90. package/dist-server/service/reduced-inventory-history/reduced-inventory-history.js.map +1 -1
  91. package/dist-server/service/tote/tote-mutation.js +4 -4
  92. package/dist-server/service/tote/tote-mutation.js.map +1 -1
  93. package/dist-server/service/tote/tote-query.js +12 -13
  94. package/dist-server/service/tote/tote-query.js.map +1 -1
  95. package/dist-server/service/tote/tote-types.js +2 -3
  96. package/dist-server/service/tote/tote-types.js.map +1 -1
  97. package/dist-server/service/tote/tote.js +5 -5
  98. package/dist-server/service/tote/tote.js.map +1 -1
  99. package/dist-server/service/warehouse/warehouse-mutation.js +1 -1
  100. package/dist-server/service/warehouse/warehouse-mutation.js.map +1 -1
  101. package/dist-server/service/warehouse/warehouse-query.js +9 -10
  102. package/dist-server/service/warehouse/warehouse-query.js.map +1 -1
  103. package/dist-server/service/warehouse/warehouse.js +12 -12
  104. package/dist-server/service/warehouse/warehouse.js.map +1 -1
  105. package/dist-server/tsconfig.tsbuildinfo +1 -1
  106. package/dist-server/utils/inventory-util.js +16 -16
  107. package/dist-server/utils/inventory-util.js.map +1 -1
  108. package/package.json +8 -8
  109. package/server/controllers/ecommerce/ecommerce-controller.ts +1 -1
  110. package/server/controllers/ecommerce/sellercraft-controller.ts +75 -65
  111. package/server/controllers/warehouse-controller.ts +9 -4
  112. package/server/service/inventory/inventory-mutation.ts +28 -24
  113. package/server/service/inventory/inventory-query.ts +269 -304
  114. package/server/service/inventory/inventory.ts +50 -35
  115. package/server/service/inventory-change/inventory-change-mutation.ts +305 -256
  116. package/server/service/inventory-change/inventory-change-query.ts +9 -9
  117. package/server/service/inventory-history/inventory-history-mutation.ts +12 -15
  118. package/server/service/inventory-history/inventory-history-query.ts +158 -133
  119. package/server/service/inventory-item/inventory-item-mutation.ts +20 -17
  120. package/server/service/inventory-item/inventory-item-query.ts +28 -18
  121. package/server/service/inventory-item-change/inventory-item-change-mutation.ts +12 -9
  122. package/server/service/inventory-item-change/inventory-item-change-query.ts +10 -8
  123. package/server/service/inventory-product/inventory-product-mutation.ts +16 -12
  124. package/server/service/inventory-product/inventory-product-query.ts +7 -8
  125. package/server/service/location/location-mutation.ts +24 -24
  126. package/server/service/location/location-query.ts +27 -23
  127. package/server/service/location/location.ts +11 -10
  128. package/server/service/movement/movement-mutation.ts +7 -8
  129. package/server/service/movement/movement-query.ts +18 -16
  130. package/server/service/pallet/pallet-mutation.ts +18 -20
  131. package/server/service/pallet/pallet-query.ts +13 -14
  132. package/server/service/pallet-count/pallet-count-mutation.ts +20 -17
  133. package/server/service/pallet-count/pallet-count-query.ts +6 -7
  134. package/server/service/pallet-history/pallet-history-mutation.ts +15 -15
  135. package/server/service/pallet-history/pallet-history-query.ts +7 -8
  136. package/server/service/reduced-inventory-history/reduced-inventory-history.ts +1 -1
  137. package/server/service/tote/tote-mutation.ts +23 -22
  138. package/server/service/tote/tote-query.ts +18 -14
  139. package/server/service/warehouse/warehouse-mutation.ts +21 -18
  140. package/server/service/warehouse/warehouse-query.ts +11 -11
  141. package/server/service/warehouse/warehouse.ts +7 -7
  142. package/server/utils/inventory-util.ts +10 -10
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.InventoryHistoryQuery = void 0;
5
4
  const tslib_1 = require("tslib");
@@ -26,10 +25,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
26
25
  });
27
26
  }
28
27
  const convertedParams = (0, shell_1.convertListParams)(params);
29
- let [items, total] = await (0, typeorm_1.getRepository)(inventory_history_1.InventoryHistory).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'bizplace', 'product', 'location', 'warehouse', 'creator', 'updater'], order: {
30
- palletId: 'DESC',
31
- createdAt: 'ASC'
32
- } }));
28
+ let [items, total] = await (0, shell_1.getRepository)(inventory_history_1.InventoryHistory).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'bizplace', 'product', 'location', 'warehouse', 'creator', 'updater'], order: Object.assign(Object.assign({}, convertedParams.order), { palletId: 'DESC', createdAt: 'ASC' }) }));
33
29
  items = (await Promise.all(items.map(async (item) => {
34
30
  switch (item.transactionType) {
35
31
  case 'UNLOADING':
@@ -56,14 +52,15 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
56
52
  }
57
53
  async inventoryHistory(name, context) {
58
54
  const { domain } = context.state;
59
- return await (0, typeorm_1.getRepository)(inventory_history_1.InventoryHistory).findOne({
60
- where: { domain: domain, name, relations: ['domain', 'creator', 'updater'] }
55
+ return await (0, shell_1.getRepository)(inventory_history_1.InventoryHistory).findOne({
56
+ where: { domain: domain, name },
57
+ relations: ['domain', 'creator', 'updater']
61
58
  });
62
59
  }
63
60
  async bizplaceInventoryHistories(context, inventoryHistory, filters, pagination, sortings) {
64
61
  const { domain, user, tx } = context.state;
65
62
  const ownerBizplace = await (0, biz_base_1.getMyBizplace)(domain, user);
66
- const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(inventoryHistory.bizplace.id);
63
+ const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({ id: inventoryHistory.bizplace.id });
67
64
  const productFilters = filters.find(x => x.name == 'product_info');
68
65
  filters = filters.filter(x => x.name != 'product_info');
69
66
  const fromDate = new Date(inventoryHistory.fromDate);
@@ -72,7 +69,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
72
69
  let where = { domain: domain };
73
70
  if (productFilters) {
74
71
  let productFilterValue = `%${productFilters.value.toLowerCase()}%`;
75
- const productQb = (0, typeorm_1.getRepository)(product_base_1.Product).createQueryBuilder('prd');
72
+ const productQb = (0, shell_1.getRepository)(product_base_1.Product).createQueryBuilder('prd');
76
73
  productQb.where(new typeorm_1.Brackets(qb => {
77
74
  qb.where('Lower(prd.sku) LIKE :productInfo', { productInfo: productFilterValue })
78
75
  .orWhere('Lower(prd.name) LIKE :productInfo', { productInfo: productFilterValue })
@@ -83,7 +80,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
83
80
  where['product'] = (0, typeorm_1.In)(_products.map((product) => product.id));
84
81
  }
85
82
  if (inventoryHistory && inventoryHistory.warehouseName) {
86
- const _warehouses = await tx.getRepository(warehouse_1.Warehouse).find({
83
+ const _warehouses = await tx.getRepository(warehouse_1.Warehouse).findBy({
87
84
  domain: domain,
88
85
  name: (0, typeorm_1.Raw)(alias => `LOWER(${alias}) LIKE '${inventoryHistory.warehouseName.toLowerCase()}'`)
89
86
  });
@@ -133,7 +130,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
133
130
  }
134
131
  if (!bizplaceFilter || !fromDate || !toDate)
135
132
  throw 'Invalid input';
136
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
133
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({
137
134
  id: bizplaceFilter.value
138
135
  });
139
136
  let batchNoQuery = '';
@@ -185,7 +182,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
185
182
  await tx.query(`
186
183
  create temp table temp_data_src AS
187
184
  (
188
- SELECT prd.name AS product_name, prd.description AS product_description, prd.type as product_type, prd.aux_value_1 AS product_aux_value_1, trim(invh.batch_id) as batch_id, invh.product_id,
185
+ SELECT prd.sku as sku, prd.name AS product_name, prd.description AS product_description, prd.type as product_type, prd.aux_value_1 AS product_aux_value_1, trim(invh.batch_id) as batch_id, invh.product_id,
189
186
  invh.packing_type, invh.bizplace_id, invh.domain_id,
190
187
  invh.ref_order_id, invh.order_no, invh.order_ref_no, invh.transaction_type, invh.status, invh.created_at,
191
188
  invh.qty, invh.opening_qty,
@@ -201,7 +198,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
201
198
  `, [domain.id, bizplace.id, toDate.value]);
202
199
  await tx.query(`
203
200
  create temp table temp_inv_history as (
204
- SELECT src.product_name, src.product_description, src.product_type, src.product_aux_value_1, src.batch_id, src.product_id, src.packing_type, src.uom,
201
+ SELECT src.sku, src.product_name, src.product_description, src.product_type, src.product_aux_value_1, src.batch_id, src.product_id, src.packing_type, src.uom,
205
202
  src.bizplace_id, src.domain_id,
206
203
  SUM(COALESCE(src.qty,0)) AS qty,
207
204
  SUM(COALESCE(src.opening_qty,0)) AS opening_qty,
@@ -214,14 +211,14 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
214
211
  $1::date AS created_date
215
212
  FROM temp_data_src src
216
213
  WHERE src.created_at < $1::timestamp
217
- GROUP BY src.product_name, src.product_description, src.product_type, src.product_aux_value_1, src.batch_id, src.product_id, src.packing_type, src.uom,
214
+ GROUP BY src.sku, src.product_name, src.product_description, src.product_type, src.product_aux_value_1, src.batch_id, src.product_id, src.packing_type, src.uom,
218
215
  src.bizplace_id, src.domain_id
219
216
  UNION ALL
220
- SELECT product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
217
+ SELECT sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
221
218
  domain_id, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
222
219
  order_name, ref_no, 1 AS rn, MIN(created_at) - $2::interval as created_at, (MIN(created_at) - $2::interval)::DATE as created_date
223
220
  FROM (
224
- SELECT invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.bizplace_id,
221
+ SELECT invh.sku, invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.bizplace_id,
225
222
  invh.domain_id,
226
223
  invh.qty, invh.opening_qty, invh.uom_value, invh.uom, invh.opening_uom_value,
227
224
  COALESCE(order_no, '-') AS order_name,
@@ -234,14 +231,14 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
234
231
  invh.transaction_type <>'NEW'
235
232
  AND invh.created_at >= $1::timestamp
236
233
  ) AS inv_movement
237
- GROUP BY product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
234
+ GROUP BY sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
238
235
  domain_id, order_name, ref_no, rn
239
236
  UNION ALL
240
- SELECT product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
237
+ SELECT sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
241
238
  domain_id, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
242
239
  order_name, ref_no, 1 AS rn, created_at - $2::interval as created_at, created_at::date as created_date
243
240
  FROM (
244
- SELECT invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.uom, invh.bizplace_id,
241
+ SELECT invh.sku, invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.uom, invh.bizplace_id,
245
242
  invh.domain_id,
246
243
  invh.qty, invh.opening_qty, invh.uom_value, invh.opening_uom_value,
247
244
  invh.transaction_type AS order_name,
@@ -254,14 +251,14 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
254
251
  invh.transaction_type = 'NEW')
255
252
  AND invh.created_at >= $1::timestamp
256
253
  ) AS inv_movement
257
- GROUP BY product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
254
+ GROUP BY sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
258
255
  domain_id, order_name, ref_no, rn, created_at
259
256
  UNION ALL
260
- SELECT product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
257
+ SELECT sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
261
258
  domain_id, sum(-opening_qty) as qty, sum(opening_qty) as opening_qty, sum(-opening_uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
262
259
  order_name, ref_no, 1 AS rn, created_at - $2::interval as created_at, created_at::date as created_date
263
260
  FROM (
264
- SELECT invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.uom, invh.bizplace_id,
261
+ SELECT invh.sku, invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.uom, invh.bizplace_id,
265
262
  invh.domain_id,
266
263
  invh.qty, invh.opening_qty, invh.uom_value, invh.opening_uom_value,
267
264
  invh.transaction_type AS order_name,
@@ -274,23 +271,23 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
274
271
  invh.status = 'MISSING'
275
272
  AND invh.created_at >= $1::timestamp
276
273
  ) AS inv_movement
277
- GROUP BY product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
274
+ GROUP BY sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
278
275
  domain_id, order_name, ref_no, rn, created_at
279
276
 
280
277
  )`, [fromDate.value, tzoffset]);
281
278
  const result = await tx.query(`
282
- select product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
279
+ select sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
283
280
  domain_id, qty, opening_qty, round(uom_value::decimal,2) as uom_value, opening_uom_value, order_name, ref_no, created_at::date
284
281
  from temp_inv_history invh where
285
282
  exists (
286
283
  select * from (
287
- select batch_id, product_name, packing_type, sum(qty) as totalQty, count(*) as totalRow from temp_inv_history ih2
288
- group by batch_id, product_name, packing_type
284
+ select sku, batch_id, product_name, packing_type, sum(qty) as totalQty, count(*) as totalRow from temp_inv_history ih2
285
+ group by sku, batch_id, product_name, packing_type
289
286
  ) src
290
- where src.batch_id = invh.batch_id and src.product_name = invh.product_name and src.packing_type = invh.packing_type
287
+ where src.sku = invh.sku and src.batch_id = invh.batch_id and src.product_name = invh.product_name and src.packing_type = invh.packing_type
291
288
  ${hasTransactionOrBalanceQuery}
292
289
  )
293
- ORDER BY invh.product_name asc, invh.product_description asc, invh.packing_type asc, invh.batch_id asc, invh.uom asc, invh.rn asc, invh.created_at asc
290
+ ORDER BY invh.sku asc, invh.product_name asc, invh.product_description asc, invh.packing_type asc, invh.batch_id asc, invh.uom asc, invh.rn asc, invh.created_at asc
294
291
  `);
295
292
  tx.query(`
296
293
  drop table temp_products, temp_data_src, temp_inv_history
@@ -303,6 +300,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
303
300
  packingType: item.packing_type,
304
301
  product: {
305
302
  id: item.product_id,
303
+ sku: item.sku,
306
304
  name: item.product_name +
307
305
  ' ( ' +
308
306
  item.product_description +
@@ -352,7 +350,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
352
350
  throw 'Invalid input';
353
351
  let bizplaceQuery = '';
354
352
  if (bizplaceFilter) {
355
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
353
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({
356
354
  id: bizplaceFilter.value
357
355
  });
358
356
  if (bizplace) {
@@ -501,7 +499,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
501
499
  throw 'Invalid input';
502
500
  let bizplaceQuery = '';
503
501
  if (bizplaceFilter) {
504
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
502
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({
505
503
  id: bizplaceFilter.value
506
504
  });
507
505
  if (bizplace) {
@@ -647,7 +645,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
647
645
  let toDate = params.filters.find(data => data.name === 'toDate');
648
646
  if (!bizplaceFilter || !fromDate || !toDate)
649
647
  throw 'Invalid input';
650
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
648
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({
651
649
  id: bizplaceFilter.value
652
650
  });
653
651
  let queryFilter = ``;
@@ -753,7 +751,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
753
751
  }
754
752
  if (!bizplaceFilter || !fromDate || !toDate)
755
753
  throw 'Invalid input';
756
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
754
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({
757
755
  id: bizplaceFilter.value
758
756
  });
759
757
  let [result, total] = byPallet.value
@@ -904,20 +902,27 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
904
902
  where domain_id = $1 and created_at < $2::timestamp + $3::INTERVAL + '1 day'::INTERVAL
905
903
  );
906
904
  `, [domain.id, createdAt.value, timezoneOffset]);
907
- //comment start
908
- //detailed review needed 19 May 2022 by @ChrisLim-git
905
+ await tx.query(`
906
+ CREATE TEMP TABLE tmp_src_group on commit drop AS (
907
+ select ih.domain_id, ih.pallet_id, sum(ih.qty) as qty, sum(ih.uom_value) as uom_value, max(ih.seq) as last_seq, max(ih.created_at) as created_at,
908
+ min(ih.created_at) as initial_inbound_at
909
+ from tmp_src ih
910
+ group by ih.domain_id, ih.pallet_id
911
+ );
912
+ `);
909
913
  await tx.query(`
910
914
  create temp table tmp_data on commit drop as (
911
915
  select dt.*, rih.carton_id, rih.batch_id, rih.batch_id_ref, rih.product_id, rih.packing_type, rih.bizplace_id, rih.location_id, rih.unit_cost,iv.id as inventory_id, iv.uom,
912
- iv.expiration_date, iv.manufacture_date, iv.reusable_pallet_id, iv.remark,iv.status
916
+ iv.expiration_date, iv.manufacture_date, iv.reusable_pallet_id, iv.remark
913
917
  from
914
918
  (
915
- select ih.domain_id, ih.pallet_id, sum(ih.qty) as qty, sum(ih.uom_value) as uom_value, max(ih.seq) as last_seq, max(ih.created_at) as created_at,
916
- min(ih.created_at) as initial_inbound_at
917
- from tmp_src ih
918
- group by ih.domain_id, ih.pallet_id
919
+ SELECT ih.*, ih2.status FROM tmp_src_group ih
920
+ INNER JOIN inventory_histories ih2
921
+ ON ih.domain_id = ih2.domain_id
922
+ AND ih.pallet_id = ih2.pallet_id
923
+ AND ih.last_seq = ih2.seq
919
924
  ) dt
920
- inner join tmp_src rih on dt.domain_id = rih.domain_id and dt.pallet_id = rih.pallet_id and dt.last_seq = rih.seq
925
+ inner join tmp_src rih on dt.domain_id = rih.domain_id and dt.pallet_id = rih.pallet_id and dt.last_seq = rih.seq and rih.status <> 'TERMINATED'
921
926
  inner join inventories iv on iv.domain_id = dt.domain_id and iv.pallet_id = dt.pallet_id and iv.status <> 'MISSING'
922
927
  where exists (
923
928
  SELECT * FROM tmp_bizfilter bizFilter
@@ -927,39 +932,11 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
927
932
  ${expirationQueryFilter}
928
933
  );
929
934
  `);
930
- await tx.query(`
931
- create temp table tmp_result on commit drop as (
932
- select
933
- rih.domain_id, rih.pallet_id as "palletId", rih.carton_id as "cartonId", rih.qty as "remainQty", rih.uom_value as "uomValue", rih.uom, rih.last_seq, rih.created_at,
934
- rih.initial_inbound_at as "initialInboundAt", rih.unit_cost as "unitCost",
935
- case when rih.reusable_pallet_id is not null then concat(rih.batch_id, ' (', plt.name, ')') else rih.batch_id end as "batchId",
936
- rih.batch_id_ref as "batchIdRef", rih.product_id as "productId", rih.packing_type as "packingType",
937
- prd.id as product_id, prd.name as product_name, prd.sku as product_sku, prd.brand as product_brand, prd.description as product_description, prd.volume as product_volume,
938
- bz.id as bizplace_id, bz.name as bizplace_name,
939
- loc.id as location_id, loc.name as location_name, loc."zone" as location_zone, loc."row" as location_row, loc."column" as location_column, loc.shelf as location_shelf,
940
- wh.name as warehouse_name, plt.name as reusable_pallet_name,
941
- rih.remark,
942
- rih.manufacture_date as "manufactureDate",
943
- rih.expiration_date as "expirationDate"
944
- ,sum(case when oi.status = 'LOADING' or (oi.status = 'SORTING' and oi.type = 'RELEASE_OF_GOODS') then oi.release_qty else 0 end) as "nonLoadedQty"
945
- ,sum(case when oi.status = 'LOADING' or (oi.status = 'SORTING' and oi.type = 'RELEASE_OF_GOODS') then (oi.release_uom_value / oi.release_qty* oi.release_qty) else 0 end) as "nonLoadedUomValue"
946
- from tmp_data rih
947
- left join pallets plt on plt.id = rih.reusable_pallet_id
948
- inner join products prd on prd.id = rih.product_id
949
- inner join bizplaces bz on bz.id = rih.bizplace_id
950
- inner join locations loc on loc.id = rih.location_id
951
- inner join warehouses wh on wh.id = loc.warehouse_id
952
- left join order_inventories oi on oi.inventory_id = rih.inventory_id
953
- group by rih.inventory_id,rih.domain_id,rih.pallet_id,rih.carton_id,rih.qty,rih.uom_value,rih.uom,rih.last_seq,rih.created_at, rih.initial_inbound_at,rih.unit_cost,rih.reusable_pallet_id,
954
- rih.batch_id,plt.name,rih.batch_id_ref,rih.product_id,rih.packing_type,rih.bizplace_id,rih.location_id,prd.id,bz.id,loc.id,wh.name,rih.remark,rih.expiration_date,rih.manufacture_date,rih.status
955
- having 1=1 and (case when rih.status = 'TERMINATED' and SUM(CASE WHEN oi.status = 'LOADING' or (oi.status = 'SORTING' AND oi.type = 'RELEASE_OF_GOODS') THEN oi.release_qty ELSE 0 END) > 0 then rih.status = 'TERMINATED' else rih.status <> 'TERMINATED' end)
956
- order by created_at desc
957
- );
958
- `);
959
- const total = await tx.query(`select count(*) from tmp_result`);
935
+ const total = await tx.query(`select count(*) from tmp_data`);
960
936
  const result = await tx.query(`
961
937
  select
962
- rih.domain_id, rih.pallet_id as "palletId", rih.carton_id as "cartonId", rih.qty as "remainQty", rih.uom_value as "uomValue", rih.uom, rih.last_seq, rih.created_at,
938
+ rih.domain_id, rih.pallet_id as "palletId", rih.carton_id as "cartonId", rih.qty as "remainQty",
939
+ TRUNC(rih.uom_value::numeric,2) as "uomValue", rih.uom, rih.last_seq, rih.created_at,
963
940
  rih.initial_inbound_at as "initialInboundAt", rih.unit_cost as "unitCost",
964
941
  case when rih.reusable_pallet_id is not null then concat(rih.batch_id, ' (', plt.name, ')') else rih.batch_id end as "batchId",
965
942
  rih.batch_id_ref as "batchIdRef", rih.product_id, rih.packing_type as "packingType", rih.bizplace_id, rih.location_id,
@@ -969,23 +946,35 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
969
946
  wh.name as warehouse_name, plt.name as reusable_pallet_name,
970
947
  rih.remark,
971
948
  rih.manufacture_date as "manufactureDate",
972
- rih.expiration_date as "expirationDate"
973
- ,sum(case when oi.status = 'LOADING' or (oi.status = 'SORTING' and oi.type = 'RELEASE_OF_GOODS') then oi.release_qty else 0 end) as "nonLoadedQty"
974
- ,sum(case when oi.status = 'LOADING' or (oi.status = 'SORTING' and oi.type = 'RELEASE_OF_GOODS') then (oi.release_uom_value / oi.release_qty* oi.release_qty) else 0 end) as "nonLoadedUomValue"
949
+ rih.expiration_date as "expirationDate",
950
+ coalesce((
951
+ select sum(oi1.release_qty) as nonLoadedQty from order_inventories oi1
952
+ inner join release_goods rg1 on rg1.id = oi1.release_good_id
953
+ where rg1.status in ('PICKING', 'LOADING')
954
+ and oi1.inventory_id = rih.inventory_id
955
+ and oi1.status in ('PICKED', 'LOADING')
956
+ and rg1.domain_id = '${domain.id}'
957
+ group by oi1.inventory_id
958
+ ),0) as "nonLoadedQty",
959
+ TRUNC(coalesce((
960
+ select sum(oi1.release_uom_value) as nonLoadedUomValue from order_inventories oi1
961
+ inner join release_goods rg1 on rg1.id = oi1.release_good_id
962
+ where rg1.status in ('PICKING', 'LOADING')
963
+ and oi1.inventory_id = rih.inventory_id
964
+ and oi1.status in ('PICKED', 'LOADING')
965
+ and rg1.domain_id = '${domain.id}'
966
+ group by oi1.inventory_id
967
+ ),0)::numeric,2) as "nonLoadedUomValue"
975
968
  from tmp_data rih
976
969
  left join pallets plt on plt.id = rih.reusable_pallet_id
977
970
  inner join products prd on prd.id = rih.product_id
978
971
  inner join bizplaces bz on bz.id = rih.bizplace_id
979
972
  inner join locations loc on loc.id = rih.location_id
980
973
  inner join warehouses wh on wh.id = loc.warehouse_id
981
- left join order_inventories oi on oi.inventory_id = rih.inventory_id
982
- group by rih.inventory_id,rih.domain_id,rih.pallet_id,rih.carton_id,rih.qty,rih.uom_value,rih.uom,rih.last_seq,rih.created_at, rih.initial_inbound_at,rih.unit_cost,rih.reusable_pallet_id,
983
- rih.batch_id,plt.name,rih.batch_id_ref,rih.product_id,rih.packing_type,rih.bizplace_id,rih.location_id,prd.id,bz.id,loc.id,wh.name,rih.remark,rih.expiration_date,rih.manufacture_date,rih.status
984
- having 1=1 and (case when rih.status = 'TERMINATED' and SUM(CASE WHEN oi.status = 'LOADING' or (oi.status = 'SORTING' AND oi.type = 'RELEASE_OF_GOODS') THEN oi.release_qty ELSE 0 END) > 0 then rih.status = 'TERMINATED' else rih.status <> 'TERMINATED' end)
974
+ WHERE 1 = 1
985
975
  ${queryOrder}
986
976
  ${setPagination ? 'OFFSET ' + (pagination.page - 1) * pagination.limit + ' LIMIT ' + pagination.limit : ''}
987
977
  `);
988
- //comment end
989
978
  // map all results
990
979
  let items = result.map(itm => {
991
980
  return Object.assign(Object.assign({}, itm), { bizplace: {
@@ -1009,14 +998,14 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
1009
998
  }
1010
999
  async bizplaceInventoryHistoriesForExport(context, inventoryHistory, filters) {
1011
1000
  const { domain, tx } = context.state;
1012
- const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(inventoryHistory.bizplace.id);
1001
+ const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({ id: inventoryHistory.bizplace.id });
1013
1002
  const productFilters = filters.find(x => x.name == 'product_info');
1014
1003
  filters = filters.filter(x => x.name != 'product_info');
1015
1004
  const fromDate = new Date(inventoryHistory.fromDate);
1016
1005
  const toDate = new Date(inventoryHistory.toDate);
1017
1006
  if (productFilters) {
1018
1007
  let productFilterValue = `%${productFilters.value.toLowerCase()}%`;
1019
- const productQb = (0, typeorm_1.getRepository)(product_base_1.Product).createQueryBuilder('prd');
1008
+ const productQb = (0, shell_1.getRepository)(product_base_1.Product).createQueryBuilder('prd');
1020
1009
  productQb.where(new typeorm_1.Brackets(qb => {
1021
1010
  qb.where('Lower(prd.sku) LIKE :productInfo', { productInfo: productFilterValue })
1022
1011
  .orWhere('Lower(prd.name) LIKE :productInfo', { productInfo: productFilterValue })
@@ -1031,7 +1020,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
1031
1020
  });
1032
1021
  }
1033
1022
  if (inventoryHistory && inventoryHistory.warehouseName) {
1034
- const _warehouses = await tx.getRepository(warehouse_1.Warehouse).find({
1023
+ const _warehouses = await tx.getRepository(warehouse_1.Warehouse).findBy({
1035
1024
  domain: domain,
1036
1025
  name: (0, typeorm_1.Raw)(alias => `LOWER(${alias}) LIKE '${inventoryHistory.warehouseName.toLowerCase()}'`)
1037
1026
  });
@@ -1063,7 +1052,7 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
1063
1052
  operator: 'eq',
1064
1053
  value: customerBizplace.id
1065
1054
  });
1066
- const qb = (0, typeorm_1.getRepository)(inventory_history_1.InventoryHistory).createQueryBuilder('ih');
1055
+ const qb = (0, shell_1.getRepository)(inventory_history_1.InventoryHistory).createQueryBuilder('ih');
1067
1056
  (0, shell_1.buildQuery)(qb, { filters }, context);
1068
1057
  qb.select('prd.sku', 'sku')
1069
1058
  .addSelect('prd.name', 'productName')
@@ -1122,13 +1111,14 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
1122
1111
  }
1123
1112
  if (!bizplaceFilter || !fromDate || !toDate)
1124
1113
  throw 'Invalid input';
1125
- const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
1114
+ const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOneBy({
1126
1115
  id: bizplaceFilter.value
1127
1116
  });
1128
1117
  //check if all product details got volume
1129
1118
  let foundPermittedBizplace;
1130
1119
  if (bizplace) {
1131
- foundPermittedBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(bizplace.id, {
1120
+ foundPermittedBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
1121
+ where: { id: bizplace.id },
1132
1122
  relations: ['company', 'company.domain']
1133
1123
  });
1134
1124
  const companyDomain = foundPermittedBizplace.company.domain;
@@ -1231,13 +1221,13 @@ let InventoryHistoryQuery = class InventoryHistoryQuery {
1231
1221
  }
1232
1222
  }
1233
1223
  async domain(inventoryHistory) {
1234
- return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(inventoryHistory.domainId);
1224
+ return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: inventoryHistory.domainId });
1235
1225
  }
1236
1226
  async updater(inventoryHistory) {
1237
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(inventoryHistory.updaterId);
1227
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: inventoryHistory.updaterId });
1238
1228
  }
1239
1229
  async creator(inventoryHistory) {
1240
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(inventoryHistory.creatorId);
1230
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: inventoryHistory.creatorId });
1241
1231
  }
1242
1232
  };
1243
1233
  tslib_1.__decorate([
@@ -1245,7 +1235,7 @@ tslib_1.__decorate([
1245
1235
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1246
1236
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1247
1237
  tslib_1.__metadata("design:type", Function),
1248
- tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
1238
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1249
1239
  tslib_1.__metadata("design:returntype", Promise)
1250
1240
  ], InventoryHistoryQuery.prototype, "inventoryHistories", null);
1251
1241
  tslib_1.__decorate([
@@ -1265,7 +1255,7 @@ tslib_1.__decorate([
1265
1255
  tslib_1.__param(3, (0, type_graphql_1.Arg)('pagination', type => shell_1.Pagination, { nullable: true })),
1266
1256
  tslib_1.__param(4, (0, type_graphql_1.Arg)('sortings', type => [shell_1.Sorting], { nullable: true })),
1267
1257
  tslib_1.__metadata("design:type", Function),
1268
- tslib_1.__metadata("design:paramtypes", [Object, inventory_history_types_1.InventoryHistoryPatch, Array, typeof (_b = typeof shell_1.Pagination !== "undefined" && shell_1.Pagination) === "function" ? _b : Object, Array]),
1258
+ tslib_1.__metadata("design:paramtypes", [Object, inventory_history_types_1.InventoryHistoryPatch, Array, shell_1.Pagination, Array]),
1269
1259
  tslib_1.__metadata("design:returntype", Promise)
1270
1260
  ], InventoryHistoryQuery.prototype, "bizplaceInventoryHistories", null);
1271
1261
  tslib_1.__decorate([
@@ -1274,7 +1264,7 @@ tslib_1.__decorate([
1274
1264
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1275
1265
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1276
1266
  tslib_1.__metadata("design:type", Function),
1277
- tslib_1.__metadata("design:paramtypes", [typeof (_c = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _c : Object, Object]),
1267
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1278
1268
  tslib_1.__metadata("design:returntype", Promise)
1279
1269
  ], InventoryHistoryQuery.prototype, "inventoryHistoryReport", null);
1280
1270
  tslib_1.__decorate([
@@ -1283,7 +1273,7 @@ tslib_1.__decorate([
1283
1273
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1284
1274
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1285
1275
  tslib_1.__metadata("design:type", Function),
1286
- tslib_1.__metadata("design:paramtypes", [typeof (_d = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _d : Object, Object]),
1276
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1287
1277
  tslib_1.__metadata("design:returntype", Promise)
1288
1278
  ], InventoryHistoryQuery.prototype, "inventoryHistoryPalletReport", null);
1289
1279
  tslib_1.__decorate([
@@ -1292,7 +1282,7 @@ tslib_1.__decorate([
1292
1282
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1293
1283
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1294
1284
  tslib_1.__metadata("design:type", Function),
1295
- tslib_1.__metadata("design:paramtypes", [typeof (_e = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _e : Object, Object]),
1285
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1296
1286
  tslib_1.__metadata("design:returntype", Promise)
1297
1287
  ], InventoryHistoryQuery.prototype, "inventoryHistoryPalletDetailReport", null);
1298
1288
  tslib_1.__decorate([
@@ -1301,7 +1291,7 @@ tslib_1.__decorate([
1301
1291
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1302
1292
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1303
1293
  tslib_1.__metadata("design:type", Function),
1304
- tslib_1.__metadata("design:paramtypes", [typeof (_f = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _f : Object, Object]),
1294
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1305
1295
  tslib_1.__metadata("design:returntype", Promise)
1306
1296
  ], InventoryHistoryQuery.prototype, "inventoryHistoryPalletStorageReport", null);
1307
1297
  tslib_1.__decorate([
@@ -1310,7 +1300,7 @@ tslib_1.__decorate([
1310
1300
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1311
1301
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1312
1302
  tslib_1.__metadata("design:type", Function),
1313
- tslib_1.__metadata("design:paramtypes", [typeof (_g = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _g : Object, Object]),
1303
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1314
1304
  tslib_1.__metadata("design:returntype", Promise)
1315
1305
  ], InventoryHistoryQuery.prototype, "inventoryHistorySummaryReport", null);
1316
1306
  tslib_1.__decorate([
@@ -1323,7 +1313,7 @@ tslib_1.__decorate([
1323
1313
  tslib_1.__param(4, (0, type_graphql_1.Arg)('locationSortingRules', type => [shell_1.Sorting], { nullable: true })),
1324
1314
  tslib_1.__param(5, (0, type_graphql_1.Arg)('setPagination', type => Boolean, { defaultValue: true })),
1325
1315
  tslib_1.__metadata("design:type", Function),
1326
- tslib_1.__metadata("design:paramtypes", [Object, Array, typeof (_h = typeof shell_1.Pagination !== "undefined" && shell_1.Pagination) === "function" ? _h : Object, Array, Array, Boolean]),
1316
+ tslib_1.__metadata("design:paramtypes", [Object, Array, shell_1.Pagination, Array, Array, Boolean]),
1327
1317
  tslib_1.__metadata("design:returntype", Promise)
1328
1318
  ], InventoryHistoryQuery.prototype, "onhandInventories", null);
1329
1319
  tslib_1.__decorate([
@@ -1342,7 +1332,7 @@ tslib_1.__decorate([
1342
1332
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
1343
1333
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
1344
1334
  tslib_1.__metadata("design:type", Function),
1345
- tslib_1.__metadata("design:paramtypes", [typeof (_j = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _j : Object, Object]),
1335
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
1346
1336
  tslib_1.__metadata("design:returntype", Promise)
1347
1337
  ], InventoryHistoryQuery.prototype, "inventoryHistoryVolumeSummaryReport", null);
1348
1338
  tslib_1.__decorate([
@@ -1567,8 +1557,8 @@ async function filterInventoryQuery(tx, params, bizplace, context) {
1567
1557
  from inventories i2
1568
1558
  inner join reduced_inventory_histories ih on ih.pallet_id = i2.pallet_id and ih.domain_id = i2.domain_id
1569
1559
  where
1570
- i2.domain_id = $1
1571
- and i2.bizplace_id = $2
1560
+ ih.domain_id = $1
1561
+ and ih.bizplace_id = $2
1572
1562
  and ih.created_at <= $3
1573
1563
  ${batchNoQuery}
1574
1564
  )