@things-factory/operato-wms 5.0.0-alpha.2 → 5.0.0-alpha.22

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 (52) hide show
  1. package/client/pages/inbound/serial-number-list-popup.js +342 -0
  2. package/client/pages/inbound/unload-product.js +220 -41
  3. package/client/pages/inbound/unloaded-inventories-popup.js +7 -0
  4. package/client/pages/inventory/non-loaded-inventory.js +297 -0
  5. package/client/pages/order/release-order/b2b/b2b-order-list.js +41 -18
  6. package/client/pages/order/release-order/b2c/b2c-order-requests.js +40 -18
  7. package/client/pages/outbound/packing-product.js +88 -80
  8. package/client/pages/outbound/picking-product.js +61 -36
  9. package/client/pages/outbound/serial-number-popup.js +150 -64
  10. package/client/pages/report/inbound-serial-number-report.js +452 -0
  11. package/client/pages/report/outbound-order-details-report.js +64 -9
  12. package/client/pages/report/outbound-serial-number-report.js +467 -0
  13. package/client/route.js +11 -0
  14. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js +111 -0
  15. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js.map +1 -0
  16. package/dist-server/graphql/resolvers/reports/index.js +3 -1
  17. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  18. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +53 -48
  19. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
  20. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js +118 -0
  21. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js.map +1 -0
  22. package/dist-server/graphql/types/reports/inbound-serial-number-report-list.js +14 -0
  23. package/dist-server/graphql/types/reports/inbound-serial-number-report-list.js.map +1 -0
  24. package/dist-server/graphql/types/reports/inbound-serial-number-report.js +23 -0
  25. package/dist-server/graphql/types/reports/inbound-serial-number-report.js.map +1 -0
  26. package/dist-server/graphql/types/reports/index.js +10 -0
  27. package/dist-server/graphql/types/reports/index.js.map +1 -1
  28. package/dist-server/graphql/types/reports/outbound-order-details-report.js +3 -0
  29. package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
  30. package/dist-server/graphql/types/reports/outbound-serial-number-report-list.js +14 -0
  31. package/dist-server/graphql/types/reports/outbound-serial-number-report-list.js.map +1 -0
  32. package/dist-server/graphql/types/reports/outbound-serial-number-report.js +25 -0
  33. package/dist-server/graphql/types/reports/outbound-serial-number-report.js.map +1 -0
  34. package/dist-server/migrations/1568858861188-SeedSetting.js +2 -1
  35. package/dist-server/migrations/1568858861188-SeedSetting.js.map +1 -1
  36. package/package.json +67 -66
  37. package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +128 -0
  38. package/server/graphql/resolvers/reports/index.ts +5 -0
  39. package/server/graphql/resolvers/reports/outbound-order-details-report.ts +54 -48
  40. package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +135 -0
  41. package/server/graphql/types/reports/inbound-serial-number-report-list.ts +8 -0
  42. package/server/graphql/types/reports/inbound-serial-number-report.ts +17 -0
  43. package/server/graphql/types/reports/index.ts +11 -0
  44. package/server/graphql/types/reports/outbound-order-details-report.ts +3 -0
  45. package/server/graphql/types/reports/outbound-serial-number-report-list.ts +8 -0
  46. package/server/graphql/types/reports/outbound-serial-number-report.ts +19 -0
  47. package/server/migrations/1568858861188-SeedSetting.ts +5 -2
  48. package/things-factory.config.js +12 -0
  49. package/translations/en.json +26 -6
  50. package/translations/ko.json +21 -2
  51. package/translations/ms.json +21 -2
  52. package/translations/zh.json +25 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "5.0.0-alpha.2",
3
+ "version": "5.0.0-alpha.22",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -41,72 +41,73 @@
41
41
  "docker:run": "docker run --platform linux/amd64 -p 4000:3000 hatiolab/operato-wms:latest"
42
42
  },
43
43
  "dependencies": {
44
- "@operato/ghost-print": "^0.4.3",
45
- "@operato/scene-chartjs": "^0.1.5",
46
- "@operato/scene-clock": "^0.1.5",
47
- "@operato/scene-clone": "^0.1.5",
48
- "@operato/scene-compass": "^0.1.5",
49
- "@operato/scene-gauge": "^0.1.5",
50
- "@operato/scene-half-roundrect": "^0.1.5",
51
- "@operato/scene-indoor-map": "^0.1.5",
52
- "@operato/scene-legend": "^0.1.5",
53
- "@operato/scene-news-ticker": "^0.1.5",
54
- "@operato/scene-progressbar": "^0.1.5",
55
- "@operato/scene-random": "^0.1.5",
56
- "@operato/scene-switch": "^0.1.5",
57
- "@operato/scene-tab": "^0.1.5",
58
- "@operato/scene-table": "^0.1.5",
59
- "@operato/scene-wheel-sorter": "^0.1.5",
60
- "@things-factory/apptool-ui": "^5.0.0-alpha.2",
61
- "@things-factory/attachment-ui": "^5.0.0-alpha.2",
62
- "@things-factory/auth-ui": "^5.0.0-alpha.2",
63
- "@things-factory/barcode-ui": "^5.0.0-alpha.2",
64
- "@things-factory/biz-ui": "^5.0.0-alpha.2",
65
- "@things-factory/board-service": "^5.0.0-alpha.2",
66
- "@things-factory/board-ui": "^5.0.0-alpha.2",
67
- "@things-factory/code-ui": "^5.0.0-alpha.2",
68
- "@things-factory/context-ui": "^5.0.0-alpha.2",
69
- "@things-factory/export-ui": "^5.0.0-alpha.2",
70
- "@things-factory/export-ui-csv": "^5.0.0-alpha.2",
71
- "@things-factory/export-ui-excel": "^5.0.0-alpha.2",
72
- "@things-factory/fav-base": "^5.0.0-alpha.2",
73
- "@things-factory/form-ui": "^5.0.0-alpha.2",
74
- "@things-factory/grist-ui": "^5.0.0-alpha.2",
75
- "@things-factory/help": "^5.0.0-alpha.2",
76
- "@things-factory/i18n-base": "^5.0.0-alpha.2",
77
- "@things-factory/id-rule-base": "^5.0.0-alpha.2",
78
- "@things-factory/import-ui": "^5.0.0-alpha.2",
79
- "@things-factory/import-ui-excel": "^5.0.0-alpha.2",
80
- "@things-factory/menu-ui": "^5.0.0-alpha.2",
81
- "@things-factory/more-ui": "^5.0.0-alpha.2",
82
- "@things-factory/notification": "^5.0.0-alpha.2",
83
- "@things-factory/pdf": "^5.0.0-alpha.2",
84
- "@things-factory/print-proxy-service": "^5.0.0-alpha.2",
85
- "@things-factory/print-service": "^5.0.0-alpha.2",
86
- "@things-factory/print-ui": "^5.0.0-alpha.2",
87
- "@things-factory/product-base": "^5.0.0-alpha.2",
88
- "@things-factory/resource-ui": "^5.0.0-alpha.2",
89
- "@things-factory/sales-ui": "^5.0.0-alpha.2",
90
- "@things-factory/scene-data-transform": "^5.0.0-alpha.2",
91
- "@things-factory/scene-excel": "^5.0.0-alpha.2",
92
- "@things-factory/scene-firebase": "^5.0.0-alpha.2",
93
- "@things-factory/scene-form": "^5.0.0-alpha.2",
94
- "@things-factory/scene-google-map": "^5.0.0-alpha.2",
95
- "@things-factory/scene-graphql": "^5.0.0-alpha.2",
96
- "@things-factory/scene-label": "^5.0.0-alpha.2",
97
- "@things-factory/scene-marker": "^5.0.0-alpha.2",
98
- "@things-factory/scene-mqtt": "^5.0.0-alpha.2",
99
- "@things-factory/scene-restful": "^5.0.0-alpha.2",
100
- "@things-factory/scene-visualizer": "^5.0.0-alpha.2",
101
- "@things-factory/setting-ui": "^5.0.0-alpha.2",
102
- "@things-factory/system-ui": "^5.0.0-alpha.2",
103
- "@things-factory/transport-base": "^5.0.0-alpha.2",
104
- "@things-factory/tutorial-ui": "^5.0.0-alpha.2",
105
- "@things-factory/warehouse-base": "^5.0.0-alpha.2",
106
- "@things-factory/worksheet-base": "^5.0.0-alpha.2"
44
+ "@operato/ghost-print": "1.0.0-alpha.45",
45
+ "@operato/scene-chartjs": "^1.0.0-alpha.4",
46
+ "@operato/scene-clock": "^1.0.0-alpha.4",
47
+ "@operato/scene-clone": "^1.0.0-alpha.4",
48
+ "@operato/scene-compass": "^1.0.0-alpha.4",
49
+ "@operato/scene-gauge": "^1.0.0-alpha.4",
50
+ "@operato/scene-half-roundrect": "^1.0.0-alpha.4",
51
+ "@operato/scene-indoor-map": "^1.0.0-alpha.4",
52
+ "@operato/scene-legend": "^1.0.0-alpha.4",
53
+ "@operato/scene-news-ticker": "^1.0.0-alpha.4",
54
+ "@operato/scene-progressbar": "^1.0.0-alpha.4",
55
+ "@operato/scene-random": "^1.0.0-alpha.4",
56
+ "@operato/scene-switch": "^1.0.0-alpha.4",
57
+ "@operato/scene-tab": "^1.0.0-alpha.4",
58
+ "@operato/scene-table": "^1.0.0-alpha.4",
59
+ "@operato/scene-wheel-sorter": "^1.0.0-alpha.4",
60
+ "@things-factory/apptool-ui": "^5.0.0-alpha.22",
61
+ "@things-factory/attachment-ui": "^5.0.0-alpha.22",
62
+ "@things-factory/auth-ui": "^5.0.0-alpha.22",
63
+ "@things-factory/barcode-ui": "^5.0.0-alpha.22",
64
+ "@things-factory/biz-ui": "^5.0.0-alpha.22",
65
+ "@things-factory/board-service": "^5.0.0-alpha.22",
66
+ "@things-factory/board-ui": "^5.0.0-alpha.22",
67
+ "@things-factory/code-ui": "^5.0.0-alpha.22",
68
+ "@things-factory/context-ui": "^5.0.0-alpha.22",
69
+ "@things-factory/env": "^5.0.0-alpha.22",
70
+ "@things-factory/export-ui": "^5.0.0-alpha.22",
71
+ "@things-factory/export-ui-csv": "^5.0.0-alpha.22",
72
+ "@things-factory/export-ui-excel": "^5.0.0-alpha.22",
73
+ "@things-factory/fav-base": "^5.0.0-alpha.22",
74
+ "@things-factory/form-ui": "^5.0.0-alpha.22",
75
+ "@things-factory/grist-ui": "^5.0.0-alpha.22",
76
+ "@things-factory/help": "^5.0.0-alpha.22",
77
+ "@things-factory/i18n-base": "^5.0.0-alpha.22",
78
+ "@things-factory/id-rule-base": "^5.0.0-alpha.22",
79
+ "@things-factory/import-ui": "^5.0.0-alpha.22",
80
+ "@things-factory/import-ui-excel": "^5.0.0-alpha.22",
81
+ "@things-factory/menu-ui": "^5.0.0-alpha.22",
82
+ "@things-factory/more-ui": "^5.0.0-alpha.22",
83
+ "@things-factory/notification": "^5.0.0-alpha.22",
84
+ "@things-factory/pdf": "^5.0.0-alpha.22",
85
+ "@things-factory/print-proxy-service": "^5.0.0-alpha.22",
86
+ "@things-factory/print-service": "^5.0.0-alpha.22",
87
+ "@things-factory/print-ui": "^5.0.0-alpha.22",
88
+ "@things-factory/product-base": "^5.0.0-alpha.22",
89
+ "@things-factory/resource-ui": "^5.0.0-alpha.22",
90
+ "@things-factory/sales-ui": "^5.0.0-alpha.22",
91
+ "@things-factory/scene-data-transform": "^5.0.0-alpha.22",
92
+ "@things-factory/scene-excel": "^5.0.0-alpha.22",
93
+ "@things-factory/scene-firebase": "^5.0.0-alpha.22",
94
+ "@things-factory/scene-form": "^5.0.0-alpha.22",
95
+ "@things-factory/scene-google-map": "^5.0.0-alpha.22",
96
+ "@things-factory/scene-graphql": "^5.0.0-alpha.22",
97
+ "@things-factory/scene-label": "^5.0.0-alpha.22",
98
+ "@things-factory/scene-marker": "^5.0.0-alpha.22",
99
+ "@things-factory/scene-mqtt": "^5.0.0-alpha.22",
100
+ "@things-factory/scene-restful": "^5.0.0-alpha.22",
101
+ "@things-factory/scene-visualizer": "^5.0.0-alpha.22",
102
+ "@things-factory/setting-ui": "^5.0.0-alpha.22",
103
+ "@things-factory/system-ui": "^5.0.0-alpha.22",
104
+ "@things-factory/transport-base": "^5.0.0-alpha.22",
105
+ "@things-factory/tutorial-ui": "^5.0.0-alpha.22",
106
+ "@things-factory/warehouse-base": "^5.0.0-alpha.22",
107
+ "@things-factory/worksheet-base": "^5.0.0-alpha.22"
107
108
  },
108
109
  "devDependencies": {
109
- "@things-factory/builder": "^5.0.0-alpha.2"
110
+ "@things-factory/builder": "^5.0.0-alpha.22"
110
111
  },
111
- "gitHead": "055536f981d229d51ae63f46585036b35fa86602"
112
+ "gitHead": "8e06de9c59237f1800b2ff4f1c53162a0228342a"
112
113
  }
@@ -0,0 +1,128 @@
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 inboundSerialNumberReport = {
10
+ async inboundSerialNumberReport(_: 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 fromDate = params.filters.find(data => data.name === 'fromDate')
16
+ let toDate = params.filters.find(data => data.name === 'toDate')
17
+ let ganNo = params.filters.find(data => data.name === 'ganNo')
18
+
19
+ if (userFilter) {
20
+ const user: User = await tx.getRepository(User).findOne({
21
+ where: { id: userFilter.value },
22
+ relations: ['bizplaces']
23
+ })
24
+
25
+ const bizplace: Bizplace = user.bizplaces[0]
26
+
27
+ if (!bizplace) throw 'Invalid input'
28
+
29
+ bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
30
+ } else {
31
+ bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
32
+ }
33
+
34
+ if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
35
+
36
+ const bizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
37
+ id: bizplaceFilter.value
38
+ })
39
+
40
+ await rawProductsQuery(tx, params, bizplace)
41
+
42
+ let extraQueryFilters = ''
43
+ if (ganNo) {
44
+ extraQueryFilters = `${extraQueryFilters} and order_no like '%${ganNo.value}%' `
45
+ }
46
+
47
+ await tx.query(
48
+ `
49
+ create temp table temp_inbound_serial_number_report on commit drop as (
50
+ select * from (
51
+ select
52
+ row_number() over(partition by an."name" order by coalesce(w.started_at, ii.created_at), p.sku ) as "no",
53
+ case when "source" = 'ADJUSTMENT' then 'adjustment' else an."name" end as "order_no",
54
+ i.pallet_id, i.carton_id,an.ref_no, an.ref_no_2, an.ref_no_3,
55
+ p.id as "product_id", p.sku as "product_sku", p.brand_sku as "product_brand_sku",
56
+ p.name as "product_name", p.description as "product_description", p."type" as "product_type",
57
+ coalesce(pd.volume, '0') as "product_volume",
58
+ ii.serial_number,
59
+ coalesce(w.started_at,ii.created_at) as "etd"
60
+ from inventory_items ii
61
+ inner join inventories i on i.id = ii.inventory_id
62
+ inner join products p on p.id = i.product_id
63
+ left join product_details pd on pd.product_id = p.id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
64
+ left join arrival_notices an on an.id = ii.inbound_order_id::uuid
65
+ left join worksheets w on w.arrival_notice_id = an.id and w.type = 'UNLOADING'
66
+ where
67
+ i.domain_id = $1 and i.bizplace_id = $2
68
+ and coalesce(w.started_at, ii.created_at) between $3 and $4
69
+ order by coalesce(w.started_at, ii.created_at), p.sku
70
+ ) src
71
+ where 1=1
72
+ ${extraQueryFilters}
73
+ )
74
+ `,
75
+ [context.state.domain.id, bizplace.id, fromDate.value, toDate.value]
76
+ )
77
+
78
+ const total: any = await tx.query(`
79
+ select count(*) from temp_inbound_serial_number_report
80
+ `)
81
+
82
+ const result: any = await tx.query(
83
+ `
84
+ select *
85
+ from temp_inbound_serial_number_report
86
+ offset $1 limit $2
87
+ `,
88
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
89
+ )
90
+
91
+ let items = result.map(itm => {
92
+ let data = {
93
+ no: itm.no,
94
+ bizplace: {
95
+ description: bizplace.description,
96
+ name: bizplace.name
97
+ },
98
+ palletId: itm.pallet_id,
99
+ cartonId: itm.carton_id,
100
+ orderNo: itm.order_no,
101
+ refNo1: itm.ref_no,
102
+ refNo2: itm.ref_no_2,
103
+ refNo3: itm.ref_no_3,
104
+ product: {
105
+ id: itm.product_id,
106
+ sku: itm.product_sku,
107
+ brandSku: itm.product_brand_sku,
108
+ name: itm.product_name,
109
+ description: itm.product_description,
110
+ type: itm.product_type,
111
+ volume: itm.product_volume
112
+ },
113
+ serialNumber: itm.serial_number,
114
+ etd: itm.etd
115
+ }
116
+
117
+ return data
118
+ })
119
+
120
+ return {
121
+ items,
122
+ total: total[0].count
123
+ }
124
+ } catch (error) {
125
+ throw error
126
+ }
127
+ }
128
+ }
@@ -1,8 +1,13 @@
1
+ import { inboundSerialNumberReport } from './inbound-serial-number-report'
2
+ import { outboundSerialNumberReport } from './outbound-serial-number-report'
3
+
1
4
  import { inboundOrderDetailsReport } from './inbound-order-details-report'
2
5
  import { outboundOrderDetailsReport } from './outbound-order-details-report'
3
6
  import { productLabelReport } from './product-label-report'
4
7
 
5
8
  export const Query = {
9
+ ...inboundSerialNumberReport,
10
+ ...outboundSerialNumberReport,
6
11
  ...inboundOrderDetailsReport,
7
12
  ...outboundOrderDetailsReport,
8
13
  ...productLabelReport
@@ -16,6 +16,7 @@ export const outboundOrderDetailsReport = {
16
16
  let toDate = params.filters.find(data => data.name === 'toDate')
17
17
  let roNo = params.filters.find(data => data.name === 'roNo')
18
18
  let doNo = params.filters.find(data => data.name === 'doNo')
19
+ let status = params.filters.find(data => data.name === 'status')
19
20
 
20
21
  if (userFilter) {
21
22
  const user: User = await tx.getRepository(User).findOne({
@@ -48,60 +49,35 @@ export const outboundOrderDetailsReport = {
48
49
  extraQueryFilters = `${extraQueryFilters} and delivery_order_no like '%${doNo.value}%' `
49
50
  }
50
51
 
52
+ console.time('temp')
51
53
  await tx.query(
52
54
  `
53
55
  create temp table temp_outbound_order_report on commit drop as (
54
56
  select * from (
55
- select b2.id AS "bizplace_id", b2.name AS "bizplace_name", b2.description AS "bizplace_description",
56
- do2.name AS "delivery_order_no", do2.delivery_date as "delivery_order_date", coalesce(do2."to", concat(cp.address, cp.address_2)) as "delivery_address",
57
- 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",
57
+ select oi.id, '${bizplace.id}' AS "bizplace_id", '${bizplace.name}' AS "bizplace_name", '${bizplace.description}' AS "bizplace_description",
58
+ do2.name AS "delivery_order_no", do2.delivery_date as "delivery_order_date",
59
+ do2."to", do2.contact_point_ref_id,
60
+ 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",
58
61
  rg.created_at AS "order_created_at", rg.accepted_at, u4.name as accepted_by,
59
62
  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",
60
- oi.packing_type as "pack_type", oi.packing_size as "pack_size", oi.release_qty AS "release_qty",
61
- w.started_at as "picking_start", w.ended_at as "picking_complete",
62
- ih.qty as "qty", ih.uom_value as "uom_value", ih.uom, ih.pallet_id, ih.carton_id, ih.batch_id, ih.batch_id_ref,
63
- i.expiration_date, i.manufacture_date,
64
- ih.created_at as "picked_at", u.name as "picked_by",
65
- ih2.created_at as "packed_at", u2.name as "packed_by",
66
- ih3.created_at as "loaded_at", u3.name as "loaded_by",
67
- ih4.created_at as "shipped_at",
68
- coalesce((select volume from product_details pd where pd.product_id = i.product_id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
69
- order by created_at desc
70
- fetch first 1 rows only),0) as unit_volume,
71
- coalesce((select nett_weight from product_details pd where pd.product_id = i.product_id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
72
- order by created_at desc
73
- fetch first 1 rows only),0) as unit_nett_weight,
74
- coalesce((select gross_weight from product_details pd where pd.product_id = i.product_id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
75
- order by created_at desc
76
- fetch first 1 rows only),0) as unit_gross_weight,
77
- coalesce((select weight_unit from product_details pd where pd.product_id = i.product_id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
78
- order by created_at desc
79
- fetch first 1 rows only),'') as weight_unit
80
- from (
81
- select * from release_goods
82
- where domain_id = $1 and bizplace_id = $2 and status ='DONE'
83
- and created_at >= $3 and created_at <= $4
84
- ) rg
63
+ i.packing_type as "pack_type", i.packing_size as "pack_size", oi.release_qty AS "release_qty",
64
+ oi.picked_at, oi.picked_by, oi.packed_at, oi.packed_by, oi.loaded_at, oi.loaded_by, oi.shipped_at,
65
+ oi.release_qty as "qty", oi.release_uom_value as "uom_value", i.uom,
66
+ oi.return_to_location_qty, oi.return_to_location_uom_value,
67
+ i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date
68
+ from order_inventories oi
69
+ inner join release_goods rg on rg.id = oi.release_good_id
85
70
  left join users u4 on u4.id = rg.accepted_by_id
86
- inner join bizplaces b2 ON b2.id = rg.bizplace_id
87
- inner join order_inventories oi on oi.release_good_id = rg.id
88
71
  inner join inventories i on i.id = oi.inventory_id
89
72
  inner join temp_products p on p.id = oi.product_id
90
- left join worksheets w on w.release_good_id = rg.id and w."type" ='PICKING'
91
- left join reduced_inventory_histories ih on ih.inventory_id = oi.inventory_id and ih.transaction_type ='PICKING' and ih.ref_order_id = rg.id::varchar
92
- left join users u on u.id = ih.creator_id
93
- left join reduced_inventory_histories ih2 on ih2.inventory_id = oi.inventory_id and ih2.transaction_type ='PACKING' and ih2.ref_order_id = rg.id::varchar
94
- left join users u2 on u2.id = ih2.creator_id
95
- left join reduced_inventory_histories ih3 on ih3.inventory_id = oi.inventory_id and ih3.transaction_type ='LOADING' and ih3.ref_order_id = rg.id::varchar
96
- left join users u3 on u3.id = ih3.creator_id
97
- left join reduced_inventory_histories ih4 on ih4.inventory_id = oi.inventory_id and ih4.transaction_type ='SHIPPING' and ih4.ref_order_id = rg.id::varchar
98
- left join worksheets w2 on w2.release_good_id = rg.id and w2."type" ='PACKING'
99
- left join worksheets w3 on w3.release_good_id = rg.id and w2."type" ='LOADING'
100
73
  left join delivery_orders do2 on do2.id = oi.delivery_order_id
101
- left join contact_points cp on cp.id = do2.contact_point_ref_id
102
- left join marketplace_orders mo on mo.release_order_id::uuid = rg.id
103
- where oi.status <> 'REPLACED'
104
- order by rg.name, p.sku
74
+ where exists (
75
+ select rg2.id from release_goods rg2
76
+ where rg2.domain_id = $1 and rg2.bizplace_id = $2
77
+ and rg2.created_at >= $3 and rg2.created_at <= $4 and rg2.id = oi.release_good_id
78
+ )
79
+ and oi.status <> 'REPLACED'
80
+ ${status ? `and rg.status = '${status.value}' ` : ``}
105
81
  ) src
106
82
  where 1=1
107
83
  ${extraQueryFilters}
@@ -110,22 +86,49 @@ export const outboundOrderDetailsReport = {
110
86
  [context.state.domain.id, bizplace.id, fromDate.value, toDate.value]
111
87
  )
112
88
 
89
+ console.timeEnd('temp')
113
90
  const total: any = await tx.query(`
114
91
  select count(*) from temp_outbound_order_report
115
92
  `)
116
93
 
94
+ console.time('result')
117
95
  const result: any = await tx.query(
118
96
  `
119
97
  select *,
120
98
  round((qty * unit_volume)::numeric ,4) as total_volume,
121
99
  round((qty * unit_nett_weight)::numeric ,4) as total_unit_nett_weight,
122
- round((qty * unit_gross_weight)::numeric ,4) as total_unit_gross_weight
123
- from temp_outbound_order_report
124
- offset $1 limit $2
100
+ round((qty * unit_gross_weight)::numeric ,4) as total_unit_gross_weight
101
+ from (
102
+ select *,
103
+ w.started_at as picking_start,
104
+ w.ended_at as picking_complete,
105
+ coalesce(oi."to", concat(cp.address, cp.address_2)) as "delivery_address",
106
+ 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
107
+ order by created_at desc
108
+ fetch first 1 rows only),0) as unit_volume,
109
+ coalesce((select nett_weight 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
110
+ order by created_at desc
111
+ fetch first 1 rows only),0) as unit_nett_weight,
112
+ coalesce((select gross_weight 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
113
+ order by created_at desc
114
+ fetch first 1 rows only),0) as unit_gross_weight,
115
+ coalesce((select weight_unit 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
116
+ order by created_at desc
117
+ fetch first 1 rows only),'') as weight_unit
118
+ from temp_outbound_order_report oi
119
+ left join worksheet_details wd on wd.target_inventory_id = oi.id
120
+ left join worksheets w on w.id = wd.worksheet_id
121
+ left join contact_points cp on cp.id = oi.contact_point_ref_id
122
+ where (w.type= 'PICKING' OR w.type = 'BATCH_PICKING')
123
+ order by oi.ro_no, oi.product_sku
124
+ offset $1 limit $2
125
+ ) src
125
126
  `,
126
127
  [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
127
128
  )
128
129
 
130
+ console.timeEnd('result')
131
+
129
132
  let items = result.map(itm => {
130
133
  return {
131
134
  bizplace: {
@@ -138,9 +141,10 @@ export const outboundOrderDetailsReport = {
138
141
  deliveryAddress: itm.delivery_address,
139
142
  roNo: itm.ro_no,
140
143
  roType: itm.ro_type,
144
+ status: itm.ro_status,
141
145
  refNo1: itm.ref_no_1,
142
- refNo2: itm.ref_no_2,
143
146
  refNo3: itm.ref_no_3,
147
+ refNo2: itm.ref_no_2,
144
148
  acceptedBy: itm.accepted_by,
145
149
  acceptedAt: itm.accepted_at,
146
150
  orderCreatedAt: itm.order_created_at,
@@ -158,6 +162,8 @@ export const outboundOrderDetailsReport = {
158
162
  qty: Math.abs(itm.qty),
159
163
  uomValue: Math.abs(itm.uom_value),
160
164
  uom: itm.uom,
165
+ returnToLocationQty: itm.return_to_location_qty,
166
+ returnToLocationUomValue: itm.return_to_location_uom_value,
161
167
  unitVolume: itm.unit_volume,
162
168
  totalVolume: itm.total_volume,
163
169
  unitNettWeight: itm.unit_nett_weight,
@@ -0,0 +1,135 @@
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 outboundSerialNumberReport = {
10
+ async outboundSerialNumberReport(_: 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 fromDate = params.filters.find(data => data.name === 'fromDate')
16
+ let toDate = params.filters.find(data => data.name === 'toDate')
17
+ let ganNo = params.filters.find(data => data.name === 'ganNo')
18
+
19
+ if (userFilter) {
20
+ const user: User = await tx.getRepository(User).findOne({
21
+ where: { id: userFilter.value },
22
+ relations: ['bizplaces']
23
+ })
24
+
25
+ const bizplace: Bizplace = user.bizplaces[0]
26
+
27
+ if (!bizplace) throw 'Invalid input'
28
+
29
+ bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
30
+ } else {
31
+ bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
32
+ }
33
+
34
+ if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
35
+
36
+ const bizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
37
+ id: bizplaceFilter.value
38
+ })
39
+
40
+ await rawProductsQuery(tx, params, bizplace)
41
+
42
+ let extraQueryFilters = ''
43
+ if (ganNo) {
44
+ extraQueryFilters = `${extraQueryFilters} and order_no like '%${ganNo.value}%' `
45
+ }
46
+
47
+ await tx.query(
48
+ `
49
+ create temp table temp_outbound_serial_number_report on commit drop as (
50
+ select * from (
51
+ select
52
+ row_number() over(partition by rg."name" order by coalesce(w.started_at, ii.created_at), p.sku ) as "no",
53
+ rg."name" as "order_no", concat_ws(', ',rg.delivery_address_1,rg.delivery_address_2,rg.delivery_address_3,rg.delivery_address_4,rg.delivery_address_5,rg.postal_code,rg.city,rg.state) as "full_delivery_address",
54
+ rg."attention_to" as "attention_to",
55
+ i.pallet_id, i.carton_id, rg.ref_no, rg.ref_no_2, rg.ref_no_3,
56
+ p.id as "product_id", p.sku as "product_sku", p.brand_sku as "product_brand_sku",
57
+ p.name as "product_name", p.description as "product_description", p."type" as "product_type",
58
+ coalesce(pd.volume, '0') as "product_volume",
59
+ ii.serial_number,
60
+ coalesce(w.started_at,ii.created_at) as "etd"
61
+ from inventory_items ii
62
+ inner join inventories i on i.id = ii.inventory_id
63
+ inner join products p on p.id = i.product_id
64
+ left join product_details pd on pd.product_id = p.id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
65
+ inner join release_goods rg on rg.id = ii.outbound_order_id::uuid
66
+ left join contact_points cp on cp.id = rg.deliver_to_id
67
+ left join order_inventories oi on oi.release_good_id = rg.id and oi.inventory_id = i.id
68
+ left join delivery_orders do2 on do2.id = oi.delivery_order_id
69
+ left join contact_points cp2 on cp2.id = do2.contact_point_ref_id
70
+ left join worksheets w on w.arrival_notice_id = rg.id and w.type = 'PICKING'
71
+ where
72
+ i.domain_id = $1 and i.bizplace_id = $2
73
+ and coalesce(w.started_at, ii.created_at) between $3 and $4
74
+ order by coalesce(w.started_at, ii.created_at), p.sku
75
+ ) src
76
+ where 1=1
77
+ ${extraQueryFilters}
78
+ )
79
+ `,
80
+ [context.state.domain.id, bizplace.id, fromDate.value, toDate.value]
81
+ )
82
+
83
+ const total: any = await tx.query(`
84
+ select count(*) from temp_outbound_serial_number_report
85
+ `)
86
+
87
+ const result: any = await tx.query(
88
+ `
89
+ select *
90
+ from temp_outbound_serial_number_report
91
+ offset $1 limit $2
92
+ `,
93
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
94
+ )
95
+
96
+ let items = result.map(itm => {
97
+ let data = {
98
+ no: itm.no,
99
+ bizplace: {
100
+ description: bizplace.description,
101
+ name: bizplace.name
102
+ },
103
+ fullDeliveryAddress: itm.full_delivery_address,
104
+ attentionTo:itm.attention_to,
105
+ palletId: itm.pallet_id,
106
+ cartonId: itm.carton_id,
107
+ orderNo: itm.order_no,
108
+ refNo1: itm.ref_no,
109
+ refNo2: itm.ref_no_2,
110
+ refNo3: itm.ref_no_3,
111
+ product: {
112
+ id: itm.product_id,
113
+ sku: itm.product_sku,
114
+ brandSku: itm.product_brand_sku,
115
+ name: itm.product_name,
116
+ description: itm.product_description,
117
+ type: itm.product_type,
118
+ volume: itm.product_volume
119
+ },
120
+ serialNumber: itm.serial_number,
121
+ etd: itm.etd
122
+ }
123
+
124
+ return data
125
+ })
126
+
127
+ return {
128
+ items,
129
+ total: total[0].count
130
+ }
131
+ } catch (error) {
132
+ throw error
133
+ }
134
+ }
135
+ }
@@ -0,0 +1,8 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const InboundSerialNumberReportList = gql`
4
+ type InboundSerialNumberReportList {
5
+ items: [InboundSerialNumberReport]
6
+ total: Int
7
+ }
8
+ `
@@ -0,0 +1,17 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const InboundSerialNumberReport = gql`
4
+ type InboundSerialNumberReport {
5
+ no: Int
6
+ bizplace: Bizplace
7
+ palletId: String
8
+ cartonId: String
9
+ orderNo: String
10
+ refNo1: String
11
+ refNo2: String
12
+ refNo3: String
13
+ product: Product
14
+ serialNumber: String
15
+ etd: String
16
+ }
17
+ `
@@ -1,3 +1,8 @@
1
+ import { InboundSerialNumberReport } from './inbound-serial-number-report'
2
+ import { InboundSerialNumberReportList } from './inbound-serial-number-report-list'
3
+ import { OutboundSerialNumberReport } from './outbound-serial-number-report'
4
+ import { OutboundSerialNumberReportList } from './outbound-serial-number-report-list'
5
+
1
6
  import { InboundOrderDetailsReport } from './inbound-order-details-report'
2
7
  import { InboundOrderDetailsReportList } from './inbound-order-details-report-list'
3
8
  import { OutboundOrderDetailsReport } from './outbound-order-details-report'
@@ -6,12 +11,18 @@ import { ProductLabelReport } from './product-label-report'
6
11
  import { ProductLabelReportList } from './product-label-report-list'
7
12
 
8
13
  export const Query = `
14
+ inboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundSerialNumberReportList @transaction
15
+ outboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundSerialNumberReportList @transaction
9
16
  inboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundOrderDetailsReportList @transaction
10
17
  outboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundOrderDetailsReportList @transaction
11
18
  productLabelReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ProductLabelReportList @transaction
12
19
  `
13
20
 
14
21
  export const Types = [
22
+ InboundSerialNumberReport,
23
+ InboundSerialNumberReportList,
24
+ OutboundSerialNumberReport,
25
+ OutboundSerialNumberReportList,
15
26
  InboundOrderDetailsReport,
16
27
  InboundOrderDetailsReportList,
17
28
  OutboundOrderDetailsReport,