@things-factory/operato-wms 4.3.31 → 4.3.34

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.
@@ -2,92 +2,123 @@ import { EntityManager } from 'typeorm'
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Domain, ListParam } from '@things-factory/shell'
5
+ import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
6
 
6
7
  export const outboundOrderByStatusResolver = {
7
8
  async outboundOrderByStatus(_: any, params: ListParam, context: any) {
8
- const { domain, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
9
+ const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
10
+
11
+ const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || null
12
+ let bizplaceIds: string[]
13
+
14
+ let bizplaces = bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
15
+ bizplaceIds = bizplaces.map(bizplace => {
16
+ return "'" + bizplace.trim() + "'"
17
+ }).join(',')
9
18
 
10
19
  const orderStatus: { status: string; count: number }[] = await tx.query(
11
20
  `
12
- WITH cte_list ("status", "count") as (
13
- select 'DONE' as status, 0 as "count"
14
- union
15
- select 'CANCELLED' as status, 0 as "count"
16
- union
17
- select 'PICKING UNASSIGNED' as status, 0 as "count"
18
- union
19
- select 'PACKING' as status, 0 as "count"
20
- union
21
- select 'AWAITING DISPATCH' as status, 0 as "count"
22
- union
23
- select 'OUT FROM WAREHOUSE' as status, 0 as "count"
24
- union
25
- select 'PICKING ASSIGNED' as status, 0 as "count"
26
- union
27
- select 'OTHERS' as status, 0 as "count"
28
- ) select l."status", coalesce(src."count", l."count") as "count"
29
- from cte_list l
30
- left join (
31
- SELECT "status", COUNT(*) AS "count" FROM (
32
- SELECT
33
- CASE WHEN "status" = 'DONE' and rg.updated_at::date = CURRENT_DATE THEN 'DONE'
34
- WHEN "status" = 'CANCELLED' THEN 'CANCELLED'
35
- WHEN "status" IN('PENDING_RECEIVE', 'PENDING_WORKSHEET') THEN 'PICKING UNASSIGNED'
36
- END AS "status"
37
- FROM release_goods rg
38
- WHERE "domain_id" = $1
39
- AND rg."status" IN ('CANCELLED','PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING', 'READY_TO_PACK', 'PACKING', 'DONE')
40
- ) AS foo
21
+ WITH cte_list ("status", "count") AS (
22
+ SELECT 'PICKING UNASSIGNED' AS status, 0 AS "count"
23
+ UNION
24
+ SELECT 'PICKING ASSIGNED' AS status, 0 AS "count"
25
+ UNION
26
+ SELECT 'BATCH PICKING ASSIGNED' AS status, 0 AS "count"
27
+ UNION
28
+ SELECT 'PACKING' AS status, 0 AS "count"
29
+ UNION
30
+ SELECT 'AWAITING DISPATCH' AS status, 0 AS "count"
31
+ UNION
32
+ SELECT 'OUT FROM WAREHOUSE' AS status, 0 AS "count"
33
+ UNION
34
+ SELECT 'PENDING MANIFEST CREATION' AS status, 0 AS "count"
35
+ UNION
36
+ SELECT 'DONE' AS status, 0 AS "count"
37
+ UNION
38
+ SELECT 'PENDING CANCEL' AS status, 0 AS "count"
39
+ UNION
40
+ SELECT 'CANCELLED' AS status, 0 AS "count"
41
+ UNION
42
+ SELECT 'OTHERS' AS status, 0 AS "count"
43
+ UNION
44
+ SELECT 'DRAFT' AS status, 0 AS "count"
45
+ ) SELECT l."status", coalesce(src."count", l."count") AS "count"
46
+ FROM cte_list l
47
+ LEFT JOIN (
48
+ SELECT "status", SUM("count") AS count FROM (
49
+ SELECT "status", COUNT(*) AS "count" FROM (
50
+ SELECT
51
+ CASE WHEN "status" = 'DONE' AND rg.updated_at::date = CURRENT_DATE THEN 'DONE'
52
+ WHEN "status" = 'PENDING_CANCEL' THEN 'PENDING CANCEL'
53
+ WHEN "status" = 'CANCELLED' AND rg.updated_at::date = CURRENT_DATE THEN 'CANCELLED'
54
+ WHEN "status" IN('PENDING_RECEIVE','PENDING_WORKSHEET') THEN 'PICKING UNASSIGNED'
55
+ END AS "status"
56
+ FROM release_goods rg
57
+ WHERE "domain_id" = $1
58
+ AND rg."bizplace_id" IN (${bizplaceIds})
59
+ AND rg."status" IN ('PENDING','PENDING_RECEIVE','PENDING_WORKSHEET','READY_TO_PICK','PICKING','READY_TO_PACK','PACKING','PENDING_CANCEL','CANCELLED','DONE')
60
+ ) AS foo
61
+ GROUP BY "status"
62
+ UNION ALL
63
+ SELECT "status", COUNT(*) AS "count" FROM (
64
+ SELECT
65
+ CASE WHEN "dispatchment_status" = 'DISPATCHED' AND rg.updated_at::date = CURRENT_DATE THEN 'OUT FROM WAREHOUSE'
66
+ END AS "status"
67
+ FROM release_goods rg
68
+ WHERE "domain_id" = $1
69
+ AND rg."bizplace_id" IN (${bizplaceIds})
70
+ AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
71
+ AND rg."status" NOT IN ('CANCELLED','PENDING_CANCEL')
72
+ AND rg."tracking_no" NOTNULL
73
+ AND rg."type" = 'b2c'
74
+ ) AS foo
75
+ GROUP BY "status"
76
+ UNION ALL
77
+ SELECT 'AWAITING DISPATCH' AS "status", count(*) FROM manifests m
78
+ INNER JOIN release_goods rg ON rg.manifest_id = m.id
79
+ WHERE m."status" = 'OPEN'
80
+ AND m."domain_id" = $1
81
+ UNION ALL
82
+ SELECT 'PICKING ASSIGNED' AS "status", count(*) FROM worksheets w
83
+ WHERE w."domain_id" = $1
84
+ AND w."bizplace_id" IN (${bizplaceIds})
85
+ AND w."type" = 'PICKING'
86
+ AND w."status" IN ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
87
+ GROUP BY w."status"
88
+ UNION ALL
89
+ SELECT 'BATCH PICKING ASSIGNED' AS "status", count(*) FROM worksheets w
90
+ WHERE w."domain_id" = $1
91
+ AND w."bizplace_id" IN (${bizplaceIds})
92
+ AND w."type" = 'BATCH_PICKING'
93
+ AND w."status" IN ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
94
+ GROUP BY w."status"
95
+ UNION ALL
96
+ SELECT 'PACKING' AS "status", count(*) FROM worksheets w
97
+ WHERE w."domain_id" = $1 AND w."type" = 'PACKING'
98
+ AND w."bizplace_id" IN (${bizplaceIds})
99
+ AND w."status" IN ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
100
+ GROUP BY w."status"
101
+ UNION ALL
102
+ SELECT 'PENDING MANIFEST CREATION' AS "status", count(*) FROM release_goods rg
103
+ WHERE rg."domain_id" = $1
104
+ AND rg."bizplace_id" IN (${bizplaceIds})
105
+ AND rg."status" = 'DONE'
106
+ AND rg."manifest_id" ISNULL
107
+ AND rg."type" = 'b2c'
108
+ AND rg."updated_at" >= (CURRENT_DATE - 30)
109
+ UNION ALL
110
+ SELECT 'DRAFT' AS "status", count(*) FROM draft_release_goods drg
111
+ WHERE drg."domain_id" = $1
112
+ AND drg."bizplace_id" IN (${bizplaceIds})
113
+ AND drg."status" = 'DRAFT'
114
+ AND drg."type" = 'b2c'
115
+ ) AS src
41
116
  GROUP BY "status"
42
- UNION ALL
43
- SELECT "status", COUNT(*) AS "count" FROM (
44
- SELECT
45
- CASE WHEN "dispatchment_status" = 'DISPATCHED' THEN 'OUT FROM WAREHOUSE'
46
- END AS "status"
47
- FROM release_goods rg
48
- WHERE "domain_id" = $1
49
- AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
50
- AND rg."status" NOT IN ('CANCELLED', 'PENDING_CANCEL')
51
- AND rg."tracking_no" NOTNULL
52
- ) AS foo
53
- GROUP BY "status"
54
- union all
55
- select 'AWAITING DISPATCH' as "status", count(*) from manifests m
56
- inner join release_goods rg ON rg.manifest_id = m.id
57
- where m."status" = 'OPEN' and m."domain_id" = $1
58
- union all
59
- select 'PICKING ASSIGNED' as "status", count(*) from worksheets w
60
- where w."domain_id" = $1 and w."type" ='PICKING'
61
- and w."status" in ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
62
- group by w."status"
63
- union all
64
- select 'PACKING' as "status", count(*) from worksheets w
65
- where w."domain_id" = $1 and w."type" ='PACKING'
66
- and w."status" in ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
67
- group by w."status"
68
- ) src on src."status" = l."status"
117
+ ) src ON src."status" = l."status"
69
118
  `,
70
119
  [domain.id]
71
120
  )
72
121
 
73
- const statusList: string[] = [
74
- 'PICKING UNASSIGNED',
75
- 'PICKING ASSIGNED',
76
- 'PACKING',
77
- 'AWAITING DISPATCH',
78
- 'OUT FROM WAREHOUSE',
79
- 'CANCELLED',
80
- 'DONE',
81
- 'OUT OF STOCK'
82
- ]
83
-
84
- return statusList.reduce((statusCounts: { status: string; count: number }[], status: string) => {
85
- let foundItem = orderStatus.find(order => order.status == status)
86
-
87
- if (foundItem) statusCounts.push({ status, count: foundItem.count })
88
- else statusCounts.push({ status, count: 0 })
89
-
90
- return statusCounts
91
- }, [])
122
+ return orderStatus
92
123
  }
93
124
  }
@@ -122,18 +122,18 @@
122
122
  "field.addable_uom_value": "addable uom value",
123
123
  "field.address_id": "address id",
124
124
  "field.address": "address",
125
- "field.adjusted": "adjusted",
126
125
  "field.adjusted_batch_id_ref": "adjusted batch no ref",
127
126
  "field.adjusted_batch_id": "adjusted batch no",
128
127
  "field.adjusted_pack_qty": "adjusted pack qty",
129
128
  "field.adjusted_packing_type": "adjusted packing type",
130
129
  "field.adjusted_pallet_qty": "adjusted pallet qty",
130
+ "field.adjusted_qty": "adjusted qty",
131
131
  "field.adjusted_total_uom_value": "adjusted total uom value",
132
132
  "field.adjusted_unit_price": "adjusted unit price",
133
133
  "field.adjusted_uom_value": "adjusted uom value",
134
134
  "field.adjusted_uom": "adjusted uom",
135
135
  "field.adjusted_volume": "adjusted volume",
136
- "field.adjusted_qty": "adjusted qty",
136
+ "field.adjusted": "adjusted",
137
137
  "field.after": "after",
138
138
  "field.amount": "amount",
139
139
  "field.arrival_notice": "arrival notice",
@@ -168,6 +168,7 @@
168
168
  "field.brand_sku": "brand sku",
169
169
  "field.brand": "brand",
170
170
  "field.brn": "brn",
171
+ "field.buffer_location": "buffer location",
171
172
  "field.buffer_qty": "buffer qty",
172
173
  "field.by_pallet": "by pallet",
173
174
  "field.carton_id": "carton ID",
@@ -190,10 +191,10 @@
190
191
  "field.claim_type": "claim type",
191
192
  "field.claim": "claim",
192
193
  "field.claimType": "claim type",
193
- "field.closing": "closing",
194
194
  "field.closing_balance": "closing balance",
195
- "field.closing_volume": "closing volume",
196
195
  "field.closing_qty": "closing qty",
196
+ "field.closing_volume": "closing volume",
197
+ "field.closing": "closing",
197
198
  "field.cogs_account_code": "COGS account code",
198
199
  "field.column": "column",
199
200
  "field.combination": "combination",
@@ -280,9 +281,9 @@
280
281
  "field.id": "id",
281
282
  "field.import_cargo": "import cargo",
282
283
  "field.in": "in",
283
- "field.inbound_volume": "inbound volume",
284
284
  "field.inbound_pallet_id": "inbound pallet id",
285
285
  "field.inbound_qty": "inbound qty",
286
+ "field.inbound_volume": "inbound volume",
286
287
  "field.inbound": "inbound",
287
288
  "field.indicator": "indicator",
288
289
  "field.initial_inbound_date": "initial inbound date",
@@ -324,9 +325,9 @@
324
325
  "field.max_qty": "max qty",
325
326
  "field.mfg_year": "mfg. year",
326
327
  "field.min_qty": "min qty",
327
- "field.missing": "missing",
328
- "field.missing_volume": "missing volume",
329
328
  "field.missing_qty": "missing qty",
329
+ "field.missing_volume": "missing volume",
330
+ "field.missing": "missing",
330
331
  "field.month": "month",
331
332
  "field.movement": "movement",
332
333
  "field.name": "name",
@@ -335,20 +336,20 @@
335
336
  "field.nett_weight": "nett weight",
336
337
  "field.no_of_items": "no of items",
337
338
  "field.no": "no",
338
- "field.non_tally": "non tally",
339
339
  "field.non_loaded_qty": "non loaded qty",
340
340
  "field.non_loaded_uom_value": "non loaded uom value",
341
+ "field.non_tally": "non tally",
341
342
  "field.now_scanning": "now scanning",
342
343
  "field.number_of_column": "number of column",
343
344
  "field.number_of_depth": "number of depth",
344
345
  "field.number_of_row": "number of row",
345
346
  "field.number_of_shelf": "number of shelf",
346
347
  "field.onhand_inventory_quantity": "onhand inventory quantity",
347
- "field.opening": "opening",
348
348
  "field.opening_balance": "opening balance",
349
- "field.opening_volume": "opening volume",
350
349
  "field.opening_qty": "opening qty",
351
350
  "field.opening_uom_value": "opening uom value",
351
+ "field.opening_volume": "opening volume",
352
+ "field.opening": "opening",
352
353
  "field.operation_guide_type": "operation guide type",
353
354
  "field.operation_guide": "operation guide",
354
355
  "field.operationGuide": "operation guide",
@@ -364,8 +365,8 @@
364
365
  "field.ot": "O/T",
365
366
  "field.other_target": "other target",
366
367
  "field.out": "out",
367
- "field.outbound_volume": "outbound volume",
368
368
  "field.outbound_qty": "outbound qty",
369
+ "field.outbound_volume": "outbound volume",
369
370
  "field.outbound": "outbound",
370
371
  "field.over_stock": "over stock",
371
372
  "field.own_collection": "own collection",
@@ -1113,8 +1114,8 @@
1113
1114
  "text.do_you_want_to_print": "do you want to print",
1114
1115
  "text.do_you_want_to_proceed": "do you want to proceed",
1115
1116
  "text.document_has_been_generated": "document has been generated",
1116
- "text.draft_purchase_order": "draft purchase order",
1117
1117
  "text.draft_order_form_invalid": "draft order form invalid",
1118
+ "text.draft_purchase_order": "draft purchase order",
1118
1119
  "text.driver_and_vehicle_is_not_selected": "driver and vehicle is not selected",
1119
1120
  "text.driver_is_empty": "driver name is empty",
1120
1121
  "text.driver_is_not_selected": "driver is not selected",
@@ -1735,7 +1736,6 @@
1735
1736
  "title.transfer_order_requests": "transfer order requests",
1736
1737
  "title.transport_driver": "transport driver",
1737
1738
  "title.transport_vehicle": "transport vehicle",
1738
- "title.update_purchase_order": "update purchase order?",
1739
1739
  "title.undo_putaway": "undo putaway",
1740
1740
  "title.undo_unload": "undo unload",
1741
1741
  "title.unloaded_inventories": "unloaded inventories",
@@ -1747,6 +1747,7 @@
1747
1747
  "title.unpack_procedure": "unpack procedure",
1748
1748
  "title.unpack": "unpack",
1749
1749
  "title.unpacking": "unpacking",
1750
+ "title.update_purchase_order": "update purchase order?",
1750
1751
  "title.upload_document_template": "upload document template",
1751
1752
  "title.upload_document": "upload document",
1752
1753
  "title.upload_gdn": "upload gdn",