@things-factory/operato-wms 4.3.356 → 4.3.358
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/components/select-cc-product-popup.js +321 -0
- package/client/pages/constants/order.js +15 -0
- package/client/pages/inventory-check/add-extra-inventory-popup.js +306 -0
- package/client/pages/inventory-check/check-inventory-popup.js +183 -167
- package/client/pages/inventory-check/create-cycle-count.js +292 -141
- package/client/pages/inventory-check/cycle-count-inventory-details-popup.js +282 -0
- package/client/pages/inventory-check/cycle-count-recheck-popup.js +129 -31
- package/client/pages/inventory-check/cycle-count-report.js +425 -306
- package/client/pages/inventory-check/cycle-count-review.js +742 -0
- package/client/pages/inventory-check/cycle-count-worksheet-list.js +476 -0
- package/client/pages/inventory-check/inspecting-product.js +954 -1029
- package/client/pages/inventory-check/inventory-check-detail.js +378 -0
- package/client/pages/inventory-check/inventory-check-list.js +35 -109
- package/client/pages/inventory-check/relocate-inventory-popup.js +222 -0
- package/client/pages/inventory-check/search-popup.js +1 -1
- package/client/pages/inventory-check/select-cc-location-popup.js +230 -0
- package/client/pages/inventory-check/worksheet-cycle-count.js +112 -90
- package/client/pages/outbound/route-label-popup.js +16 -0
- package/client/route.js +8 -0
- package/dist-server/graphql/resolvers/reports/cycle-count-report.js +244 -0
- package/dist-server/graphql/resolvers/reports/cycle-count-report.js.map +1 -0
- package/dist-server/graphql/resolvers/reports/index.js +2 -1
- package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
- package/dist-server/graphql/types/reports/cycle-count-report-list.js +14 -0
- package/dist-server/graphql/types/reports/cycle-count-report-list.js.map +1 -0
- package/dist-server/graphql/types/reports/cycle-count-report.js +25 -0
- package/dist-server/graphql/types/reports/cycle-count-report.js.map +1 -0
- package/dist-server/graphql/types/reports/index.js +5 -0
- package/dist-server/graphql/types/reports/index.js.map +1 -1
- package/package.json +6 -6
- package/server/graphql/resolvers/reports/cycle-count-report.ts +267 -0
- package/server/graphql/resolvers/reports/index.ts +3 -4
- package/server/graphql/types/reports/cycle-count-report-list.ts +8 -0
- package/server/graphql/types/reports/cycle-count-report.ts +19 -0
- package/server/graphql/types/reports/index.ts +7 -8
- package/things-factory.config.js +8 -0
- package/translations/en.json +34 -0
- package/translations/ko.json +34 -0
- package/translations/ms.json +35 -1
- package/translations/zh.json +37 -3
|
@@ -8,6 +8,7 @@ import { isMobileDevice } from '@things-factory/utils'
|
|
|
8
8
|
import gql from 'graphql-tag'
|
|
9
9
|
import { css, html } from 'lit-element'
|
|
10
10
|
import { WORKSHEET_STATUS } from '../constants'
|
|
11
|
+
import { fetchSettingRule } from '../../fetch-setting-value'
|
|
11
12
|
|
|
12
13
|
class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
13
14
|
static get properties() {
|
|
@@ -15,6 +16,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
15
16
|
_worksheetNo: String,
|
|
16
17
|
_worksheetStatus: String,
|
|
17
18
|
_cycleCountNo: String,
|
|
19
|
+
_enableCartonLabel: Boolean,
|
|
18
20
|
config: Object,
|
|
19
21
|
data: Object
|
|
20
22
|
}
|
|
@@ -82,7 +84,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
82
84
|
var actions = [
|
|
83
85
|
{
|
|
84
86
|
title: i18next.t('button.back'),
|
|
85
|
-
action: () =>
|
|
87
|
+
action: () => navigate('cycle_count_worksheet_list'),
|
|
86
88
|
...CommonButtonStyles.back
|
|
87
89
|
}
|
|
88
90
|
]
|
|
@@ -96,7 +98,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
return {
|
|
99
|
-
title: i18next.t('title.
|
|
101
|
+
title: i18next.t('title.cycle_count_worksheet_detail'),
|
|
100
102
|
actions,
|
|
101
103
|
printable: {
|
|
102
104
|
accept: ['preview'],
|
|
@@ -106,6 +108,14 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
get computedColumns() {
|
|
112
|
+
if (this._enableCartonLabel) {
|
|
113
|
+
return this.preConfig.columns.filter(column => column.name !== 'palletId')
|
|
114
|
+
} else {
|
|
115
|
+
return this.preConfig.columns.filter(column => column.name !== 'cartonId')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
109
119
|
render() {
|
|
110
120
|
return html`
|
|
111
121
|
<div class="form-container">
|
|
@@ -115,7 +125,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
115
125
|
<label>${i18next.t('label.company')}</label>
|
|
116
126
|
<input name="bizplace" readonly />
|
|
117
127
|
|
|
118
|
-
<label>${i18next.t('label.
|
|
128
|
+
<label>${i18next.t('label.inventory_check_no')}</label>
|
|
119
129
|
<input name="cycleCountNo" readonly />
|
|
120
130
|
|
|
121
131
|
<label>${i18next.t('label.execute_date')}</label>
|
|
@@ -127,6 +137,9 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
127
137
|
key => html` <option value="${WORKSHEET_STATUS[key].value}">${WORKSHEET_STATUS[key].name}</option> `
|
|
128
138
|
)}
|
|
129
139
|
</select>
|
|
140
|
+
|
|
141
|
+
<label>${i18next.t('label.cycle_count_task_no')}</label>
|
|
142
|
+
<input name="checkCount" readonly />
|
|
130
143
|
</fieldset>
|
|
131
144
|
</form>
|
|
132
145
|
|
|
@@ -139,13 +152,18 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
139
152
|
<data-grist
|
|
140
153
|
id="grist"
|
|
141
154
|
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
142
|
-
.config=${this.
|
|
155
|
+
.config=${{ ...this.preConfig, columns: this.computedColumns }}
|
|
143
156
|
.fetchHandler="${this.fetchWorksheet.bind(this)}"
|
|
144
157
|
></data-grist>
|
|
145
158
|
</div>
|
|
146
159
|
`
|
|
147
160
|
}
|
|
148
161
|
|
|
162
|
+
constructor() {
|
|
163
|
+
super()
|
|
164
|
+
this._enableCartonLabel = false
|
|
165
|
+
}
|
|
166
|
+
|
|
149
167
|
pageUpdated(changes) {
|
|
150
168
|
if (this.active && (changes.resourceId || this._worksheetNo)) {
|
|
151
169
|
if (changes.resourceId) {
|
|
@@ -166,19 +184,9 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
166
184
|
this.preConfig = {
|
|
167
185
|
rows: { appendable: false },
|
|
168
186
|
list: {
|
|
169
|
-
fields: [
|
|
170
|
-
'batchId',
|
|
171
|
-
'palletId',
|
|
172
|
-
'product',
|
|
173
|
-
'location',
|
|
174
|
-
'inspectedLocation',
|
|
175
|
-
'inspectedQty',
|
|
176
|
-
'inspectedUomValue',
|
|
177
|
-
'inspectedBatchNo',
|
|
178
|
-
'status'
|
|
179
|
-
]
|
|
187
|
+
fields: ['batchId', 'cartonId', 'palletId', 'product', 'location', 'status']
|
|
180
188
|
},
|
|
181
|
-
|
|
189
|
+
pagination: { infinite: true },
|
|
182
190
|
columns: [
|
|
183
191
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
184
192
|
{
|
|
@@ -188,6 +196,13 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
188
196
|
imex: { header: i18next.t('field.batch_id'), key: 'batchId', width: 100, type: 'string' },
|
|
189
197
|
width: 100
|
|
190
198
|
},
|
|
199
|
+
{
|
|
200
|
+
type: 'string',
|
|
201
|
+
name: 'cartonId',
|
|
202
|
+
header: i18next.t('field.carton_id'),
|
|
203
|
+
imex: { header: i18next.t('field.carton_id'), key: 'cartonId', width: 150, type: 'string' },
|
|
204
|
+
width: 150
|
|
205
|
+
},
|
|
191
206
|
{
|
|
192
207
|
type: 'string',
|
|
193
208
|
name: 'palletId',
|
|
@@ -217,7 +232,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
217
232
|
width: 15,
|
|
218
233
|
type: 'string'
|
|
219
234
|
},
|
|
220
|
-
width:
|
|
235
|
+
width: 100
|
|
221
236
|
},
|
|
222
237
|
{
|
|
223
238
|
type: 'object',
|
|
@@ -229,7 +244,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
229
244
|
width: 15,
|
|
230
245
|
type: 'string'
|
|
231
246
|
},
|
|
232
|
-
width:
|
|
247
|
+
width: 100
|
|
233
248
|
},
|
|
234
249
|
{
|
|
235
250
|
type: 'string',
|
|
@@ -238,44 +253,6 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
238
253
|
imex: { header: i18next.t('field.packing_type'), key: 'packingType', width: 100, type: 'string' },
|
|
239
254
|
width: 100
|
|
240
255
|
},
|
|
241
|
-
{
|
|
242
|
-
type: 'object',
|
|
243
|
-
name: 'inspectedLocation',
|
|
244
|
-
header: i18next.t('field.inspected_location'),
|
|
245
|
-
imex: {
|
|
246
|
-
header: i18next.t('field.inspected_location'),
|
|
247
|
-
key: 'inspectedLocation.name',
|
|
248
|
-
width: 15,
|
|
249
|
-
type: 'string'
|
|
250
|
-
},
|
|
251
|
-
width: 120
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
type: 'string',
|
|
255
|
-
name: 'inspectedBatchNo',
|
|
256
|
-
header: i18next.t('field.inspected_batch_no'),
|
|
257
|
-
imex: { header: i18next.t('field.inspected_batch_no'), key: 'inspectedBatchNo', width: 100, type: 'string' },
|
|
258
|
-
width: 100
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
type: 'integer',
|
|
262
|
-
name: 'inspectedQty',
|
|
263
|
-
header: i18next.t('field.inspected_qty'),
|
|
264
|
-
imex: { header: i18next.t('field.inspected_qty'), key: 'inspectedQty', width: 100, type: 'number' },
|
|
265
|
-
width: 100
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
type: 'float',
|
|
269
|
-
name: 'inspectedUomValue',
|
|
270
|
-
header: i18next.t('field.inspected_uom_value'),
|
|
271
|
-
imex: {
|
|
272
|
-
header: i18next.t('field.inspected_uom_value'),
|
|
273
|
-
key: 'inspectedUomValue',
|
|
274
|
-
width: 100,
|
|
275
|
-
type: 'number'
|
|
276
|
-
},
|
|
277
|
-
width: 100
|
|
278
|
-
},
|
|
279
256
|
{
|
|
280
257
|
type: 'string',
|
|
281
258
|
name: 'uom',
|
|
@@ -300,7 +277,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
300
277
|
return this.shadowRoot.querySelector('data-grist')
|
|
301
278
|
}
|
|
302
279
|
|
|
303
|
-
async fetchWorksheet(
|
|
280
|
+
async fetchWorksheet() {
|
|
304
281
|
if (!this._worksheetNo) return
|
|
305
282
|
const response = await client.query({
|
|
306
283
|
query: gql`
|
|
@@ -308,25 +285,43 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
308
285
|
worksheetWithPagination(name: $name, pagination: $pagination) {
|
|
309
286
|
worksheet {
|
|
310
287
|
status
|
|
288
|
+
checkCount
|
|
311
289
|
inventoryCheck {
|
|
312
290
|
name
|
|
313
291
|
executionDate
|
|
314
292
|
}
|
|
315
293
|
bizplace {
|
|
294
|
+
id
|
|
316
295
|
name
|
|
296
|
+
domain {
|
|
297
|
+
id
|
|
298
|
+
name
|
|
299
|
+
}
|
|
317
300
|
}
|
|
318
301
|
}
|
|
319
302
|
worksheetDetails {
|
|
320
303
|
name
|
|
321
304
|
description
|
|
322
305
|
status
|
|
323
|
-
|
|
306
|
+
targetInventoryCheckItem {
|
|
307
|
+
product {
|
|
308
|
+
name
|
|
309
|
+
brand
|
|
310
|
+
description
|
|
311
|
+
}
|
|
312
|
+
productDetail {
|
|
313
|
+
id
|
|
314
|
+
packingType
|
|
315
|
+
uom
|
|
316
|
+
}
|
|
324
317
|
inventory {
|
|
325
318
|
batchId
|
|
319
|
+
cartonId
|
|
326
320
|
palletId
|
|
327
321
|
packingType
|
|
328
322
|
uom
|
|
329
323
|
location {
|
|
324
|
+
id
|
|
330
325
|
name
|
|
331
326
|
description
|
|
332
327
|
}
|
|
@@ -336,13 +331,6 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
336
331
|
description
|
|
337
332
|
}
|
|
338
333
|
}
|
|
339
|
-
inspectedLocation {
|
|
340
|
-
name
|
|
341
|
-
description
|
|
342
|
-
}
|
|
343
|
-
inspectedBatchNo
|
|
344
|
-
inspectedQty
|
|
345
|
-
inspectedUomValue
|
|
346
334
|
}
|
|
347
335
|
}
|
|
348
336
|
total
|
|
@@ -351,7 +339,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
351
339
|
`,
|
|
352
340
|
variables: {
|
|
353
341
|
name: this._worksheetNo,
|
|
354
|
-
pagination: {
|
|
342
|
+
pagination: {}
|
|
355
343
|
}
|
|
356
344
|
})
|
|
357
345
|
|
|
@@ -360,6 +348,16 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
360
348
|
this._worksheetStatus = worksheet.status
|
|
361
349
|
this._cycleCountNo = (worksheet.inventoryCheck && worksheet.inventoryCheck.name) || ''
|
|
362
350
|
|
|
351
|
+
const partnerDomainId = worksheet.bizplace?.domain.id
|
|
352
|
+
this._enableCartonLabel = await fetchSettingRule('enable-carton-label', partnerDomainId)
|
|
353
|
+
await this.updateComplete
|
|
354
|
+
|
|
355
|
+
if (this._enableCartonLabel) {
|
|
356
|
+
this.preConfig.columns = this.preConfig.columns.filter(column => column.name !== 'palletId')
|
|
357
|
+
} else {
|
|
358
|
+
this.preConfig.columns = this.preConfig.columns.filter(column => column.name !== 'cartonId')
|
|
359
|
+
}
|
|
360
|
+
|
|
363
361
|
this._fillupForm({
|
|
364
362
|
...worksheet,
|
|
365
363
|
cycleCountNo: worksheet.inventoryCheck.name,
|
|
@@ -367,25 +365,47 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
367
365
|
})
|
|
368
366
|
|
|
369
367
|
const records = worksheetDetails.map(worksheetDetail => {
|
|
370
|
-
|
|
371
|
-
...worksheetDetail.
|
|
372
|
-
|
|
373
|
-
|
|
368
|
+
const record = {
|
|
369
|
+
...worksheetDetail.targetInventoryCheckItem.inventory,
|
|
370
|
+
productDetailId: worksheetDetail.targetInventoryCheckItem.productDetail.id,
|
|
371
|
+
locationId: worksheetDetail.targetInventoryCheckItem.inventory.location.id,
|
|
372
|
+
brand: worksheetDetail.targetInventoryCheckItem.inventory.product.brand,
|
|
374
373
|
description: worksheetDetail.description,
|
|
375
374
|
status: worksheetDetail.status,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
inspectedUomValue: worksheetDetail.targetInventory.inspectedUomValue,
|
|
379
|
-
uom:
|
|
380
|
-
worksheetDetail.targetInventory &&
|
|
381
|
-
worksheetDetail.targetInventory.inventory &&
|
|
382
|
-
worksheetDetail.targetInventory.inventory.uom,
|
|
383
|
-
inspectedBatchNo: worksheetDetail.targetInventory.inspectedBatchNo,
|
|
384
|
-
packingType: worksheetDetail.targetInventory.inventory.packingType
|
|
375
|
+
uom: worksheetDetail.targetInventoryCheckItem.inventory.uom,
|
|
376
|
+
packingType: worksheetDetail.targetInventoryCheckItem.inventory.packingType
|
|
385
377
|
}
|
|
378
|
+
|
|
379
|
+
if (!this._enableCartonLabel) {
|
|
380
|
+
record.name = worksheetDetail.name
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return record
|
|
386
384
|
})
|
|
387
385
|
|
|
388
|
-
|
|
386
|
+
if (this._enableCartonLabel) {
|
|
387
|
+
const groupedRecords = {}
|
|
388
|
+
let groupedTotal = 0
|
|
389
|
+
|
|
390
|
+
records.forEach(record => {
|
|
391
|
+
const groupKey = `${record.cartonId || ''}-${record.productDetailId || ''}-${record.batchId || ''}-${
|
|
392
|
+
record.locationId || ''
|
|
393
|
+
}`
|
|
394
|
+
|
|
395
|
+
if (!groupedRecords[groupKey]) {
|
|
396
|
+
groupedRecords[groupKey] = { ...record, count: 1 }
|
|
397
|
+
groupedTotal++
|
|
398
|
+
} else {
|
|
399
|
+
groupedRecords[groupKey].count += 1
|
|
400
|
+
}
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
const groupedResults = Object.values(groupedRecords)
|
|
404
|
+
|
|
405
|
+
return { records: groupedResults, total: groupedTotal }
|
|
406
|
+
} else {
|
|
407
|
+
return { records, total }
|
|
408
|
+
}
|
|
389
409
|
}
|
|
390
410
|
}
|
|
391
411
|
|
|
@@ -397,24 +417,26 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
397
417
|
width: 100
|
|
398
418
|
}
|
|
399
419
|
|
|
400
|
-
this.preConfig.columns
|
|
420
|
+
const updatedColumns = [...this.preConfig.columns]
|
|
421
|
+
for (let column of updatedColumns) {
|
|
401
422
|
if (column.name === 'description') {
|
|
402
423
|
column.record = { ...column.record, editable: this._worksheetStatus === WORKSHEET_STATUS.DEACTIVATED.value }
|
|
403
424
|
}
|
|
404
|
-
}
|
|
425
|
+
}
|
|
405
426
|
|
|
406
427
|
if (
|
|
407
|
-
!
|
|
428
|
+
!updatedColumns.some(e => e.name === 'status') &&
|
|
408
429
|
this._worksheetStatus !== WORKSHEET_STATUS.DEACTIVATED.value
|
|
409
430
|
) {
|
|
410
|
-
|
|
411
|
-
} else
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
431
|
+
updatedColumns.push(statusColumnConfig)
|
|
432
|
+
} else {
|
|
433
|
+
const indexToRemove = updatedColumns.findIndex(e => e.name === 'status')
|
|
434
|
+
if (indexToRemove !== -1) {
|
|
435
|
+
updatedColumns.splice(indexToRemove, 1)
|
|
436
|
+
}
|
|
416
437
|
}
|
|
417
438
|
|
|
439
|
+
this.preConfig.columns = updatedColumns
|
|
418
440
|
this.config = { ...this.preConfig }
|
|
419
441
|
}
|
|
420
442
|
|
|
@@ -477,7 +499,7 @@ class WorksheetCycleCount extends localize(i18next)(PageView) {
|
|
|
477
499
|
})
|
|
478
500
|
await this.grist.fetch()
|
|
479
501
|
this.updateContext()
|
|
480
|
-
navigate(`
|
|
502
|
+
navigate(`cycle_count_worksheet_list`)
|
|
481
503
|
} else {
|
|
482
504
|
CustomAlert({
|
|
483
505
|
title: i18next.t('title.error'),
|
|
@@ -280,6 +280,14 @@ class RouteLabelPopup extends connect(store)(localize(i18next)(LitElement)) {
|
|
|
280
280
|
header: i18next.t('field.release_qty'),
|
|
281
281
|
width: 150
|
|
282
282
|
},
|
|
283
|
+
{
|
|
284
|
+
type: 'select',
|
|
285
|
+
name: 'packingType',
|
|
286
|
+
header: i18next.t('field.packing_type'),
|
|
287
|
+
width: 150,
|
|
288
|
+
options: [],
|
|
289
|
+
props: { searchOper: 'eq' }
|
|
290
|
+
},
|
|
283
291
|
{
|
|
284
292
|
type: 'string',
|
|
285
293
|
name: 'roName',
|
|
@@ -402,6 +410,14 @@ class RouteLabelPopup extends connect(store)(localize(i18next)(LitElement)) {
|
|
|
402
410
|
}) || {}
|
|
403
411
|
})
|
|
404
412
|
}
|
|
413
|
+
// Populate the packingType options
|
|
414
|
+
const uniquePackingTypes = [...new Set(this.orderInventories.records.map(record => record.packingType))]
|
|
415
|
+
const packingTypeOptions = uniquePackingTypes.map(typeValue => ({
|
|
416
|
+
value: typeValue,
|
|
417
|
+
name: typeValue // You can modify this to display a formatted name if needed
|
|
418
|
+
}))
|
|
419
|
+
|
|
420
|
+
this.config.columns.find(col => col.name === 'packingType').options = packingTypeOptions
|
|
405
421
|
} catch (e) {
|
|
406
422
|
this._showToast(e)
|
|
407
423
|
}
|
package/client/route.js
CHANGED
|
@@ -288,6 +288,10 @@ export default function route(page) {
|
|
|
288
288
|
import('./pages/inventory-check/inventory-check-list')
|
|
289
289
|
return page
|
|
290
290
|
|
|
291
|
+
case 'cycle_count_worksheet_list':
|
|
292
|
+
import('./pages/inventory-check/cycle-count-worksheet-list')
|
|
293
|
+
return page
|
|
294
|
+
|
|
291
295
|
case 'worksheet_cycle_count':
|
|
292
296
|
import('./pages/inventory-check/worksheet-cycle-count')
|
|
293
297
|
return page
|
|
@@ -300,6 +304,10 @@ export default function route(page) {
|
|
|
300
304
|
import('./pages/inventory-check/cycle-count-report')
|
|
301
305
|
return page
|
|
302
306
|
|
|
307
|
+
case 'cycle_count_review':
|
|
308
|
+
import('./pages/inventory-check/cycle-count-review')
|
|
309
|
+
return page
|
|
310
|
+
|
|
303
311
|
case 'job_sheets':
|
|
304
312
|
import('./pages/report/job-sheet-list')
|
|
305
313
|
return page
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cycleCountReport = void 0;
|
|
4
|
+
const sales_base_1 = require("@things-factory/sales-base");
|
|
5
|
+
exports.cycleCountReport = {
|
|
6
|
+
async cycleCountReport(_, { name }, context) {
|
|
7
|
+
try {
|
|
8
|
+
const { domain, tx } = context.state;
|
|
9
|
+
const cycleCount = await tx.getRepository(sales_base_1.InventoryCheck).findOne({
|
|
10
|
+
where: { domain, name },
|
|
11
|
+
relations: ['domain']
|
|
12
|
+
});
|
|
13
|
+
await tx.query(`CREATE EXTENSION IF NOT EXISTS tablefunc`);
|
|
14
|
+
// Step 1: Create the temp_fixed_columns table
|
|
15
|
+
await tx.query(`
|
|
16
|
+
CREATE TEMP TABLE temp_fixed_columns ON COMMIT DROP AS (
|
|
17
|
+
SELECT
|
|
18
|
+
d.id as "partner_domain_id",
|
|
19
|
+
w.check_count as "check_count",
|
|
20
|
+
ic.id as "inventory_check_id",
|
|
21
|
+
ici.inventory_id as "inventory_id",
|
|
22
|
+
ic.name as "name",
|
|
23
|
+
ici.product_id as "product_id",
|
|
24
|
+
ici.count_no as "count_no",
|
|
25
|
+
ici.product_detail_id as "product_detail_id",
|
|
26
|
+
ici.status as "invCheckItemStatus",
|
|
27
|
+
b.name as "company",
|
|
28
|
+
ic.name as "cycle_count_no",
|
|
29
|
+
ic.execution_date as "execution_date",
|
|
30
|
+
ic.status as "status",
|
|
31
|
+
i.carton_id as "carton_id",
|
|
32
|
+
i.pallet_id as "pallet_id",
|
|
33
|
+
p.sku as "product_sku",
|
|
34
|
+
p.name as "product_name",
|
|
35
|
+
p.brand as "product_brand",
|
|
36
|
+
p.packing_type as "product_packing_type",
|
|
37
|
+
ici.origin_batch_no as "origin_batch_no",
|
|
38
|
+
ici.inspected_batch_no as "inspected_batch_no",
|
|
39
|
+
ici.origin_location_id as "origin_location_id",
|
|
40
|
+
ici.inspected_location_id as "inspected_location_id",
|
|
41
|
+
ici.origin_uom_value as "origin_uom_value",
|
|
42
|
+
ici.inspected_uom_value as "inspected_uom_value",
|
|
43
|
+
COALESCE(ici_first_count.origin_qty, ici.origin_qty, 0) as "origin_qty",
|
|
44
|
+
COALESCE(ici.inspected_qty, 0) as "inspected_qty"
|
|
45
|
+
FROM
|
|
46
|
+
inventory_checks ic
|
|
47
|
+
inner join
|
|
48
|
+
inventory_check_items ici on ici.inventory_check_id = ic.id
|
|
49
|
+
left join
|
|
50
|
+
inventories i on i.id = ici.inventory_id
|
|
51
|
+
left join
|
|
52
|
+
inventory_check_items ici_first_count on ici_first_count.inventory_id = ici.inventory_id AND ici_first_count.count_no = 1
|
|
53
|
+
inner join
|
|
54
|
+
products p ON p.id = ici.product_id
|
|
55
|
+
inner join
|
|
56
|
+
product_details pd ON pd.id = ici.product_detail_id
|
|
57
|
+
inner join
|
|
58
|
+
worksheets w on w.inventory_check_id = ic.id
|
|
59
|
+
inner join
|
|
60
|
+
worksheet_details wd on wd.worksheet_id = w.id and wd.target_inventory_check_item_id = ici.id
|
|
61
|
+
inner join
|
|
62
|
+
bizplaces b on b.id = ic.bizplace_id
|
|
63
|
+
inner join
|
|
64
|
+
domains d on d.id = b.domain_id
|
|
65
|
+
WHERE
|
|
66
|
+
ic.id = $1
|
|
67
|
+
|
|
68
|
+
)`, [cycleCount.id]);
|
|
69
|
+
// Step 2: Create the temp_dynamic_columns table
|
|
70
|
+
await tx.query(`
|
|
71
|
+
CREATE TEMP TABLE temp_dynamic_columns ON COMMIT DROP AS (
|
|
72
|
+
SELECT ic.id as "inventory_check_id",
|
|
73
|
+
w.check_count as "check_count"
|
|
74
|
+
FROM inventory_checks ic
|
|
75
|
+
INNER JOIN worksheets w ON ic.id = w.inventory_check_id
|
|
76
|
+
WHERE ic.id = $1
|
|
77
|
+
)`, [cycleCount.id]);
|
|
78
|
+
// Step 3: Generate definedCrossColumn for dynamic columns
|
|
79
|
+
let definedCrossColumn = await tx.query(`
|
|
80
|
+
SELECT string_agg(DISTINCT concat('count_', check_count), ',') as columns
|
|
81
|
+
FROM temp_dynamic_columns`);
|
|
82
|
+
// Step 4: Pivot data and create the pivot table
|
|
83
|
+
await tx.query(`
|
|
84
|
+
CREATE TEMP TABLE temp_pivoted_data ON COMMIT DROP AS (
|
|
85
|
+
SELECT *
|
|
86
|
+
FROM crosstab(
|
|
87
|
+
$$
|
|
88
|
+
SELECT inventory_id, check_count, inspected_qty
|
|
89
|
+
FROM temp_fixed_columns ORDER BY 1,2,3
|
|
90
|
+
$$,
|
|
91
|
+
$$
|
|
92
|
+
SELECT DISTINCT check_count FROM temp_dynamic_columns ORDER BY 1
|
|
93
|
+
$$
|
|
94
|
+
) AS ct (inventory_id varchar, ${definedCrossColumn[0].columns
|
|
95
|
+
.split(',')
|
|
96
|
+
.map(itm => {
|
|
97
|
+
return itm + ' varchar';
|
|
98
|
+
})
|
|
99
|
+
.join(',')} )
|
|
100
|
+
)`);
|
|
101
|
+
// Step 5: Create the temp_final_count table
|
|
102
|
+
await tx.query(`
|
|
103
|
+
CREATE TEMP TABLE temp_final_count ON COMMIT DROP AS (
|
|
104
|
+
SELECT
|
|
105
|
+
inventory_id,
|
|
106
|
+
MAX(inspected_qty) as "final_count"
|
|
107
|
+
FROM
|
|
108
|
+
inventory_check_items ici
|
|
109
|
+
WHERE
|
|
110
|
+
(inventory_id, count_no) IN (
|
|
111
|
+
SELECT
|
|
112
|
+
inventory_id,
|
|
113
|
+
MAX(count_no)
|
|
114
|
+
FROM
|
|
115
|
+
inventory_check_items
|
|
116
|
+
GROUP BY
|
|
117
|
+
inventory_id
|
|
118
|
+
)
|
|
119
|
+
AND inventory_check_id = $1
|
|
120
|
+
GROUP BY inventory_id
|
|
121
|
+
)`, [cycleCount.id]);
|
|
122
|
+
// Step 6: Create the final temp table with combined data
|
|
123
|
+
await tx.query(`
|
|
124
|
+
CREATE TEMP TABLE temp_final_data ON COMMIT DROP AS (
|
|
125
|
+
SELECT
|
|
126
|
+
f.*,
|
|
127
|
+
fc.final_count,
|
|
128
|
+
row_to_json((SELECT cn FROM (SELECT ${definedCrossColumn[0].columns
|
|
129
|
+
.split(',')
|
|
130
|
+
.map(itm => {
|
|
131
|
+
return 'p.' + itm;
|
|
132
|
+
})
|
|
133
|
+
.join(',')}) cn))::varchar as "count_data",
|
|
134
|
+
CASE
|
|
135
|
+
WHEN f.count_no = latest_counts.latest_count_no
|
|
136
|
+
THEN (f.origin_batch_no <> f.inspected_batch_no)
|
|
137
|
+
ELSE false
|
|
138
|
+
END AS "BatchNoVariance",
|
|
139
|
+
CASE
|
|
140
|
+
WHEN f.count_no = latest_counts.latest_count_no
|
|
141
|
+
THEN (f.origin_location_id <> f.inspected_location_id)
|
|
142
|
+
ELSE false
|
|
143
|
+
END AS "LocationVariance",
|
|
144
|
+
CASE
|
|
145
|
+
WHEN f.count_no = latest_counts.latest_count_no
|
|
146
|
+
THEN (f.origin_uom_value <> f.inspected_uom_value)
|
|
147
|
+
ELSE false
|
|
148
|
+
END AS "UomValueVariance"
|
|
149
|
+
FROM temp_fixed_columns f
|
|
150
|
+
LEFT JOIN temp_pivoted_data p ON f.inventory_id::uuid = p.inventory_id::uuid
|
|
151
|
+
LEFT JOIN temp_final_count fc ON f.inventory_id = fc.inventory_id
|
|
152
|
+
LEFT JOIN (
|
|
153
|
+
SELECT inventory_id, MAX(count_no) as latest_count_no
|
|
154
|
+
FROM temp_fixed_columns
|
|
155
|
+
GROUP BY inventory_id
|
|
156
|
+
) latest_counts ON f.inventory_id = latest_counts.inventory_id
|
|
157
|
+
)`);
|
|
158
|
+
// Step 7: Select final result
|
|
159
|
+
const result = await tx.query(`
|
|
160
|
+
SELECT * FROM temp_final_data`);
|
|
161
|
+
// groupinh inventory id
|
|
162
|
+
let inventoryIds = new Set();
|
|
163
|
+
let items = [];
|
|
164
|
+
result.forEach(itm => {
|
|
165
|
+
if (!inventoryIds.has(itm.inventory_id)) {
|
|
166
|
+
inventoryIds.add(itm.inventory_id);
|
|
167
|
+
let countStatus;
|
|
168
|
+
if (itm.inspected_batch_no === null &&
|
|
169
|
+
itm.inspected_qty === null &&
|
|
170
|
+
itm.inspected_uom_value === null &&
|
|
171
|
+
itm.inspected_location_id === null) {
|
|
172
|
+
countStatus = 'MISSING';
|
|
173
|
+
}
|
|
174
|
+
else if (itm.origin_batch_no === null &&
|
|
175
|
+
itm.origin_qty === null &&
|
|
176
|
+
itm.origin_uom_value === null &&
|
|
177
|
+
itm.origin_location_id === null) {
|
|
178
|
+
countStatus = 'NEW';
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (itm.final_count === itm.origin_qty) {
|
|
182
|
+
countStatus = 'HIT';
|
|
183
|
+
}
|
|
184
|
+
else if (itm.final_count < itm.origin_qty) {
|
|
185
|
+
countStatus = 'SHORT';
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
countStatus = 'EXCESS';
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
let data = {
|
|
192
|
+
inventoryCheck: {
|
|
193
|
+
name: itm.name,
|
|
194
|
+
executionDate: itm.execution_date,
|
|
195
|
+
status: itm.status
|
|
196
|
+
},
|
|
197
|
+
inventoryCheckItem: {
|
|
198
|
+
status: itm.invCheckItemStatus,
|
|
199
|
+
originBatchNo: itm.origin_batch_no,
|
|
200
|
+
inspectedBatchNo: itm.inspected_batch_no,
|
|
201
|
+
originLocation: itm.origin_location_id,
|
|
202
|
+
inspectedLocation: itm.inspected_location_id,
|
|
203
|
+
originUomValue: itm.origin_uom_value,
|
|
204
|
+
inspectedUomValue: itm.inspected_uom_value,
|
|
205
|
+
originQty: itm.origin_qty,
|
|
206
|
+
inspectedQty: itm.inspected_qty
|
|
207
|
+
},
|
|
208
|
+
inventory: {
|
|
209
|
+
id: itm.inventory_id,
|
|
210
|
+
cartonId: itm.carton_id,
|
|
211
|
+
palletId: itm.pallet_id
|
|
212
|
+
},
|
|
213
|
+
product: {
|
|
214
|
+
sku: itm.product_sku,
|
|
215
|
+
name: itm.product_name,
|
|
216
|
+
brand: itm.product_brand,
|
|
217
|
+
packingType: itm.product_packing_type
|
|
218
|
+
},
|
|
219
|
+
countData: itm.count_data,
|
|
220
|
+
batchNoVariance: itm.BatchNoVariance,
|
|
221
|
+
locationVariance: itm.LocationVariance,
|
|
222
|
+
uomValueVariance: itm.UomValueVariance,
|
|
223
|
+
finalCount: itm.final_count,
|
|
224
|
+
countVariance: itm.final_count - itm.origin_qty,
|
|
225
|
+
countStatus,
|
|
226
|
+
company: itm.company,
|
|
227
|
+
partnerDomainId: itm.partner_domain_id
|
|
228
|
+
};
|
|
229
|
+
items.push(data);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
// Step 8: Count total and return the final object
|
|
233
|
+
const finalTotal = inventoryIds.size;
|
|
234
|
+
return {
|
|
235
|
+
items,
|
|
236
|
+
total: finalTotal
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
//# sourceMappingURL=cycle-count-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycle-count-report.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/cycle-count-report.ts"],"names":[],"mappings":";;;AAGA,2DAA2D;AAG9C,QAAA,gBAAgB,GAAG;IAC9B,KAAK,CAAC,gBAAgB,CAAC,CAAM,EAAE,EAAE,IAAI,EAAoB,EAAE,OAAY;QACrE,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAA0C,OAAO,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