@things-factory/operato-wms 4.3.591 → 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.
@@ -137,6 +137,12 @@ class CycleCountInventoryDetailsPopup extends localize(i18next)(LitElement) {
137
137
  header: i18next.t('field.count_no'),
138
138
  width: 120
139
139
  },
140
+ {
141
+ type: 'string',
142
+ name: 'description',
143
+ header: i18next.t('field.description'),
144
+ width: 100
145
+ },
140
146
  {
141
147
  type: 'string',
142
148
  name: 'originBatchNo',
@@ -161,18 +167,6 @@ class CycleCountInventoryDetailsPopup extends localize(i18next)(LitElement) {
161
167
  header: i18next.t('field.inspected_location'),
162
168
  width: 200
163
169
  },
164
- {
165
- type: 'string',
166
- name: 'originUomValue',
167
- header: i18next.t('field.system_uom_value'),
168
- width: 200
169
- },
170
- {
171
- type: 'string',
172
- name: 'inspectedUomValue',
173
- header: i18next.t('field.inspected_uom_value'),
174
- width: 200
175
- },
176
170
  {
177
171
  type: 'string',
178
172
  name: 'originExpirationDate',
@@ -221,6 +215,9 @@ class CycleCountInventoryDetailsPopup extends localize(i18next)(LitElement) {
221
215
  inspectedBatchNo
222
216
  systemExpiryDate
223
217
  inspectedExpiryDate
218
+ product {
219
+ description
220
+ }
224
221
  originLocation {
225
222
  id
226
223
  name
@@ -254,6 +251,8 @@ class CycleCountInventoryDetailsPopup extends localize(i18next)(LitElement) {
254
251
  context: gqlContext()
255
252
  })
256
253
 
254
+ const items = response?.data?.inventoryCheckItems?.items || []
255
+
257
256
  if (!response.errors) {
258
257
  this.data = {
259
258
  total: response.data.inventoryCheckItems.total || 0,
@@ -262,6 +261,7 @@ class CycleCountInventoryDetailsPopup extends localize(i18next)(LitElement) {
262
261
  return {
263
262
  ...itm,
264
263
  countNo: itm.countNo,
264
+ description: itm.product?.description,
265
265
  inspectedBatchNo: itm.inspectedBatchNo,
266
266
  originLocationName: itm.originLocation ? itm.originLocation.name : null,
267
267
  inspectedLocationName: itm.inspectedLocation ? itm.inspectedLocation.name : null,
@@ -21,11 +21,15 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
21
21
  _worksheetNo: String,
22
22
  _reportStatus: String,
23
23
  _cycleCountNo: String,
24
+ _orgInventoryAccuracy: Number,
24
25
  _enableCartonLabel: Boolean,
25
26
  _countData: Array,
27
+ _countUomData: Array,
28
+ _searchFields: Array,
26
29
  cycleCountType: String,
27
30
  customerId: String,
28
31
  inventoryAccuracy: String,
32
+ _firstItem: Object,
29
33
  config: Object,
30
34
  data: Object
31
35
  }
@@ -137,6 +141,7 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
137
141
  </fieldset>
138
142
  </form>
139
143
  </div>
144
+ <search-form id="search-form" .fields=${this._searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
140
145
  <div class="grist">
141
146
  <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.inventory')}</h2>
142
147
  <data-grist
@@ -152,6 +157,8 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
152
157
  constructor() {
153
158
  super()
154
159
  this._enableCartonLabel = false
160
+ this._firstItem = {}
161
+ this._orgInventoryAccuracy = null
155
162
  }
156
163
 
157
164
  async pageUpdated(changes) {
@@ -163,25 +170,64 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
163
170
  await this.fetchCycleCountReport()
164
171
  this.config = { ...this.cycleCountConfig }
165
172
  }
173
+
174
+ this.resetSearchForm()
175
+ this._clearView()
166
176
  }
167
177
 
168
178
  async pageInitialized() {
169
179
  this.isUserBelongsDomain = await this._checkUserBelongsDomain()
170
180
  this.config = this.cycleCountConfig
181
+
182
+ this._searchFields = [
183
+ {
184
+ name: 'batchNoVariance',
185
+ label: i18next.t('field.batch_no_variance'),
186
+ type: 'checkbox',
187
+ value: false,
188
+ props: { searchOper: 'eq' }
189
+ },
190
+ {
191
+ name: 'expirationDateVariance',
192
+ label: i18next.t('field.expiration_date_variance'),
193
+ type: 'checkbox',
194
+ value: false,
195
+ props: { searchOper: 'eq' }
196
+ },
197
+ {
198
+ name: 'locationVariance',
199
+ label: i18next.t('field.location_variance'),
200
+ type: 'checkbox',
201
+ value: false,
202
+ props: { searchOper: 'eq' }
203
+ }
204
+ ]
171
205
  }
172
206
 
173
207
  get cycleCountConfig() {
174
- let data = this._countData
175
- const countColumns = data
176
- ? Object.keys(data)
177
- .filter(key => key.startsWith('count ') && data[key] !== null && data[key] !== undefined)
178
- .map(key => ({
179
- type: 'integer',
180
- name: key,
181
- header: key,
182
- width: 120
183
- }))
184
- : []
208
+ let data = this._countData || {}
209
+ // Generate UOM Count Columns
210
+ const countColumns = Object.keys(data)
211
+ .filter(key => key.startsWith('count ') && data[key] !== null && data[key] !== undefined)
212
+ .map(key => ({
213
+ type: 'integer',
214
+ name: key,
215
+ header: key,
216
+ width: 120
217
+ }))
218
+
219
+ // Generate UOM Value Columns
220
+ const uomValueColumns = Object.keys(data)
221
+ .filter(key => key.startsWith('count ') && data[key] !== null && data[key] !== undefined)
222
+ .map((key, index) => {
223
+ const inspectedValueKey = `uom count ${index + 1}`
224
+ return {
225
+ type: 'integer',
226
+ name: inspectedValueKey,
227
+ header: `UOM Value ${key}`,
228
+ width: 150
229
+ }
230
+ })
185
231
 
186
232
  let columns = [
187
233
  { type: 'gutter', gutterName: 'sequence' },
@@ -226,58 +272,35 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
226
272
  },
227
273
  {
228
274
  type: 'string',
229
- name: 'description',
230
- header: i18next.t('field.description'),
275
+ name: 'packingType',
276
+ header: i18next.t('field.packing_type'),
231
277
  width: 100
232
278
  },
233
279
  {
234
- type: 'string',
235
- name: 'brand',
236
- header: i18next.t('field.brand'),
280
+ type: 'integer',
281
+ name: 'systemQty',
282
+ header: i18next.t('field.system_qty'),
237
283
  width: 100
238
284
  },
285
+ ...countColumns,
239
286
  {
240
287
  type: 'string',
241
- name: 'packingType',
242
- header: i18next.t('field.packing_type'),
288
+ name: 'finalCount',
289
+ header: i18next.t('field.final_count'),
243
290
  width: 100
244
291
  },
245
292
  {
246
- type: 'boolean',
247
- name: 'batchNoVariance',
248
- header: i18next.t('field.batch_no_variance'),
249
- width: 150,
250
- renderer: value => {
251
- return `<input type="checkbox" ${value ? 'checked' : ''} disabled/>`
252
- }
253
- },
254
- {
255
- type: 'boolean',
256
- name: 'expirationDateVariance',
257
- header: i18next.t('field.expiration_date_variance'),
258
- width: 150,
259
- renderer: value => {
260
- return `<input type="checkbox" ${value ? 'checked' : ''} disabled/>`
261
- }
262
- },
263
- {
264
- type: 'boolean',
265
- name: 'locationVariance',
266
- header: i18next.t('field.location_variance'),
267
- width: 150,
268
- renderer: value => {
269
- return `<input type="checkbox" ${value ? 'checked' : ''} disabled/>`
270
- }
293
+ type: 'string',
294
+ name: 'systemUomValue',
295
+ header: i18next.t('field.system_uom_value'),
296
+ width: 150
271
297
  },
298
+ ...uomValueColumns,
272
299
  {
273
- type: 'boolean',
274
- name: 'uomValueVariance',
275
- header: i18next.t('field.uom_value_variance'),
276
- width: 150,
277
- renderer: value => {
278
- return `<input type="checkbox" ${value ? 'checked' : ''} disabled/>`
279
- },
280
- hidden: this._enableCartonLabel
300
+ type: 'string',
301
+ name: 'finalUom',
302
+ header: i18next.t('field.final_uom_value'),
303
+ width: 150
281
304
  },
282
305
  {
283
306
  type: 'string',
@@ -285,25 +308,22 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
285
308
  header: i18next.t('field.uom'),
286
309
  width: 80
287
310
  },
288
- {
289
- type: 'integer',
290
- name: 'systemQty',
291
- header: i18next.t('field.system_qty'),
292
- width: 100
293
- },
294
- ...countColumns,
295
- {
296
- type: 'string',
297
- name: 'finalCount',
298
- header: i18next.t('field.final_count'),
299
- width: 100
300
- },
301
311
  {
302
312
  type: 'string',
303
313
  name: 'countVariance',
304
314
  header: i18next.t('field.count_variance'),
305
315
  width: 120
306
316
  },
317
+ {
318
+ type: 'boolean',
319
+ name: 'uomValueVariance',
320
+ header: i18next.t('field.uom_value_variance'),
321
+ width: 150,
322
+ renderer: value => {
323
+ return `<input type="checkbox" ${value ? 'checked' : ''} disabled/>`
324
+ },
325
+ hidden: this._enableCartonLabel
326
+ },
307
327
  {
308
328
  type: 'string',
309
329
  name: 'countStatus',
@@ -336,18 +356,27 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
336
356
  return this.shadowRoot.querySelector('form')
337
357
  }
338
358
 
339
- get grist() {
359
+ get dataGrist() {
340
360
  return this.shadowRoot.querySelector('data-grist')
341
361
  }
342
362
 
363
+ get searchForm() {
364
+ return this.shadowRoot.querySelector('search-form')
365
+ }
366
+
367
+ _clearView() {
368
+ this._orgInventoryAccuracy = null
369
+ }
370
+
343
371
  async fetchCycleCountReport() {
344
372
  if (!this._cycleCountNo) return
345
373
  let total
374
+ let filters = await this.searchForm.getQueryFilters()
346
375
  try {
347
376
  const response = await client.query({
348
377
  query: gql`
349
- query cycleCountReport($name: String!) {
350
- cycleCountReport(name: $name) {
378
+ query cycleCountReport($filters: [Filter], $pagination: Pagination, $sortings: [Sorting], $name: String!) {
379
+ cycleCountReport(filters: $filters, pagination: $pagination, sortings: $sortings, name: $name) {
351
380
  items {
352
381
  inventoryCheck {
353
382
  name
@@ -393,6 +422,7 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
393
422
  originLocationId
394
423
  inspectedLocationId
395
424
  countData
425
+ countUomData
396
426
  batchNoVariance
397
427
  locationVariance
398
428
  uomValueVariance
@@ -401,6 +431,7 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
401
431
  countStatus
402
432
  company
403
433
  finalCount
434
+ finalUom
404
435
  partnerDomainId
405
436
  }
406
437
  total
@@ -408,12 +439,15 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
408
439
  }
409
440
  `,
410
441
  variables: {
442
+ filters: filters,
443
+ pagination: null,
444
+ sortings: [],
411
445
  name: this._cycleCountNo
412
446
  }
413
447
  })
414
448
 
415
449
  if (!response.errors) {
416
- const firstItem = response.data.cycleCountReport.items[0]
450
+ const firstItem = response.data.cycleCountReport?.items[0] || this._firstItem
417
451
  if (!firstItem) return
418
452
 
419
453
  const {
@@ -422,6 +456,7 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
422
456
  partnerDomainId
423
457
  } = firstItem
424
458
 
459
+ this._firstItem = firstItem
425
460
  this._enableCartonLabel = await fetchSettingRule('enable-carton-label', partnerDomainId)
426
461
  await this.updateComplete
427
462
 
@@ -437,21 +472,35 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
437
472
 
438
473
  // Parsing countData from string to object & convert to int or replace with "-"
439
474
  let countData = JSON.parse(item.countData)
440
- Object.keys(countData).forEach(key => {
441
- if (key.startsWith('count ')) {
442
- countData[key] =
443
- !isNaN(parseFloat(countData[key])) && isFinite(countData[key]) ? parseInt(countData[key], 10) : '-'
444
- }
445
- })
446
- this._countData = countData
475
+ let countUomData = JSON.parse(item.countUomData)
476
+
477
+ const mapCountData = (data, prefix) => {
478
+ return Object.keys(data).reduce((acc, key) => {
479
+ if (key.startsWith(prefix)) {
480
+ acc[key] = !isNaN(parseFloat(data[key])) && isFinite(data[key]) ? parseFloat(data[key], 10) : '-'
481
+ }
482
+ return acc
483
+ }, {})
484
+ }
485
+
486
+ const findLatestCount = (data, prefix) => {
487
+ return [...Object.keys(data)]
488
+ .filter(key => key.startsWith(prefix) && data[key] !== '-')
489
+ .pop()
490
+ }
491
+
492
+ this._countData = mapCountData(countData, 'count')
493
+ this._countUomData = mapCountData(countUomData, 'uom count')
494
+
495
+ // Calculate the latest count key and finalCount
496
+ const latestCountKey = findLatestCount(this._countData, 'count ')
497
+ const latestUomCountKey = findLatestCount(this._countUomData, 'uom count ')
498
+
447
499
 
448
- // Calculate the latest count key and finalCount
449
- const latestCountKey = [...Object.keys(countData)]
450
- .filter(key => key.startsWith('count ') && countData[key] !== '-')
451
- .pop()
452
500
 
453
501
  // Calculate finalCount based on the latest count
454
- const finalCount = latestCountKey ? countData[latestCountKey] : item.systemQty
502
+ const finalCount = latestCountKey ? this._countData[latestCountKey] : item.systemQty
503
+ const finalUom = latestUomCountKey ? this._countUomData[latestUomCountKey] : item.systemUomValue
455
504
 
456
505
  // Calculate countVariance
457
506
  let countVariance = finalCount - item.systemQty
@@ -498,7 +547,8 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
498
547
  }
499
548
 
500
549
  return {
501
- ...countData,
550
+ ...this._countData,
551
+ ...this._countUomData,
502
552
  inventoryId,
503
553
  cartonId,
504
554
  palletId,
@@ -514,6 +564,7 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
514
564
  systemBatchNo: item.systemBatchNo,
515
565
  systemLocationName: item.systemLocationName,
516
566
  systemUomValue: item.systemUomValue,
567
+ finalUom: item.finalUom,
517
568
  originLocationId: item.originLocationId,
518
569
  originLocationName,
519
570
  inspectedLocationId: item.inspectedLocationId,
@@ -532,7 +583,8 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
532
583
  countVariance,
533
584
  countStatus,
534
585
  company: item.company,
535
- finalCount
586
+ finalCount,
587
+ finalUom
536
588
  }
537
589
  }) || []
538
590
 
@@ -540,12 +592,16 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
540
592
  const totalSKUInCycleCount = records.length
541
593
  const inventoryAccuracy = (totalSKUWithHIT / totalSKUInCycleCount) * 100
542
594
 
595
+ if (!this._orgInventoryAccuracy) {
596
+ this._orgInventoryAccuracy = inventoryAccuracy
597
+ }
598
+
543
599
  this._fillupForm({
544
600
  company,
545
601
  cycleCountNo: inventoryCheckName,
546
602
  executionDate,
547
603
  status,
548
- inventoryAccuracy: inventoryAccuracy.toFixed(2) + '%'
604
+ inventoryAccuracy: this._orgInventoryAccuracy.toFixed(2) + '%'
549
605
  })
550
606
 
551
607
  total = records.length
@@ -674,9 +730,6 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
674
730
  .pallet="${record.palletId}"
675
731
  .cycleCountNo="${this._cycleCountNo}"
676
732
  .enableCartonLabel="${this._enableCartonLabel}"
677
- @saved="${e => {
678
- this.dataGrist.fetch()
679
- }}"
680
733
  ></cycle-count-inventory-details-popup>
681
734
  `,
682
735
  {
@@ -716,18 +769,18 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
716
769
  { header: i18next.t('field.sku'), key: 'sku', width: 25, type: 'string' },
717
770
  { header: i18next.t('field.product'), key: 'productName', width: 60, type: 'string' },
718
771
  { header: i18next.t('field.product_description'), key: 'description', width: 60, type: 'string' },
719
- { header: i18next.t('field.brand'), key: 'brand', width: 20, type: 'string' },
720
772
  { header: i18next.t('field.packing_type'), key: 'packingType', width: 20, type: 'string' },
721
773
  { header: i18next.t('field.system_batch_no'), key: 'systemBatchNo', width: 25, type: 'string' },
722
774
  { header: i18next.t('field.inspected_batch_no'), key: 'inspectedBatchNo', width: 25, type: 'string' },
723
775
  { header: i18next.t('field.system_location'), key: 'systemLocationName', width: 25, type: 'string' },
724
776
  { header: i18next.t('field.inspected_location'), key: 'inspectedLocationName', width: 25, type: 'string' },
725
- { header: i18next.t('field.system_uom_value'), key: 'systemUomValue', width: 25, type: 'string' },
726
- { header: i18next.t('field.inspected_uom_value'), key: 'inspectedUomValue', width: 25, type: 'string' },
727
- { header: i18next.t('field.uom'), key: 'uom', width: 25, type: 'string' },
728
777
  { header: i18next.t('field.system_qty'), key: 'systemQty', width: 20, type: 'string' },
729
778
  { header: i18next.t('field.final_count'), key: 'finalCount', width: 20, type: 'string' },
779
+ { header: i18next.t('field.system_uom_value'), key: 'systemUomValue', width: 25, type: 'string' },
780
+ { header: i18next.t('field.final_uom_value'), key: 'finalUom', width: 25, type: 'string' },
781
+ { header: i18next.t('field.uom'), key: 'uom', width: 25, type: 'string' },
730
782
  { header: i18next.t('field.count_variance'), key: 'countVariance', width: 20, type: 'string' },
783
+ { header: i18next.t('field.uom_value_variance'), key: 'uomValueVariance', width: 20, type: 'string' },
731
784
  { header: i18next.t('field.count_status'), key: 'countStatus', width: 20, type: 'string' }
732
785
  ]
733
786
 
@@ -753,12 +806,33 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
753
806
  headerSetting.splice(indexToInsert + 1, 0, ...dynamicHeaders)
754
807
  }
755
808
 
809
+ const indexToInsertUOM = headerSetting.findIndex(header => header.key === 'finalUom')
810
+ if (indexToInsertUOM === -1) {
811
+ console.error('finalUom header not found in headerSetting')
812
+ return
813
+ }
814
+
815
+ const uomValueColumns = Object.keys(data[0] || {}).filter(
816
+ key => key.startsWith('count ') && data[0][key] !== null && data[0][key] !== undefined
817
+ )
818
+
819
+ const uomHeaders = uomValueColumns.map((column, index) => {
820
+ const inspectedValueKey = `uom count ${index + 1}`
821
+ return {
822
+ header: `UOM Value Count ${index + 1}`,
823
+ key: inspectedValueKey,
824
+ width: 25,
825
+ type: 'string'
826
+ }
827
+ })
828
+
829
+ headerSetting.splice(indexToInsertUOM, 0, ...uomHeaders)
830
+
756
831
  return { header: headerSetting, data }
757
832
  } catch (e) {
758
833
  this._showToast(e)
759
834
  }
760
835
  }
761
-
762
836
  async _exportInventoryAuditOverview() {
763
837
  try {
764
838
  let data = []
@@ -796,6 +870,22 @@ class CycleCountReport extends connect(store)(localize(i18next)(PageView)) {
796
870
  })
797
871
  )
798
872
  }
873
+
874
+ //to reset search-form values when exit page
875
+ resetSearchForm() {
876
+ const searchForm = this.shadowRoot.querySelector('#search-form')
877
+ if (searchForm) {
878
+ searchForm.formFields.forEach(field => {
879
+ if (field.type === 'checkbox') {
880
+ field.checked = false
881
+ field.removeAttribute('indeterminate')
882
+ field._value = undefined
883
+ } else {
884
+ field.value = ''
885
+ }
886
+ })
887
+ }
888
+ }
799
889
  }
800
890
 
801
891
  window.customElements.define('cycle-count-report', CycleCountReport)