@things-factory/operato-wms 4.3.592 → 4.3.593
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.
- package/client/pages/inventory-check/cycle-count-inventory-details-popup.js +12 -12
- package/client/pages/inventory-check/cycle-count-report.js +181 -91
- package/client/pages/inventory-check/inspecting-product.js +56 -12
- package/dist-server/graphql/resolvers/reports/cycle-count-report.js +119 -86
- package/dist-server/graphql/resolvers/reports/cycle-count-report.js.map +1 -1
- package/dist-server/graphql/types/reports/cycle-count-report.js +2 -0
- package/dist-server/graphql/types/reports/cycle-count-report.js.map +1 -1
- package/dist-server/graphql/types/reports/index.js +1 -1
- package/dist-server/graphql/types/reports/index.js.map +1 -1
- package/helps/release-note.md +20 -12
- package/package.json +5 -5
- package/server/graphql/resolvers/reports/cycle-count-report.ts +125 -87
- package/server/graphql/types/reports/cycle-count-report.ts +2 -0
- package/server/graphql/types/reports/index.ts +3 -9
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
2
|
import { User } from '@things-factory/auth-base'
|
|
4
3
|
import { InventoryCheck } from '@things-factory/sales-base'
|
|
5
4
|
import { ListParam, Domain } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
export const cycleCountReport = {
|
|
8
|
-
async cycleCountReport(_: any, { name }: { name: string }, context: any) {
|
|
7
|
+
async cycleCountReport(_: any, { filters, name }: { filters: any[]; name: string }, context: any) {
|
|
9
8
|
try {
|
|
10
9
|
const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
|
|
11
10
|
|
|
11
|
+
const batchNoVarianceFilter = filters?.find(e => e.name === 'batchNoVariance')
|
|
12
|
+
const expirationDateVarianceFilter = filters?.find(e => e.name === 'expirationDateVariance')
|
|
13
|
+
const locationVarianceFilter = filters?.find(e => e.name === 'locationVariance')
|
|
14
|
+
|
|
12
15
|
const cycleCount: InventoryCheck = await tx.getRepository(InventoryCheck).findOne({
|
|
13
16
|
where: { domain, name },
|
|
14
17
|
relations: ['domain']
|
|
@@ -19,69 +22,68 @@ export const cycleCountReport = {
|
|
|
19
22
|
// Step 1: Create the temp_fixed_columns table
|
|
20
23
|
await tx.query(
|
|
21
24
|
`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
25
|
+
CREATE TEMP TABLE temp_fixed_columns ON COMMIT DROP AS (
|
|
26
|
+
SELECT
|
|
27
|
+
d.id as "partner_domain_id",
|
|
28
|
+
w.check_count as "check_count",
|
|
29
|
+
ic.id as "inventory_check_id",
|
|
30
|
+
ici.inventory_id as "inventory_id",
|
|
31
|
+
ic.name as "name",
|
|
32
|
+
ici.product_id as "product_id",
|
|
33
|
+
ici.count_no as "count_no",
|
|
34
|
+
ici.product_detail_id as "product_detail_id",
|
|
35
|
+
ici.status as "invCheckItemStatus",
|
|
36
|
+
b.name as "company",
|
|
37
|
+
ic.name as "cycle_count_no",
|
|
38
|
+
ic.execution_date as "execution_date",
|
|
39
|
+
ic.status as "status",
|
|
40
|
+
i.carton_id as "carton_id",
|
|
41
|
+
i.pallet_id as "pallet_id",
|
|
42
|
+
i.packing_type as "i_packing_type",
|
|
43
|
+
i.uom as "i_uom",
|
|
44
|
+
p.sku as "product_sku",
|
|
45
|
+
p.name as "product_name",
|
|
46
|
+
p.brand as "product_brand",
|
|
47
|
+
p.description as "product_description",
|
|
48
|
+
pd.packing_type as "pd_packing_type",
|
|
49
|
+
pd.uom as "pd_uom",
|
|
50
|
+
ici.origin_batch_no as "origin_batch_no",
|
|
51
|
+
ici.inspected_batch_no as "inspected_batch_no",
|
|
52
|
+
ici.origin_uom_value as "origin_uom_value",
|
|
53
|
+
ici.origin_location_id as "origin_location_id",
|
|
54
|
+
ici.origin_expiration_date as "origin_expiration_date",
|
|
55
|
+
ici.inspected_expiration_date as "inspected_expiration_date",
|
|
56
|
+
l.name as "origin_location_name",
|
|
57
|
+
ici.inspected_location_id as "inspected_location_id",
|
|
58
|
+
l2.name as "inspected_location_name",
|
|
59
|
+
COALESCE(ici.origin_qty, 0) as "origin_qty",
|
|
60
|
+
COALESCE(ici.inspected_qty, 0) as "inspected_qty",
|
|
61
|
+
COALESCE(ici.inspected_uom_value, 0) as "inspected_uom_value"
|
|
62
|
+
FROM
|
|
63
|
+
inventory_checks ic
|
|
64
|
+
INNER JOIN
|
|
62
65
|
inventory_check_items ici on ici.inventory_check_id = ic.id
|
|
63
|
-
|
|
66
|
+
LEFT JOIN
|
|
64
67
|
inventories i on i.id = ici.inventory_id
|
|
65
|
-
|
|
68
|
+
INNER JOIN
|
|
66
69
|
products p ON p.id = ici.product_id
|
|
67
|
-
|
|
70
|
+
INNER JOIN
|
|
68
71
|
product_details pd ON pd.id = ici.product_detail_id
|
|
69
|
-
|
|
72
|
+
INNER JOIN
|
|
70
73
|
worksheets w on w.inventory_check_id = ic.id
|
|
71
|
-
|
|
74
|
+
INNER JOIN
|
|
72
75
|
worksheet_details wd on wd.worksheet_id = w.id and wd.target_inventory_check_item_id = ici.id
|
|
73
|
-
|
|
76
|
+
LEFT JOIN
|
|
74
77
|
locations l on l.id = ici.origin_location_id
|
|
75
|
-
|
|
78
|
+
LEFT JOIN
|
|
76
79
|
locations l2 on l2.id = ici.inspected_location_id
|
|
77
|
-
|
|
80
|
+
INNER JOIN
|
|
78
81
|
bizplaces b on b.id = ic.bizplace_id
|
|
79
|
-
|
|
82
|
+
INNER JOIN
|
|
80
83
|
domains d on d.id = b.domain_id
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)`,
|
|
84
|
+
WHERE
|
|
85
|
+
ic.id = $1
|
|
86
|
+
)`,
|
|
85
87
|
[cycleCount.id]
|
|
86
88
|
)
|
|
87
89
|
|
|
@@ -99,30 +101,52 @@ export const cycleCountReport = {
|
|
|
99
101
|
)
|
|
100
102
|
|
|
101
103
|
// Step 3: Generate definedCrossColumn for dynamic columns
|
|
102
|
-
|
|
103
|
-
SELECT string_agg(DISTINCT 'count ' || check_count::text, ',') as
|
|
104
|
+
const definedCrossColumn = await tx.query(`
|
|
105
|
+
SELECT string_agg(DISTINCT 'count ' || check_count::text, ',') as count_columns,
|
|
106
|
+
string_agg(DISTINCT 'uom count ' || check_count::text, ',') as uom_columns
|
|
104
107
|
FROM temp_dynamic_columns
|
|
105
108
|
`)
|
|
106
109
|
|
|
107
|
-
|
|
110
|
+
const countColumns = definedCrossColumn[0].count_columns
|
|
111
|
+
.split(',')
|
|
112
|
+
.map(column => `"${column.trim()}" varchar`)
|
|
113
|
+
.join(', ')
|
|
114
|
+
|
|
115
|
+
const uomColumns = definedCrossColumn[0].uom_columns
|
|
108
116
|
.split(',')
|
|
109
117
|
.map(column => `"${column.trim()}" varchar`)
|
|
110
118
|
.join(', ')
|
|
111
119
|
|
|
112
|
-
// Step 4: Pivot data and create the pivot
|
|
120
|
+
// Step 4: Pivot data and create the pivot tables
|
|
113
121
|
await tx.query(`
|
|
114
122
|
CREATE TEMP TABLE temp_pivoted_data ON COMMIT DROP AS (
|
|
115
123
|
SELECT *
|
|
116
124
|
FROM crosstab(
|
|
117
125
|
$$
|
|
118
|
-
SELECT inventory_id, check_count, inspected_qty
|
|
126
|
+
SELECT inventory_id, 'count ' || check_count, inspected_qty
|
|
119
127
|
FROM temp_fixed_columns ORDER BY 1,2,3
|
|
120
128
|
$$,
|
|
121
129
|
$$
|
|
122
|
-
SELECT DISTINCT check_count FROM temp_dynamic_columns ORDER BY 1
|
|
130
|
+
SELECT DISTINCT 'count ' || check_count FROM temp_dynamic_columns ORDER BY 1
|
|
123
131
|
$$
|
|
124
|
-
) AS ct (inventory_id varchar, ${
|
|
125
|
-
)
|
|
132
|
+
) AS ct (inventory_id varchar, ${countColumns})
|
|
133
|
+
)
|
|
134
|
+
`)
|
|
135
|
+
|
|
136
|
+
await tx.query(`
|
|
137
|
+
CREATE TEMP TABLE temp_pivoted_uom_data ON COMMIT DROP AS (
|
|
138
|
+
SELECT *
|
|
139
|
+
FROM crosstab(
|
|
140
|
+
$$
|
|
141
|
+
SELECT inventory_id, 'uom count ' || check_count, inspected_uom_value
|
|
142
|
+
FROM temp_fixed_columns ORDER BY 1,2,3
|
|
143
|
+
$$,
|
|
144
|
+
$$
|
|
145
|
+
SELECT DISTINCT 'uom count ' || check_count FROM temp_dynamic_columns ORDER BY 1
|
|
146
|
+
$$
|
|
147
|
+
) AS ct (inventory_id varchar, ${uomColumns})
|
|
148
|
+
)
|
|
149
|
+
`)
|
|
126
150
|
|
|
127
151
|
// Step 5: Create the temp_final_count table
|
|
128
152
|
await tx.query(
|
|
@@ -131,44 +155,40 @@ export const cycleCountReport = {
|
|
|
131
155
|
SELECT
|
|
132
156
|
inventory_id,
|
|
133
157
|
count_no,
|
|
134
|
-
MAX(inspected_qty) as "final_count"
|
|
158
|
+
MAX(inspected_qty) as "final_count",
|
|
159
|
+
MAX(inspected_uom_value) as "final_uom"
|
|
135
160
|
FROM
|
|
136
161
|
inventory_check_items ici
|
|
137
162
|
WHERE
|
|
138
|
-
|
|
139
|
-
SELECT
|
|
140
|
-
inventory_id,
|
|
141
|
-
MAX(count_no)
|
|
142
|
-
FROM
|
|
143
|
-
inventory_check_items
|
|
144
|
-
WHERE inventory_check_id = $1
|
|
145
|
-
GROUP BY
|
|
146
|
-
inventory_id
|
|
147
|
-
)
|
|
148
|
-
AND inventory_check_id = $1
|
|
163
|
+
inventory_check_id = $1
|
|
149
164
|
GROUP BY inventory_id, count_no
|
|
150
165
|
)`,
|
|
151
166
|
[cycleCount.id]
|
|
152
167
|
)
|
|
153
168
|
|
|
154
|
-
|
|
169
|
+
// Step 6: Create the final temp table with combined data
|
|
170
|
+
const jsonColumnNames = definedCrossColumn[0].count_columns
|
|
155
171
|
.split(',')
|
|
156
|
-
.map(column => {
|
|
157
|
-
|
|
158
|
-
|
|
172
|
+
.map(column => `p."${column.trim()}" as "${column.trim()}"`)
|
|
173
|
+
.join(',')
|
|
174
|
+
|
|
175
|
+
const uomJsonColumnNames = definedCrossColumn[0].uom_columns
|
|
176
|
+
.split(',')
|
|
177
|
+
.map(column => `puom."${column.trim()}" as "${column.trim()}"`)
|
|
159
178
|
.join(',')
|
|
160
179
|
|
|
161
|
-
// Step 6: Create the final temp table with combined data
|
|
162
180
|
await tx.query(`
|
|
163
181
|
CREATE TEMP TABLE temp_final_data ON COMMIT DROP AS (
|
|
164
182
|
SELECT
|
|
165
183
|
f.*,
|
|
166
184
|
fc.final_count,
|
|
185
|
+
fc.final_uom,
|
|
167
186
|
first_count.origin_qty as "system_qty",
|
|
168
187
|
first_count.origin_batch_no as "system_batch_no",
|
|
169
188
|
first_count.origin_location_name as "system_location_name",
|
|
170
189
|
first_count.origin_uom_value as "system_uom_value",
|
|
171
190
|
row_to_json((SELECT cn FROM (SELECT ${jsonColumnNames}) cn))::varchar as "count_data",
|
|
191
|
+
row_to_json((SELECT cn FROM (SELECT ${uomJsonColumnNames}) cn))::varchar as "count_uom_data",
|
|
172
192
|
CASE
|
|
173
193
|
WHEN (COALESCE(first_count.origin_batch_no, '') <> COALESCE(f.inspected_batch_no, ''))
|
|
174
194
|
THEN true
|
|
@@ -204,16 +224,32 @@ export const cycleCountReport = {
|
|
|
204
224
|
WHERE count_no = 1
|
|
205
225
|
) first_count ON f.inventory_id = first_count.inventory_id
|
|
206
226
|
INNER JOIN temp_pivoted_data p ON f.inventory_id::uuid = p.inventory_id::uuid
|
|
227
|
+
INNER JOIN temp_pivoted_uom_data puom ON f.inventory_id::uuid = puom.inventory_id::uuid
|
|
207
228
|
INNER JOIN temp_final_count fc ON f.inventory_id = fc.inventory_id and f.count_no = fc.count_no
|
|
208
|
-
)
|
|
229
|
+
)
|
|
230
|
+
`)
|
|
231
|
+
|
|
232
|
+
const whereConditions = []
|
|
233
|
+
|
|
234
|
+
if (batchNoVarianceFilter?.value === true) {
|
|
235
|
+
whereConditions.push('"BatchNoVariance" = true')
|
|
236
|
+
}
|
|
237
|
+
if (expirationDateVarianceFilter?.value === true) {
|
|
238
|
+
whereConditions.push('"ExpirationDateVariance" = true')
|
|
239
|
+
}
|
|
240
|
+
if (locationVarianceFilter?.value === true) {
|
|
241
|
+
whereConditions.push('"LocationVariance" = true')
|
|
242
|
+
}
|
|
209
243
|
|
|
210
|
-
// Step 7: Select
|
|
244
|
+
// Step 7: Select final result
|
|
211
245
|
const result: any = await tx.query(`
|
|
212
|
-
SELECT * FROM temp_final_data
|
|
246
|
+
SELECT * FROM temp_final_data
|
|
247
|
+
${whereConditions.length > 0 ? 'WHERE ' + whereConditions.join(' OR ') : ''}
|
|
248
|
+
`)
|
|
213
249
|
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
250
|
+
// Step 8: Group inventory id and prepare final response
|
|
251
|
+
const inventoryIds = new Set()
|
|
252
|
+
const items = []
|
|
217
253
|
result.forEach(itm => {
|
|
218
254
|
if (!inventoryIds.has(itm.inventory_id)) {
|
|
219
255
|
inventoryIds.add(itm.inventory_id)
|
|
@@ -273,11 +309,13 @@ export const cycleCountReport = {
|
|
|
273
309
|
originLocationId: itm.origin_location_id,
|
|
274
310
|
inspectedLocationId: itm.inspected_location_id,
|
|
275
311
|
countData: itm.count_data,
|
|
312
|
+
countUomData: itm.count_uom_data,
|
|
276
313
|
batchNoVariance: itm.BatchNoVariance,
|
|
277
314
|
locationVariance: itm.LocationVariance,
|
|
278
315
|
uomValueVariance: itm.UomValueVariance,
|
|
279
316
|
expirationDateVariance: itm.ExpirationDateVariance,
|
|
280
317
|
finalCount: itm.final_count,
|
|
318
|
+
finalUom: itm.final_uom,
|
|
281
319
|
countVariance: itm.final_count - itm.origin_qty,
|
|
282
320
|
countStatus,
|
|
283
321
|
company: itm.company,
|
|
@@ -287,7 +325,7 @@ export const cycleCountReport = {
|
|
|
287
325
|
}
|
|
288
326
|
})
|
|
289
327
|
|
|
290
|
-
// Step
|
|
328
|
+
// Step 9: Count total and return the final object
|
|
291
329
|
const finalTotal = inventoryIds.size
|
|
292
330
|
return {
|
|
293
331
|
items,
|
|
@@ -10,6 +10,7 @@ export const CycleCountReport = gql`
|
|
|
10
10
|
originLocationId: String
|
|
11
11
|
inspectedLocationId: String
|
|
12
12
|
countData: String
|
|
13
|
+
countUomData: String
|
|
13
14
|
batchNoVariance: Boolean
|
|
14
15
|
locationVariance: Boolean
|
|
15
16
|
uomValueVariance: Boolean
|
|
@@ -23,5 +24,6 @@ export const CycleCountReport = gql`
|
|
|
23
24
|
systemBatchNo: String
|
|
24
25
|
systemLocationName: String
|
|
25
26
|
systemUomValue: Float
|
|
27
|
+
finalUom: Float
|
|
26
28
|
}
|
|
27
29
|
`
|
|
@@ -24,14 +24,8 @@ import { ReleaseInventoryReport } from './release-inventory-report'
|
|
|
24
24
|
import { ReleaseInventoryReportList } from './release-inventory-report-list'
|
|
25
25
|
import { ShortageReportList } from './shortage-report-list'
|
|
26
26
|
import { ShortageReport } from './shortage-report-type'
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
VasReport
|
|
30
|
-
} from './vas-report'
|
|
31
|
-
import {
|
|
32
|
-
OrderVasReportList,
|
|
33
|
-
VasReportList
|
|
34
|
-
} from './vas-report-list'
|
|
27
|
+
import { OrderVasReport, VasReport } from './vas-report'
|
|
28
|
+
import { OrderVasReportList, VasReportList } from './vas-report-list'
|
|
35
29
|
|
|
36
30
|
export const Query = `
|
|
37
31
|
inboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundSerialNumberReportList @transaction
|
|
@@ -46,7 +40,7 @@ export const Query = `
|
|
|
46
40
|
orderVasReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OrderVasReportList @transaction
|
|
47
41
|
vasReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OrderVasReportList @transaction
|
|
48
42
|
analysisPickingPackingReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): AnalysisPickingPackingReportList @transaction
|
|
49
|
-
cycleCountReport(name: String!): CycleCountReportList @transaction
|
|
43
|
+
cycleCountReport(filters: [Filter], pagination: Pagination, sortings: [Sorting], name: String!): CycleCountReportList @transaction
|
|
50
44
|
nonLoadedOrderInventories(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): NonLoadedOrderInventoryReportList @transaction
|
|
51
45
|
manifestReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ManifestReportList @transaction
|
|
52
46
|
`
|
package/translations/en.json
CHANGED
package/translations/ko.json
CHANGED
|
@@ -360,6 +360,7 @@
|
|
|
360
360
|
"field.field.zone": "[ko]field zone",
|
|
361
361
|
"field.first_delimiter": "[ko] D1",
|
|
362
362
|
"field.final_count": "[ko] final count",
|
|
363
|
+
"field.final_uom_value": "[ko] final uom value",
|
|
363
364
|
"field.fleet_no": "선단 번호",
|
|
364
365
|
"field.fleet_spec": "선적 사양",
|
|
365
366
|
"field.from_date": "시작 일",
|
package/translations/ms.json
CHANGED
|
@@ -342,6 +342,7 @@
|
|
|
342
342
|
"field.fax": "fax",
|
|
343
343
|
"field.first_delimiter": "[ms] D1",
|
|
344
344
|
"field.final_count": "[ms] final count",
|
|
345
|
+
"field.final_uom_value": "[ms] final uom value",
|
|
345
346
|
"field.fleet_no": "no armada",
|
|
346
347
|
"field.fleet_spec": "spesifikasi armada",
|
|
347
348
|
"field.from_date": "dari tarikh",
|
package/translations/zh.json
CHANGED
|
@@ -330,6 +330,7 @@
|
|
|
330
330
|
"field.fax": "[zh]fax",
|
|
331
331
|
"field.first_delimiter": "[zh] D1",
|
|
332
332
|
"field.final_count": "[zh] final count",
|
|
333
|
+
"field.final_uom_value": "[zh] final uom value",
|
|
333
334
|
"field.from_date": "[zh]from date",
|
|
334
335
|
"field.from_pallet": "[zh]from pallet",
|
|
335
336
|
"field.from": "[zh]from",
|