@things-factory/operato-wms 4.3.61 → 4.3.64

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 (61) hide show
  1. package/client/pages/components/select-inventory-popup.js +626 -0
  2. package/client/pages/inbound/unload-product.js +10 -9
  3. package/client/pages/inventory/inventory-by-product-detail.js +99 -92
  4. package/client/pages/inventory/inventory-by-product.js +170 -68
  5. package/client/pages/inventory-check/inspecting-product.js +1 -1
  6. package/client/pages/order/release-order/b2b/b2b-order-list.js +76 -80
  7. package/client/pages/order/release-order/b2c/b2c-order-requests.js +93 -81
  8. package/client/pages/order/release-order/batch-picking-popup.js +11 -0
  9. package/client/pages/order/release-order/create-release-order.js +258 -252
  10. package/client/pages/order/release-order/release-extra-product-popup.js +10 -3
  11. package/client/pages/order/release-order/release-order-detail.js +202 -63
  12. package/client/pages/order/transport-order/delivery-note-popup.js +12 -17
  13. package/client/pages/order/transport-order/upload-delivery-note.js +6 -4
  14. package/client/pages/order/transport-order/view-delivery-note.js +0 -1
  15. package/client/pages/outbound/generate-worksheet-popup.js +337 -0
  16. package/client/pages/outbound/inventory-reassign-popup.js +1097 -0
  17. package/client/pages/outbound/loading-product.js +2 -2
  18. package/client/pages/outbound/picking-product.js +174 -100
  19. package/client/pages/outbound/sorting-product.js +5 -5
  20. package/client/pages/outbound/worksheet-batch-picking.js +39 -5
  21. package/client/pages/outbound/worksheet-picking.js +45 -6
  22. package/client/pages/report/outbound-order-details-report.js +181 -49
  23. package/client/pages/report/release-inventory-report.js +503 -0
  24. package/client/route.js +5 -0
  25. package/dist-server/graphql/resolvers/extra/add-release-good-products.js +54 -3
  26. package/dist-server/graphql/resolvers/extra/add-release-good-products.js.map +1 -1
  27. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  28. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  29. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +63 -28
  30. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
  31. package/dist-server/graphql/resolvers/reports/release-inventory-report.js +180 -0
  32. package/dist-server/graphql/resolvers/reports/release-inventory-report.js.map +1 -0
  33. package/dist-server/graphql/types/reports/index.js +6 -1
  34. package/dist-server/graphql/types/reports/index.js.map +1 -1
  35. package/dist-server/graphql/types/reports/outbound-order-details-report.js +14 -1
  36. package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
  37. package/dist-server/graphql/types/reports/release-inventory-report-list.js +14 -0
  38. package/dist-server/graphql/types/reports/release-inventory-report-list.js.map +1 -0
  39. package/dist-server/graphql/types/reports/release-inventory-report.js +29 -0
  40. package/dist-server/graphql/types/reports/release-inventory-report.js.map +1 -0
  41. package/dist-server/utils/report-query-util.js +4 -2
  42. package/dist-server/utils/report-query-util.js.map +1 -1
  43. package/helps/release-note.ko.md +13 -7
  44. package/helps/release-note.md +13 -7
  45. package/helps/release-note.ms.md +13 -7
  46. package/helps/release-note.zh.md +13 -7
  47. package/package.json +9 -9
  48. package/server/graphql/resolvers/extra/add-release-good-products.ts +66 -3
  49. package/server/graphql/resolvers/reports/index.ts +3 -1
  50. package/server/graphql/resolvers/reports/outbound-order-details-report.ts +66 -29
  51. package/server/graphql/resolvers/reports/release-inventory-report.ts +202 -0
  52. package/server/graphql/types/reports/index.ts +6 -1
  53. package/server/graphql/types/reports/outbound-order-details-report.ts +14 -1
  54. package/server/graphql/types/reports/release-inventory-report-list.ts +8 -0
  55. package/server/graphql/types/reports/release-inventory-report.ts +23 -0
  56. package/server/utils/report-query-util.ts +4 -2
  57. package/things-factory.config.js +4 -0
  58. package/translations/en.json +73 -16
  59. package/translations/ko.json +157 -110
  60. package/translations/ms.json +65 -16
  61. package/translations/zh.json +79 -29
@@ -2,26 +2,32 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- ## 4 July Update
5
+ ## 3 August Update
6
6
 
7
- #### V4.6.0 Release Note
7
+ #### V4.7.0 Release Note
8
8
 
9
9
  #### Greetings to all,
10
10
 
11
- #### Make July even better with the new features and enhancements we have in store for you!
11
+ #### Let’s kickstart this August with our release on Outbound!
12
12
 
13
13
  <div>
14
- 1. Shorten Order Processing of Goods Arrival Notices (GAN)
14
+ 1. Quick Product Scanning
15
15
  </div>
16
16
  <div>
17
- 2. Edit Order Details of Goods Arrival Notice (GAN)
17
+ 2. Stock Recall
18
18
  </div>
19
19
  <div>
20
- 3. Enhancement of Loading Manifest
20
+ 3. Accumulative Locked Inventory
21
+ </div>
22
+ <div>
23
+ 4. Batch Picking Simplification
24
+ </div>
25
+ <div>
26
+ And More enhancements!
21
27
  </div>
22
28
  <br>
23
29
  For additional information about the aspects of the release, see the following link
24
- <a href="https://bit.ly/3IexqWA">V4.6.0 Release Note</a>
30
+ <a href="https://bit.ly/20220802_Hatio_Release">V4.7.0 Release Note</a>
25
31
  <br>
26
32
 
27
33
  Should you have any inquiries, feel free to contact support@hatio.asia! Stay safe and positively negative!
@@ -2,26 +2,32 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- ## 4 July Update
5
+ ## 3 August Update
6
6
 
7
- #### V4.6.0 Release Note
7
+ #### V4.7.0 Release Note
8
8
 
9
9
  #### Greetings to all,
10
10
 
11
- #### Make July even better with the new features and enhancements we have in store for you!
11
+ #### Let’s kickstart this August with our release on Outbound!
12
12
 
13
13
  <div>
14
- 1. Shorten Order Processing of Goods Arrival Notices (GAN)
14
+ 1. Quick Product Scanning
15
15
  </div>
16
16
  <div>
17
- 2. Edit Order Details of Goods Arrival Notice (GAN)
17
+ 2. Stock Recall
18
18
  </div>
19
19
  <div>
20
- 3. Enhancement of Loading Manifest
20
+ 3. Accumulative Locked Inventory
21
+ </div>
22
+ <div>
23
+ 4. Batch Picking Simplification
24
+ </div>
25
+ <div>
26
+ And More enhancements!
21
27
  </div>
22
28
  <br>
23
29
  For additional information about the aspects of the release, see the following link
24
- <a href="https://bit.ly/3IexqWA">V4.6.0 Release Note</a>
30
+ <a href="https://bit.ly/20220802_Hatio_Release">V4.7.0 Release Note</a>
25
31
  <br>
26
32
 
27
33
  Should you have any inquiries, feel free to contact support@hatio.asia! Stay safe and positively negative!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.61",
3
+ "version": "4.3.64",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -81,18 +81,18 @@
81
81
  "@things-factory/grist-ui": "^4.3.47",
82
82
  "@things-factory/help": "^4.3.47",
83
83
  "@things-factory/i18n-base": "^4.3.47",
84
- "@things-factory/id-rule-base": "^4.3.47",
84
+ "@things-factory/id-rule-base": "^4.3.62",
85
85
  "@things-factory/import-ui": "^4.3.47",
86
86
  "@things-factory/import-ui-excel": "^4.3.47",
87
- "@things-factory/menu-ui": "^4.3.47",
87
+ "@things-factory/menu-ui": "^4.3.62",
88
88
  "@things-factory/more-ui": "^4.3.47",
89
- "@things-factory/notification": "^4.3.47",
89
+ "@things-factory/notification": "^4.3.62",
90
90
  "@things-factory/pdf": "^4.3.47",
91
91
  "@things-factory/print-proxy-service": "^4.3.47",
92
92
  "@things-factory/print-ui": "^4.3.52",
93
93
  "@things-factory/product-base": "^4.3.60",
94
94
  "@things-factory/resource-ui": "^4.3.52",
95
- "@things-factory/sales-ui": "^4.3.61",
95
+ "@things-factory/sales-ui": "^4.3.64",
96
96
  "@things-factory/scene-data-transform": "^4.3.47",
97
97
  "@things-factory/scene-excel": "^4.3.47",
98
98
  "@things-factory/scene-firebase": "^4.3.47",
@@ -104,12 +104,12 @@
104
104
  "@things-factory/scene-mqtt": "^4.3.47",
105
105
  "@things-factory/scene-restful": "^4.3.47",
106
106
  "@things-factory/scene-visualizer": "^4.3.47",
107
- "@things-factory/setting-ui": "^4.3.47",
107
+ "@things-factory/setting-ui": "^4.3.62",
108
108
  "@things-factory/system-ui": "^4.3.47",
109
109
  "@things-factory/transport-base": "^4.3.47",
110
110
  "@things-factory/tutorial-ui": "^4.3.47",
111
- "@things-factory/warehouse-base": "^4.3.61",
112
- "@things-factory/worksheet-base": "^4.3.61"
111
+ "@things-factory/warehouse-base": "^4.3.64",
112
+ "@things-factory/worksheet-base": "^4.3.64"
113
113
  },
114
114
  "devDependencies": {
115
115
  "@things-factory/builder": "^4.3.47",
@@ -118,5 +118,5 @@
118
118
  "cypress-localstorage-commands": "^1.6.1",
119
119
  "eslint-plugin-cypress": "^2.12.1"
120
120
  },
121
- "gitHead": "42f79d1b7f03a52a1c9b043b897fca7a7e386049"
121
+ "gitHead": "ed452efe14f7ac969c4d795eb141ff704626c827"
122
122
  }
@@ -1,4 +1,4 @@
1
- import { EntityManager } from 'typeorm'
1
+ import { EntityManager, In, Not } from 'typeorm'
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Bizplace } from '@things-factory/biz-base'
@@ -28,7 +28,7 @@ export const addReleaseGoodProducts = {
28
28
 
29
29
  let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
30
30
  where: { domain, name: name },
31
- relations: ['bizplace']
31
+ relations: ['bizplace', 'orderProducts']
32
32
  })
33
33
 
34
34
  const bizplace: Bizplace = releaseGood.bizplace
@@ -210,11 +210,23 @@ export const addReleaseGoodProducts = {
210
210
 
211
211
  let existingOrderInv: OrderInventory
212
212
 
213
+ let existingOrderProduct: OrderProduct = await tx.getRepository(OrderProduct).findOne({
214
+ where: {
215
+ domain,
216
+ releaseGood,
217
+ batchId: oi.batchId,
218
+ packingType: oi.packingType,
219
+ product: newOrderInv.product
220
+ }
221
+ })
222
+
213
223
  // check if it is release by inventory (has inventory value) or product
214
224
  if (newOrderInv.inventory?.id) {
215
225
  // if release by inventory, then quantity and uomValue values are updated
216
226
  const foundInv: Inventory = await tx.getRepository(Inventory).findOne(newOrderInv.inventory.id)
217
227
  newOrderInv.inventory = foundInv
228
+ newOrderInv.uom = oi?.uom || foundInv.uom
229
+ newOrderInv.batchIdRef = oi?.batchIdRef || foundInv.batchIdRef
218
230
 
219
231
  // check for existing released OrderInventory specifying product, batchId, packingType, and inventory
220
232
  existingOrderInv = await tx.getRepository(OrderInventory).findOne({
@@ -241,7 +253,9 @@ export const addReleaseGoodProducts = {
241
253
  status: ORDER_PRODUCT_STATUS.ASSIGNED
242
254
  }
243
255
 
244
- newOrderProduct = await tx.getRepository(OrderProduct).save(newOrderProduct)
256
+ if (!existingOrderProduct) newOrderProduct = await tx.getRepository(OrderProduct).save(newOrderProduct)
257
+
258
+ newOrderInv.orderProduct = existingOrderProduct ? existingOrderProduct : newOrderProduct
245
259
 
246
260
  await tx.getRepository(Inventory).save(foundInv)
247
261
  } else {
@@ -286,6 +300,7 @@ export const addReleaseGoodProducts = {
286
300
  if (existingWorksheetDetail) {
287
301
  existingWorksheetDetail = {
288
302
  ...existingWorksheetDetail,
303
+ targetProduct: newOrderInv.orderProduct,
289
304
  status: WORKSHEET_STATUS.DEACTIVATED
290
305
  }
291
306
 
@@ -306,11 +321,14 @@ export const addReleaseGoodProducts = {
306
321
  savedOrderInv.releaseQty = newOrderInv.releaseQty
307
322
  savedOrderInv.releaseUomValue = newOrderInv.releaseUomValue
308
323
  savedOrderInv.batchId = newOrderInv.batchId
324
+ savedOrderInv.batchIdRef = newOrderInv.batchIdRef
309
325
  savedOrderInv.packingType = newOrderInv.packingType
326
+ savedOrderInv.uom = newOrderInv.uom
310
327
  savedOrderInv.product = newOrderInv.product
311
328
  savedOrderInv.inventory = newOrderInv.inventory
312
329
  savedOrderInv.status = newOrderInv.status
313
330
  savedOrderInv.releaseGood = newOrderInv.releaseGood
331
+ savedOrderInv.orderProduct = newOrderInv.orderProduct
314
332
  savedOrderInv.bizplace = newOrderInv.bizplace
315
333
  savedOrderInv.domain = domain
316
334
  savedOrderInv.creator = user
@@ -345,6 +363,51 @@ export const addReleaseGoodProducts = {
345
363
 
346
364
  await tx.getRepository(Worksheet).save(loadingWorksheet)
347
365
  }
366
+
367
+ // Update Order Product Release Qty
368
+ let rgOrderProducts: OrderProduct[] = await tx
369
+ .getRepository(OrderProduct)
370
+ .find({ where: { domain, releaseGood } })
371
+
372
+ await Promise.all(
373
+ rgOrderProducts.map(async op => {
374
+ const orderInventories: OrderInventory[] = await tx.getRepository(OrderInventory).find({
375
+ where: {
376
+ domain,
377
+ releaseGood,
378
+ orderProduct: op,
379
+ status: Not(
380
+ In([
381
+ ORDER_INVENTORY_STATUS.TERMINATED,
382
+ ORDER_INVENTORY_STATUS.CANCELLED,
383
+ ORDER_INVENTORY_STATUS.PENDING_CANCEL
384
+ ])
385
+ )
386
+ }
387
+ })
388
+
389
+ let totalReleaseQty: number = orderInventories.reduce((total, currentValue) => {
390
+ total += currentValue.releaseQty
391
+ return total
392
+ }, 0)
393
+
394
+ let totalReleaseUomValue: number = orderInventories.reduce((total, currentValue) => {
395
+ total += currentValue.releaseUomValue
396
+ return total
397
+ }, 0)
398
+
399
+ let updateOPInfo: any = {
400
+ releaseQty: totalReleaseQty,
401
+ releaseUomValue: totalReleaseUomValue
402
+ }
403
+
404
+ if (totalReleaseQty <= 0) {
405
+ updateOPInfo.status = ORDER_PRODUCT_STATUS.TERMINATED
406
+ }
407
+
408
+ await tx.getRepository(OrderProduct).update({ id: op.id }, updateOPInfo)
409
+ })
410
+ )
348
411
  } catch (error) {
349
412
  throw error
350
413
  }
@@ -5,6 +5,7 @@ import { costingReport } from './costing-report'
5
5
  import { inboundOrderDetailsReport } from './inbound-order-details-report'
6
6
  import { outboundOrderDetailsReport } from './outbound-order-details-report'
7
7
  import { productLabelReport } from './product-label-report'
8
+ import { releaseInventoryReport } from './release-inventory-report'
8
9
 
9
10
  export const Query = {
10
11
  ...inboundSerialNumberReport,
@@ -12,5 +13,6 @@ export const Query = {
12
13
  ...costingReport,
13
14
  ...inboundOrderDetailsReport,
14
15
  ...outboundOrderDetailsReport,
15
- ...productLabelReport
16
+ ...productLabelReport,
17
+ ...releaseInventoryReport
16
18
  }
@@ -54,30 +54,37 @@ export const outboundOrderDetailsReport = {
54
54
  `
55
55
  create temp table temp_outbound_order_report on commit drop as (
56
56
  select * from (
57
- select oi.id, '${bizplace.id}' AS "bizplace_id", '${bizplace.name}' AS "bizplace_name", '${bizplace.description
58
- }' AS "bizplace_description",
59
- do2.name AS "delivery_order_no", do2.delivery_date as "delivery_order_date",
60
- do2."to", do2.contact_point_ref_id, do2.pallet_qty, so.container_no, rg.export_option,
61
- rg.name AS "ro_no", rg."type" as "ro_type", rg.ref_no AS "ref_no_1", rg.ref_no_2 AS "ref_no_2", rg.ref_no_3 AS "ref_no_3", rg.status as "ro_status",
62
- rg.created_at AS "order_created_at", rg.accepted_at, u4.name as accepted_by, rg.checked_remark_by, rg.checked_remark_at,
57
+ select oi.id,
58
+ oi.release_qty AS "release_qty", oi.picked_at, oi.picked_by, oi.packed_at, oi.packed_by, oi.loaded_at, oi.loaded_by,
59
+ oi.release_qty as "qty", oi.release_uom_value as "uom_value", oi.return_to_location_qty, oi.return_to_location_uom_value,
60
+ coalesce(do2.other_driver, td.name) as driver_name,
61
+ coalesce(do2.truck_no, tv.name, rg.truck_no) as vehicle_no,
62
+ do2.name AS "delivery_order_no", do2.delivery_date AS "delivery_order_delivery_date", do2."to", do2.contact_point_ref_id, do2.pallet_qty,
63
+ coalesce(do2.delivery_date_time, do2.delivery_date::timestamp, ms.dispatched_at, null) as "dispatched_at",
64
+ rg.bizplace_id, $5 AS "bizplace_name", $6 AS "bizplace_description",
65
+ coalesce( concat(do2.delivery_address_1, do2.delivery_address_2, do2.delivery_address_3, do2.delivery_address_4, do2.delivery_address_5, do2.postal_code, do2.country), concat(rg.delivery_address_1, rg.delivery_address_2, rg.delivery_address_3, rg.delivery_address_4, rg.delivery_address_5, rg.postal_code, rg.country)) as delivery_address,
66
+ so.container_no, so.container_size,
67
+ rg.export_option, rg.name AS "ro_no", rg."type" as "ro_type", rg.ref_no AS "ref_no_1", rg.ref_no_2 AS "ref_no_2", rg.ref_no_3 AS "ref_no_3", rg.status as "ro_status",
68
+ rg.created_at AS "order_created_at", rg.accepted_at, u4.name as accepted_by, rg.checked_remark_by, rg.checked_remark_at, coalesce(do2.own_collection, rg.own_transport) AS own_transport,
63
69
  p.id as "product_id", p.sku as "product_sku", p.name AS "product_name", p.description AS "product_description", p.type as "product_type",
64
- i.packing_type as "pack_type", i.packing_size as "pack_size", oi.release_qty AS "release_qty",
65
- oi.picked_at, oi.picked_by, oi.packed_at, oi.packed_by, oi.loaded_at, oi.loaded_by, oi.shipped_at,
66
- oi.release_qty as "qty", oi.release_uom_value as "uom_value", i.uom, i.unit_cost,
67
- oi.return_to_location_qty, oi.return_to_location_uom_value,
68
- i.id as inventory_id, i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date
69
- from order_inventories oi
70
- inner join release_goods rg on rg.id = oi.release_good_id
70
+ i.packing_type as "pack_type", i.packing_size as "pack_size",
71
+ i.uom, i.unit_cost,
72
+ i.id as inventory_id, i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date,
73
+ coalesce(ms.name,'') as manifest_no, coalesce(rg.manifested_at, ms.created_at) as manifested_at, coalesce(u6.name, u5.name) as manifested_by
74
+ from release_goods rg
75
+ inner join order_inventories oi on rg.id = oi.release_good_id
71
76
  left join shipping_orders so on so.id = rg.shipping_order_id
72
77
  left join users u4 on u4.id = rg.accepted_by_id
78
+ left join manifests ms on ms.id = rg.manifest_id
79
+ left join users u5 on u5.id = ms.creator_id
80
+ left join users u6 on u6.id = rg.manifested_by_id
73
81
  inner join inventories i on i.id = oi.inventory_id
74
82
  inner join temp_products p on p.id = oi.product_id
75
83
  left join delivery_orders do2 on do2.id = oi.delivery_order_id
76
- where exists (
77
- select rg2.id from release_goods rg2
78
- where rg2.domain_id = $1 and rg2.bizplace_id = $2
79
- and rg2.created_at >= $3 and rg2.created_at <= $4 and rg2.id = oi.release_good_id
80
- )
84
+ left join transport_drivers td ON td.id = do2.transport_driver_id
85
+ left join transport_vehicles tv on tv.id = do2.transport_vehicle_id
86
+ where rg.bizplace_id = $2 and rg.domain_id = $1
87
+ and rg.created_at >= $3 and rg.created_at <= $4
81
88
  and oi.status <> 'REPLACED'
82
89
  ${status ? `and rg.status = '${status.value}' ` : ``}
83
90
  ) src
@@ -85,7 +92,7 @@ export const outboundOrderDetailsReport = {
85
92
  ${extraQueryFilters}
86
93
  )
87
94
  `,
88
- [context.state.domain.id, bizplace.id, fromDate.value, toDate.value]
95
+ [context.state.domain.id, bizplace.id, fromDate.value, toDate.value, bizplace.name, bizplace.description]
89
96
  )
90
97
 
91
98
  console.timeEnd('temp')
@@ -93,6 +100,16 @@ export const outboundOrderDetailsReport = {
93
100
  select count(*) from temp_outbound_order_report
94
101
  `)
95
102
 
103
+ await tx.query(
104
+ `
105
+ create temp table temp_outbound_order_worksheet on commit drop as (
106
+ select oi.id, w.started_at, w.ended_at, w.type from temp_outbound_order_report oi
107
+ inner join worksheet_details wd on wd.target_inventory_id = oi.id
108
+ inner join worksheets w on w.id = wd.worksheet_id
109
+ )
110
+ `
111
+ )
112
+
96
113
  console.time('result')
97
114
  const result: any = await tx.query(
98
115
  `
@@ -101,10 +118,12 @@ export const outboundOrderDetailsReport = {
101
118
  round((qty * unit_nett_weight)::numeric ,4) as total_unit_nett_weight,
102
119
  round((qty * unit_gross_weight)::numeric ,4) as total_unit_gross_weight
103
120
  from (
104
- select *,
105
- w.started_at as picking_start,
106
- w.ended_at as picking_complete,
107
- coalesce(oi."to", concat(cp.address, cp.address_2)) as "delivery_address",
121
+ select oi.*,
122
+ wpick.started_at as picking_start, wpick.ended_at as picking_complete,
123
+ wpack.started_at as packing_start, wpack.ended_at as packing_complete,
124
+ wsort.started_at as sorting_start, wsort.ended_at as sorting_complete,
125
+ wload.started_at as loading_start, wload.ended_at as loading_complete,
126
+ coalesce(delivery_address, concat(cp.address, cp.address_2)) as "delivery_address",
108
127
  coalesce((select volume from product_details pd where pd.product_id = oi.product_id and pd.packing_type = oi.pack_type and pd.packing_size = oi.pack_size
109
128
  order by created_at desc
110
129
  fetch first 1 rows only),0) as unit_volume,
@@ -124,10 +143,15 @@ export const outboundOrderDetailsReport = {
124
143
  order by created_at desc
125
144
  fetch first 1 rows only), oi.unit_cost, 0) as unit_cost
126
145
  from temp_outbound_order_report oi
127
- left join worksheet_details wd on wd.target_inventory_id = oi.id
128
- left join worksheets w on w.id = wd.worksheet_id
129
146
  left join contact_points cp on cp.id = oi.contact_point_ref_id
130
- where (w.type= 'PICKING' OR w.type = 'BATCH_PICKING')
147
+ left join temp_outbound_order_worksheet wpick on wpick.id = oi.id
148
+ and (wpick.type= 'PICKING' OR wpick.type = 'BATCH_PICKING')
149
+ left join temp_outbound_order_worksheet wpack on wpack.id = oi.id
150
+ and wpack.type= 'PACKING'
151
+ left join temp_outbound_order_worksheet wsort on wsort.id = oi.id
152
+ and wsort.type= 'SORTING'
153
+ left join temp_outbound_order_worksheet wload on wload.id = oi.id
154
+ and wload.type= 'LOADING'
131
155
  order by oi.ro_no, oi.product_sku
132
156
  offset $1 limit $2
133
157
  ) src
@@ -145,8 +169,10 @@ export const outboundOrderDetailsReport = {
145
169
  description: itm.bizplace_description
146
170
  },
147
171
  doNo: itm.delivery_order_no,
148
- doDeliveryDate: itm.delivery_order_date,
172
+ doDeliveryDate: itm.delivery_order_delivery_date,
173
+ dispatchedAt: itm.dispatched_at,
149
174
  deliveryAddress: itm.delivery_address,
175
+ manifestNo: itm.manifest_no,
150
176
  roNo: itm.ro_no,
151
177
  roType: itm.ro_type,
152
178
  status: itm.ro_status,
@@ -158,6 +184,12 @@ export const outboundOrderDetailsReport = {
158
184
  orderCreatedAt: itm.order_created_at,
159
185
  pickingStart: itm.picking_start,
160
186
  pickingComplete: itm.picking_complete,
187
+ packingStart: itm.packing_start,
188
+ packingComplete: itm.packing_complete,
189
+ sortingStart: itm.sorting_start,
190
+ sortingComplete: itm.sorting_complete,
191
+ loadingStart: itm.loading_start,
192
+ loadingComplete: itm.loading_complete,
161
193
  product: {
162
194
  id: itm.product_id,
163
195
  sku: itm.product_sku,
@@ -194,10 +226,15 @@ export const outboundOrderDetailsReport = {
194
226
  checkedRemarkAt: itm.checked_remark_at,
195
227
  loadedAt: itm.loaded_at,
196
228
  loadedBy: itm.loaded_by,
197
- shippedAt: itm.shipped_at,
229
+ manifestedAt: itm.manifested_at,
230
+ manifestedBy: itm.manifested_by,
198
231
  exportOption: itm.export_option,
199
232
  containerNo: itm.container_no,
200
- palletQty: itm.pallet_qty
233
+ containerSize: itm.container_size,
234
+ palletQty: itm.pallet_qty,
235
+ transportOption: itm.own_transport ? 'Own Transport' : 'Warehouse Transport',
236
+ vehicleNo: itm.vehicle_no,
237
+ driverName: itm.driver_name
201
238
  }
202
239
  })
203
240
 
@@ -0,0 +1,202 @@
1
+ import { EntityManager } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
4
+ import { Bizplace } from '@things-factory/biz-base'
5
+ import { ListParam } from '@things-factory/shell'
6
+
7
+ import { rawProductsQuery } from '../../../utils'
8
+
9
+ export const releaseInventoryReport = {
10
+ async releaseInventoryReport(_: any, params: ListParam, context: any) {
11
+ try {
12
+ const { tx }: { tx: EntityManager } = context.state
13
+ // let bizplaceFilter = { name: '', operator: '', value: '' }
14
+ // let userFilter = params.filters.find(data => data.name === 'user')
15
+ let order = params.filters.find(data => data.name === 'order')
16
+ let orderDate = params.filters.find(data => data.name === 'orderDate')
17
+ let product = params.filters.find(data => data.name === 'product')
18
+ let bizplace = params.filters.find(data => data.name === 'bizplace')
19
+ let palletId = params.filters.find(data => data.name === 'palletId')
20
+ let cartonId = params.filters.find(data => data.name === 'cartonId')
21
+
22
+ // if (userFilter) {
23
+ // const user: User = await tx.getRepository(User).findOne({
24
+ // where: { id: userFilter.value },
25
+ // relations: ['bizplaces']
26
+ // })
27
+
28
+ // const bizplace: Bizplace = user.bizplaces[0]
29
+
30
+ if (!bizplace) throw 'Invalid input'
31
+
32
+ // bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
33
+ // } else {
34
+ // bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
35
+ // }
36
+
37
+ // if (!bizplaceFilter) throw 'Invalid input'
38
+ let roFilter = '', ccFilter = '', queryFilter = ''
39
+ if (order) {
40
+ let orderValue = order.value
41
+ .toLowerCase()
42
+ .split(',')
43
+ .map(prod => {
44
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'"
45
+ })
46
+ .join(',')
47
+ roFilter += `AND (
48
+ Lower(od.name) LIKE ANY(ARRAY[${orderValue}])
49
+ OR Lower(od.ref_no) LIKE ANY(ARRAY[${orderValue}])
50
+ OR Lower(od.ref_no_2) LIKE ANY(ARRAY[${orderValue}])
51
+ OR Lower(od.ref_no_3) LIKE ANY(ARRAY[${orderValue}])
52
+ )`
53
+ ccFilter += `AND (
54
+ Lower(od.name) LIKE ANY(ARRAY[${orderValue}])
55
+ )`
56
+ }
57
+ if (orderDate) {
58
+ queryFilter += ` AND od.created_at between '${orderDate.value}'::timestamp and '${orderDate.value}'::timestamp + INTERVAL '1 day'`
59
+ }
60
+
61
+ if (palletId) {
62
+ queryFilter += ` AND lower(i.pallet_id) like '%${palletId.value.toLowerCase()}%'`
63
+ }
64
+
65
+ if (cartonId) {
66
+ queryFilter += ` AND lower(i.carton_id) like '%${cartonId.value.toLowerCase()}%'`
67
+ }
68
+
69
+ if (bizplace) {
70
+ queryFilter += ` AND od.bizplace_id = '${bizplace.value}'`
71
+ }
72
+
73
+ const bizplaceObj: Bizplace = await tx.getRepository(Bizplace).findOne({
74
+ id: bizplace.value
75
+ })
76
+ await rawProductsQuery(tx, params, bizplaceObj)
77
+
78
+ // let productQuery = ''
79
+ // if (product) {
80
+ // let productValue = product.value
81
+ // .toLowerCase()
82
+ // .split(',')
83
+ // .map(prod => {
84
+ // return "'%" + prod.trim().replace(/'/g, "''") + "%'"
85
+ // })
86
+ // .join(',')
87
+ // queryFilter = `AND (
88
+ // Lower(p.name) LIKE ANY(ARRAY[${productValue}])
89
+ // OR Lower(p.sku) LIKE ANY(ARRAY[${productValue}])
90
+ // OR Lower(p.description) LIKE ANY(ARRAY[${productValue}])
91
+ // OR Lower(p.brand_sku) LIKE ANY(ARRAY[${productValue}])
92
+ // OR Lower(p.brand) LIKE ANY(ARRAY[${productValue}])
93
+ // )`
94
+ // }
95
+
96
+ await tx.query(
97
+ `
98
+ create temp table data_src on commit drop as (
99
+ select * from (
100
+ select p.sku as product_sku, p.name as product_name, p.description as product_description, p.brand as product_brand,
101
+ b.id as bizplace_id, b.name as bizplace_name, b.description as bizplace_description, i.packing_type,
102
+ oi.release_qty as assigned_qty, oi.release_uom_value as uom_value, i.uom,
103
+ od.name as order_no, od.type::varchar as "type", od.status, od.created_at as order_at, od.release_date,
104
+ i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date, l.name as location_name
105
+ from (
106
+ select inventory_id, release_good_id, sum(release_qty) as release_qty, sum(release_uom_value) as release_uom_value from order_inventories oi
107
+ inner join release_goods od on od.id = oi.release_good_id
108
+ where release_good_id is not null
109
+ and od.status in ('PENDING', 'PENDING_RECEIVE', 'PENDING_CANCEL', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING')
110
+ and od.domain_id = $1
111
+ and oi.status != 'REPLACED'
112
+ group by inventory_id, release_good_id
113
+ ) oi
114
+ inner join release_goods od on od.id = oi.release_good_id
115
+ inner join bizplaces b on b.id = od.bizplace_id
116
+ inner join inventories i on i.id = oi.inventory_id
117
+ inner join locations l on l.id = i.location_id
118
+ inner join temp_products p on p.id = i.product_id
119
+ where 1 = 1
120
+ ${roFilter}
121
+ ${queryFilter}
122
+ union all
123
+ select p.sku as product_sku, p.name as product_name, p.description as product_description, p.brand as product_brand,
124
+ b.id as bizplace_id, b.name as bizplace_name, b.description as bizplace_description, i.packing_type,
125
+ oi.release_qty as assigned_qty, oi.release_uom_value as uom_value, i.uom,
126
+ od.name as order_no, 'cc' as "type", od.status, od.created_at as order_at, od.execution_date,
127
+ i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date, l.name as location_name
128
+ from order_inventories oi
129
+ inner join bizplaces b on b.id = oi.bizplace_id
130
+ inner join inventory_checks od on od.id = oi.inventory_check_id
131
+ inner join inventories i on i.id = oi.inventory_id
132
+ inner join locations l on l.id = i.location_id
133
+ inner join temp_products p on p.id = i.product_id
134
+ where od.status <> 'DONE'
135
+ and od.domain_id = $1
136
+ ${ccFilter}
137
+ ${queryFilter}
138
+ ) src
139
+ order by product_sku, packing_type, order_no
140
+ );
141
+ `,
142
+ [context.state.domain.id]
143
+ )
144
+
145
+ const total: any = await tx.query(`
146
+ select count(*) from data_src
147
+ `)
148
+
149
+ const result: any = await tx.query(
150
+ `
151
+ select * from data_src
152
+ offset $1 limit $2
153
+ `,
154
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
155
+ )
156
+
157
+ let items = result.map(itm => {
158
+ let data = {
159
+ bizplace: {
160
+ id: itm.bizplace_id,
161
+ name: itm.bizplace_name,
162
+ description: itm.bizplace_description
163
+ },
164
+ product: {
165
+ id: itm.product_id,
166
+ sku: itm.product_sku,
167
+ name: itm.product_name,
168
+ description: itm.product_description,
169
+ brand: itm.product_brand,
170
+ },
171
+ location: {
172
+ name: itm.location_name,
173
+ },
174
+ packingType: itm.packing_type,
175
+ assignedQty: itm.assigned_qty,
176
+ assignedUomValue: itm.uom_value,
177
+ assignedUom: itm.uom,
178
+ orderNo: itm.order_no,
179
+ type: itm.type,
180
+ status: itm.status,
181
+ orderAt: itm.order_at,
182
+ releaseDate: itm.release_date,
183
+ palletId: itm.pallet_id,
184
+ cartonId: itm.carton_id,
185
+ batchId: itm.batch_id,
186
+ batchIdRef: itm.batch_id_ref,
187
+ expirationDate: itm.expiration_date,
188
+ manufactureDate: itm.manufacture_date
189
+ }
190
+
191
+ return data
192
+ })
193
+
194
+ return {
195
+ items,
196
+ total: total[0].count
197
+ }
198
+ } catch (error) {
199
+ throw error
200
+ }
201
+ }
202
+ }
@@ -12,6 +12,8 @@ import { ProductLabelReportList } from './product-label-report-list'
12
12
 
13
13
  import { CostingReport } from './costing-report'
14
14
  import { CostingReportList } from './costing-report-list'
15
+ import { ReleaseInventoryReport } from './release-inventory-report'
16
+ import { ReleaseInventoryReportList } from './release-inventory-report-list'
15
17
 
16
18
  export const Query = `
17
19
  inboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundSerialNumberReportList @transaction
@@ -20,6 +22,7 @@ export const Query = `
20
22
  outboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundOrderDetailsReportList @transaction
21
23
  productLabelReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ProductLabelReportList @transaction
22
24
  costingReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): CostingReportList @transaction
25
+ releaseInventoryReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ReleaseInventoryReportList @transaction
23
26
  `
24
27
 
25
28
  export const Types = [
@@ -34,5 +37,7 @@ export const Types = [
34
37
  ProductLabelReport,
35
38
  ProductLabelReportList,
36
39
  CostingReport,
37
- CostingReportList
40
+ CostingReportList,
41
+ ReleaseInventoryReport,
42
+ ReleaseInventoryReportList
38
43
  ]