@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.
Files changed (40) hide show
  1. package/client/pages/components/select-cc-product-popup.js +321 -0
  2. package/client/pages/constants/order.js +15 -0
  3. package/client/pages/inventory-check/add-extra-inventory-popup.js +306 -0
  4. package/client/pages/inventory-check/check-inventory-popup.js +183 -167
  5. package/client/pages/inventory-check/create-cycle-count.js +292 -141
  6. package/client/pages/inventory-check/cycle-count-inventory-details-popup.js +282 -0
  7. package/client/pages/inventory-check/cycle-count-recheck-popup.js +129 -31
  8. package/client/pages/inventory-check/cycle-count-report.js +425 -306
  9. package/client/pages/inventory-check/cycle-count-review.js +742 -0
  10. package/client/pages/inventory-check/cycle-count-worksheet-list.js +476 -0
  11. package/client/pages/inventory-check/inspecting-product.js +954 -1029
  12. package/client/pages/inventory-check/inventory-check-detail.js +378 -0
  13. package/client/pages/inventory-check/inventory-check-list.js +35 -109
  14. package/client/pages/inventory-check/relocate-inventory-popup.js +222 -0
  15. package/client/pages/inventory-check/search-popup.js +1 -1
  16. package/client/pages/inventory-check/select-cc-location-popup.js +230 -0
  17. package/client/pages/inventory-check/worksheet-cycle-count.js +112 -90
  18. package/client/pages/outbound/route-label-popup.js +16 -0
  19. package/client/route.js +8 -0
  20. package/dist-server/graphql/resolvers/reports/cycle-count-report.js +244 -0
  21. package/dist-server/graphql/resolvers/reports/cycle-count-report.js.map +1 -0
  22. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  23. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  24. package/dist-server/graphql/types/reports/cycle-count-report-list.js +14 -0
  25. package/dist-server/graphql/types/reports/cycle-count-report-list.js.map +1 -0
  26. package/dist-server/graphql/types/reports/cycle-count-report.js +25 -0
  27. package/dist-server/graphql/types/reports/cycle-count-report.js.map +1 -0
  28. package/dist-server/graphql/types/reports/index.js +5 -0
  29. package/dist-server/graphql/types/reports/index.js.map +1 -1
  30. package/package.json +6 -6
  31. package/server/graphql/resolvers/reports/cycle-count-report.ts +267 -0
  32. package/server/graphql/resolvers/reports/index.ts +3 -4
  33. package/server/graphql/types/reports/cycle-count-report-list.ts +8 -0
  34. package/server/graphql/types/reports/cycle-count-report.ts +19 -0
  35. package/server/graphql/types/reports/index.ts +7 -8
  36. package/things-factory.config.js +8 -0
  37. package/translations/en.json +34 -0
  38. package/translations/ko.json +34 -0
  39. package/translations/ms.json +35 -1
  40. package/translations/zh.json +37 -3
@@ -1,124 +1,128 @@
1
1
  import '@things-factory/barcode-ui'
2
2
  import '@things-factory/grist-ui'
3
3
  import './check-inventory-popup'
4
+ import './relocate-inventory-popup'
5
+ import './add-extra-inventory-popup'
4
6
 
5
7
  import gql from 'graphql-tag'
6
- import {
7
- css,
8
- html
9
- } from 'lit-element'
8
+ import { css, html } from 'lit-element'
10
9
  import { connect } from 'pwa-helpers/connect-mixin.js'
11
10
 
12
- import {
13
- MultiColumnFormStyles,
14
- SingleColumnFormStyles
15
- } from '@things-factory/form-ui'
16
- import {
17
- i18next,
18
- localize
19
- } from '@things-factory/i18n-base'
11
+ import { sleep } from '@operato/utils'
12
+ import { MultiColumnFormStyles } from '@things-factory/form-ui'
13
+ import { i18next, localize } from '@things-factory/i18n-base'
20
14
  import { openPopup } from '@things-factory/layout-base'
21
- import {
22
- client,
23
- CustomAlert,
24
- PageView,
25
- store,
26
- UPDATE_CONTEXT
27
- } from '@things-factory/shell'
15
+ import { client, CustomAlert, PageView, store, UPDATE_CONTEXT } from '@things-factory/shell'
28
16
  import { CommonButtonStyles } from '@things-factory/styles'
29
- import { isMobileDevice } from '@things-factory/utils'
30
17
 
31
18
  import { fetchLocationSortingRule } from '../../fetch-location-sorting-rule'
32
19
  import { fetchSettingRule } from '../../fetch-setting-value'
33
- import {
34
- LOCATION_SORTING_RULE,
35
- ORDER_INVENTORY_STATUS,
36
- ORDER_TYPES,
37
- WORKSHEET_STATUS
38
- } from '../constants'
39
-
40
- const VIEW_TYPE = {
41
- LOCATION_SELECTED: 'LOCATION_SELECTED',
42
- INVENTORY_SELECTED: 'INVENTORY_SELECTED',
43
- MISSING_PALLET_SELECTED: 'MISSING_PALLET_SELECTED'
44
- }
20
+ import { LOCATION_SORTING_RULE, INVENTORY_CHECK_ITEM_STATUS } from '../constants'
21
+ import { showToast } from '../../util/index'
45
22
 
46
23
  class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
47
24
  static get properties() {
48
25
  return {
49
26
  cycleCountNo: String,
50
- locationConfig: Object,
51
- locationData: Object,
52
- inventoryConfig: Object,
53
- inventoryData: Object,
54
- selectedLocation: Object,
55
- selectedInventory: Object,
56
- viewType: String,
27
+ countNo: Number,
57
28
  isReleasing: Boolean,
58
- missingInventoryConfig: Object,
59
- missingInventoryData: Object,
60
- formattedLocations: Array,
61
29
  _hideCCColumnSetting: Boolean,
62
- warehouses: Array,
63
- zones: Array,
64
- rows: Array,
65
- columns: Array
30
+ _currentCard: Object,
31
+ _incompleteInspection: Boolean,
32
+ _editMode: Object,
33
+ _editedCard: Object,
34
+ _pageSettings: Object,
35
+ _enableCartonLabel: Boolean,
36
+ bizplaceId: String
66
37
  }
67
38
  }
68
39
 
69
40
  static get styles() {
70
41
  return [
71
- SingleColumnFormStyles,
72
42
  MultiColumnFormStyles,
73
43
  css`
74
44
  :host {
75
45
  display: flex;
76
46
  flex-direction: column;
77
- }
78
- .grist {
79
- background-color: var(--main-section-background-color);
80
- display: flex;
81
- flex: 1;
82
47
  overflow: auto;
48
+ background-color: #22a6a7;
83
49
  }
84
- .left-column {
85
- flex: 1;
86
- overflow: auto;
87
- display: flex;
88
- flex-direction: column;
50
+ [product-card] {
51
+ background: linear-gradient(rgb(243, 247, 251), 20%, rgb(255, 255, 255));
52
+ box-shadow: var(--box-shadow);
53
+ display: grid;
54
+ gap: 5px 15px;
55
+ clear: both;
56
+ border-style: solid;
57
+ border-width: thin;
58
+ border-color: rgb(34, 166, 167);
59
+ border-radius: var(--border-radius);
60
+ padding: 5px;
61
+ font-family: var(--subtitle-font);
62
+ font-weight: bold;
63
+ color: rgb(49, 90, 118);
64
+ text-align: left;
89
65
  }
90
- .right-column {
91
- flex: 1;
92
- overflow: auto;
93
- display: flex;
94
- flex-direction: column;
66
+ [button-space] {
67
+ margin: 5px;
68
+ padding: var(--padding-narrow);
95
69
  }
96
- .right-column > div#input-form-container {
97
- flex: 1;
70
+ .button-container {
71
+ padding: var(--button-container-padding);
72
+ margin: var(--button-container-margin);
73
+ text-align: var(--button-container-align);
74
+ background-color: var(--button-container-background);
75
+ height: var(--button-container-height);
98
76
  }
99
- data-grist {
100
- flex: 1;
77
+ .white-color-button {
78
+ --mdc-theme-primary: #f3f7fb;
79
+ --mdc-theme-on-primary: #007f7e;
80
+ --mdc-button-disabled-fill-color: #e0e0e0;
81
+ --mdc-button-disabled-ink-color: #a6a4a2;
82
+ }
83
+ .card-header {
84
+ margin-bottom: 0;
85
+ padding-bottom: 0;
86
+ text-align: center;
101
87
  }
102
- h2 {
103
- padding: var(--subtitle-padding);
104
- font: var(--subtitle-font);
105
- color: var(--subtitle-text-color);
106
- border-bottom: var(--subtitle-border-bottom);
88
+ .card-text-bold {
89
+ font-family: var(--subtitle-font);
90
+ font-weight: bold;
91
+ color: #315a76;
107
92
  }
108
- .grist h2 {
109
- margin: var(--grist-title-margin);
110
- border: var(--grist-title-border);
111
- font: var(--grist-title-font);
112
- color: var(--secondary-color);
93
+ .missing-stock-notification {
94
+ font-family: var(--subtitle-font);
95
+ font-weight: bold;
96
+ color: #dc4649;
113
97
  }
114
- .grist h2 mwc-icon {
98
+ data-grist {
99
+ overflow: auto;
100
+ flex: 1;
101
+ }
102
+ legend mwc-icon {
115
103
  vertical-align: middle;
116
104
  margin: var(--grist-title-icon-margin);
117
105
  font-size: var(--grist-title-icon-size);
118
106
  color: var(--grist-title-icon-color);
107
+ cursor: pointer;
119
108
  }
120
- h2 + data-grist {
121
- padding-top: var(--grist-title-with-grid-padding);
109
+ .content-container {
110
+ background-color: #ffffff;
111
+ height: 100%;
112
+ text-align: center;
113
+ border-radius: 5px;
114
+ padding: 5px;
115
+ }
116
+ .content-header {
117
+ margin: 5px;
118
+ border-bottom: 1px solid rgb(34, 166, 167);
119
+ font-weight: bold;
120
+ font-size: large;
121
+ color: rgb(49, 90, 118);
122
+ }
123
+ .input-font {
124
+ font-weight: normal;
125
+ font-size: 16px;
122
126
  }
123
127
  `
124
128
  ]
@@ -126,10 +130,10 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
126
130
 
127
131
  render() {
128
132
  return html`
129
- <form id="info-form" class="multi-column-form">
130
- <fieldset>
131
- <legend>${i18next.t('title.scan_area')}</legend>
132
- <label>${i18next.t('label.inventory_check_no')}</label>
133
+ <!-- Cycle Count number field -->
134
+ <div>
135
+ <form id="info-form" class="multi-column-form">
136
+ <label style="color: #ffffff;">${i18next.t('label.inventory_check_no')}</label>
133
137
  <barcode-scanable-input
134
138
  name="cycleCountNo"
135
139
  custom-input
@@ -145,124 +149,245 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
145
149
  }
146
150
  }}"
147
151
  ></barcode-scanable-input>
148
- </fieldset>
149
- <fieldset>
150
- <legend>
151
- ${`${i18next.t('title.inventory_inspection')} ${`: ${this.cycleCountNo ? this.cycleCountNo : ''}`}`}
152
- </legend>
153
- <label>${i18next.t('label.company')}</label>
154
- <input name="bizplace" readonly />
155
- <label>${i18next.t('label.started_at')}</label>
156
- <input name="startedAt" type="datetime-local" readonly />
157
- </fieldset>
158
- </form>
159
- <div class="grist">
160
- <div class="left-column">
161
- <form id="condition-form" class="multi-column-form" @change="${this.fillUpGrist.bind(this)}">
162
- <fieldset>
163
- <label>${i18next.t('field.w/h')}</label>
164
- <select
165
- name="warehouse"
166
- .disabled="${!this.formattedLocations?.length}"
167
- @change="${this.resetLocation.bind(this)}"
168
- >
169
- <option></option>
170
- ${this.warehouses.map(warehouse => html` <option>${warehouse}</option> `)}
171
- </select>
172
- <label>${i18next.t('field.zone')}</label>
173
- <select name="zone" .disabled="${!this.formattedLocations?.length}">
174
- <option></option>
175
- ${this.zones.map(zone => html`<option>${zone}</option>`)}
176
- </select>
177
- <label>${i18next.t('field.row')}</label>
178
- <select name="row" .disabled="${!this.formattedLocations?.length}">
179
- <option selected></option>
180
- ${this.rows.map(row => html`<option ?selected="${row === this.selectedRow}">${row}</option>`)}
181
- </select>
182
- <label>${i18next.t('field.column')}</label>
183
- <select name="column" .disabled="${!this.formattedLocations?.length}">
184
- <option selected></option>
185
- ${this.columns.map(
186
- column => html`<option ?selected="${column === this.selectedColumn}">${column}</option>`
187
- )}
188
- </select>
189
- </fieldset>
190
- </form>
191
- <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.location')}</h2>
192
- <data-grist
193
- id="location-grist"
194
- .mode="${isMobileDevice() ? 'LIST' : 'GRID'}"
195
- .config="${this.locationConfig}"
196
- .data="${this.locationData}"
197
- ></data-grist>
198
- <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.inventories')}</h2>
199
- <data-grist
200
- id="inventory-grist"
201
- .mode="${isMobileDevice() ? 'LIST' : 'GRID'}"
202
- .config="${this.inventoryConfig}"
203
- .data="${this.inventoryData}"
204
- ></data-grist>
152
+
153
+ <!-- search fields -->
154
+ <label style="color: #ffffff">${i18next.t('label.location')}</label>
155
+ <barcode-scanable-input
156
+ name="locationName"
157
+ custom-input
158
+ ?scan-only=${this._pageSettings?.cameraScanOnly}
159
+ @keypress="${async e => {
160
+ if (e.keyCode === 13) {
161
+ e.preventDefault()
162
+ const filters = {
163
+ locationName: this.locationNameInput?.value || null,
164
+ cartonId: this._enableCartonLabel ? this.cartonIdInput?.value : null,
165
+ palletId: !this._enableCartonLabel ? this.palletIdInput?.value : null
166
+ }
167
+ const matchedItem = await this.fetchOrFilterItem(filters)
168
+ if (matchedItem) {
169
+ this.updateInventoryState(matchedItem)
170
+ }
171
+ this.pageUpdated()
172
+ this.updateContext()
173
+ }
174
+ }}"
175
+ ></barcode-scanable-input>
176
+
177
+ ${
178
+ this._enableCartonLabel
179
+ ? html`
180
+ <label style="color: #ffffff">${i18next.t('label.carton_id')}</label>
181
+ <barcode-scanable-input
182
+ name="cartonId"
183
+ custom-input
184
+ ?scan-only=${this._pageSettings?.cameraScanOnly}
185
+ @keypress="${async e => {
186
+ if (e.keyCode === 13) {
187
+ e.preventDefault()
188
+ const filters = {
189
+ cartonId: this.cartonIdInput?.value || null,
190
+ locationName: this.locationNameInput?.value || null,
191
+ palletId: !this._enableCartonLabel ? this.palletIdInput?.value : null
192
+ }
193
+ const matchedItem = await this.fetchOrFilterItem(filters)
194
+ if (matchedItem) {
195
+ this.updateInventoryState(matchedItem)
196
+ }
197
+ this.pageUpdated()
198
+ this.updateContext()
199
+ }
200
+ }}"
201
+ ></barcode-scanable-input>
202
+ `
203
+ : html`
204
+ <label style="color: #ffffff">${i18next.t('label.lot_id')}</label>
205
+ <barcode-scanable-input
206
+ name="palletId"
207
+ custom-input
208
+ ?scan-only=${this._pageSettings?.cameraScanOnly}
209
+ @keypress="${async e => {
210
+ if (e.keyCode === 13) {
211
+ e.preventDefault()
212
+ const filters = {
213
+ palletId: !this._enableCartonLabel ? this.palletIdInput?.value : null,
214
+ cartonId: this.cartonIdInput?.value || null,
215
+ locationName: this.locationNameInput?.value || null
216
+ }
217
+ const matchedItem = await this.fetchOrFilterItem(filters)
218
+ if (matchedItem) {
219
+ this.updateInventoryState(matchedItem)
220
+ }
221
+ this.pageUpdated()
222
+ this.updateContext()
223
+ }
224
+ }}"
225
+ ></barcode-scanable-input>
226
+ `
227
+ }
228
+ </form>
229
+ </div>
230
+
231
+ <!-- Inventory Check title for product card -->
232
+ <div class="content-container">
233
+ <div class="content-header" >
234
+ <label>
235
+ ${`${i18next.t('title.inventory_check_no')}${`: ${this.cycleCountNo ? this.cycleCountNo : ''}`}`}
236
+ </label>
237
+ </div>
238
+ <div>
239
+ <!--checked inventory-->
240
+ <label class="card-header">
241
+ <font class="card-text-bold"
242
+ >${i18next.t('label.checked_inventory')}
243
+ ${this._currentCard.checkedInventoryCount || '0'}/${this._currentCard.totalItems || '0'}</font>
244
+ </label><br/>
245
+ <!--checkbox -->
246
+ <label class="card-header">
247
+ ${
248
+ this._currentCard.checked
249
+ ? html`<input type="checkbox" disabled="disabled" checked /><br />`
250
+ : html`<input type="checkbox" disabled="disabled" /><br />`
251
+ }
252
+ </label>
205
253
  </div>
206
- <div class="right-column">
207
- <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.missing_pallets')}</h2>
208
- <data-grist
209
- id="missing-inventory-grist"
210
- .mode="${isMobileDevice() ? 'LIST' : 'GRID'}"
211
- .config="${this.missingInventoryConfig}"
212
- .data="${this.missingInventoryData}"
213
- ></data-grist>
214
- <div id="input-form-container">
215
- <form
216
- id="input-form"
217
- class="single-column-form"
218
- @keypress="${e => {
219
- if (e.keyCode === 13) {
220
- if (!this.selectedInventory) {
221
- this.addExtraPallet()
222
- } else if (!this.selectedInventory.completed) {
223
- this.submitInventoryCheck()
254
+ <!-- product-card -->
255
+ <div product-card id="form">
256
+ <form id="input-form" class="single-column-form">
257
+ <label>${i18next.t('label.location')}</label><br />
258
+ <label class="input-font">${this._currentCard.locationName}</label><br />
259
+ <!-- validation lot id, carton id -->
260
+ ${
261
+ this._enableCartonLabel
262
+ ? html` <label>${i18next.t('label.carton_id')}</label>
263
+ <br /><label class="input-font">${this._currentCard.cartonId}</label>`
264
+ : html` <label>${i18next.t('label.lot_id')}</label>
265
+ <br /><label class="input-font">${this._currentCard.palletId}</label>`
266
+ }
267
+ <br />
268
+ <label>${i18next.t('label.sku')}</label>
269
+ <br />
270
+ <label class="input-font">${this._currentCard.productSku}</label>
271
+ <br />
272
+ <label>${i18next.t('label.product')}</label>
273
+ <br />
274
+ <label class="input-font">${this._currentCard.productName}</label>
275
+ <br />
276
+ <label>${i18next.t('label.packing_type')}</label>
277
+ <br />
278
+ <label class="input-font">${this._currentCard.packingType}</label>
279
+ <br />
280
+ <label>${i18next.t('label.release_qty')}</label>
281
+ <br />
282
+ <label class="input-font">${this._currentCard.lockedQty}</label>
283
+ <br />
284
+ <label>${i18next.t('label.status')}</label>
285
+ <br />
286
+ <label class="input-font">${this._currentCard.inventoryCheckItemStatus}</label>
287
+ <br />
288
+ ${
289
+ this._currentCard.inventoryCheckItemStatus == 'RELOCATED' ||
290
+ this._currentCard.inventoryCheckItemStatus == 'ADDED'
291
+ ? html`
292
+ <label>${`${i18next.t('label.inspected_location')}: `}</label>
293
+ <br />
294
+ <label class="input-font">${this._currentCard.inspectedLocation}</label>
295
+ <br />
296
+ `
297
+ : ''
298
+ }
299
+ <label>${i18next.t('label.inspected_batch_no')}
300
+ </label>
301
+ <br />
302
+ <span class="input-font" ?hidden=${this._editMode.inspectedBatchNo}>${
303
+ this._currentCard.inspectedBatchNo
304
+ }
305
+ <mwc-icon-button
306
+ icon="edit"
307
+ align="end"
308
+ @click=${() => this._enableEditMode('inspectedBatchNo')}
309
+ ></mwc-icon-button>
310
+ </span>
311
+ <span ?hidden=${!this._editMode.inspectedBatchNo}>
312
+ <input
313
+ type="text"
314
+ .value=${this._editedCard.inspectedBatchNo}
315
+ @input=${e => this._handleEditInput('inspectedBatchNo', e.target.value)}
316
+ />
317
+ <mwc-icon-button icon="save" @click=${() => this._saveEdit('inspectedBatchNo')}></mwc-icon-button>
318
+ <mwc-icon-button
319
+ icon="cancel"
320
+ @click=${() => this._disableEditMode('inspectedBatchNo')}
321
+ ></mwc-icon-button>
322
+ </span>
323
+ <br />
324
+ <label>${i18next.t('label.inspected_qty')}
325
+ </label>
326
+ <br />
327
+ <span class="input-font" ?hidden=${this._editMode.inspectedQty}>
328
+ ${this._currentCard.inspectedQty}
329
+ <mwc-icon-button
330
+ icon="edit"
331
+ align="end"
332
+ @click=${() => this._enableEditMode('inspectedQty')}
333
+ ></mwc-icon-button>
334
+ </span>
335
+ <span ?hidden=${!this._editMode.inspectedQty}>
336
+ <input type="text"
337
+ .value=${this._editedCard.inspectedQty}
338
+ @input=${e => this._handleEditInput('inspectedQty', e.target.value)}
339
+ />
340
+ <mwc-icon-button icon="save" @click=${() => this._saveEdit('inspectedQty')}></mwc-icon-button>
341
+ <mwc-icon-button
342
+ icon="cancel"
343
+ @click=${() => this._disableEditMode('inspectedQty')}
344
+ ></mwc-icon-button>
345
+ </span>
346
+ <br />
347
+ ${
348
+ !this._enableCartonLabel
349
+ ? html`
350
+ <label>${i18next.t('label.inspected_uom_value')} </label>
351
+ <br />
352
+ <span class="input-font" ?hidden=${this._editMode.inspectedUomValue}>
353
+ ${this._currentCard.inspectedUomValue}
354
+ <mwc-icon-button
355
+ icon="edit"
356
+ align="end"
357
+ @click=${() => this._enableEditMode('inspectedUomValue')}
358
+ ></mwc-icon-button>
359
+ </span>
360
+ <span ?hidden=${!this._editMode.inspectedUomValue}>
361
+ <input
362
+ class="input-font"
363
+ type="text"
364
+ .value=${this._editedCard.inspectedUomValue}
365
+ @input=${e => this._handleEditInput('inspectedUomValue', e.target.value)}
366
+ />
367
+ <mwc-icon-button
368
+ icon="save"
369
+ @click=${() => this._saveEdit('inspectedUomValue')}
370
+ ></mwc-icon-button>
371
+ <mwc-icon-button
372
+ icon="cancel"
373
+ @click=${() => this._disableEditMode('inspectedUomValue')}
374
+ ></mwc-icon-button>
375
+ </span>
376
+ `
377
+ : ''
224
378
  }
225
- }
226
- }}"
227
- >
228
- <fieldset>
229
- <legend>
230
- ${i18next.t('field.inventory')}:
231
- ${this.selectedInventory?.productName ? this.selectedInventory.productName : ''}
232
- (${this.selectedInventory?.productDescription ? this.selectedInventory.productDescription : ''})
233
- </legend>
234
- <label>${i18next.t('field.lot_id')}</label>
235
- ${this.viewType === VIEW_TYPE.INVENTORY_SELECTED || this.viewType === VIEW_TYPE.MISSING_PALLET_SELECTED
236
- ? html` <input name="palletId" readonly .value="${this.selectedInventory?.palletId || ''}" /> `
237
- : html` <barcode-scanable-input name="palletId" custom-input></barcode-scanable-input>`}
238
- <label>${i18next.t('label.inspected_batch_no')}</label>
239
- <input name="inspectedBatchNo" .value="${this.selectedInventory?.batchId || ''}" />
240
- <label>${i18next.t('label.inspected_qty')}</label>
241
- <input
242
- name="inspectedQty"
243
- type="number"
244
- .value="${this._hideCCColumnSetting
245
- ? this.selectedInventory?.inspectedQty || ''
246
- : this.selectedInventory?.inspectedQty || this.selectedInventory?.qty || ''}"
247
- />
248
- <label>${i18next.t('label.inspected_uom_value')}</label>
249
- <input
250
- name="inspectedUomValue"
251
- type="number"
252
- step=".01"
253
- .value="${this._hideCCColumnSetting
254
- ? this.selectedInventory?.inspectedUomValue || ''
255
- : this.selectedInventory?.inspectedUomValue || this.selectedInventory?.uomValue || ''}"
256
- />
257
- <label>${i18next.t('label.uom')}</label>
258
- <input name="uom" .value="${this.selectedInventory?.uom || ''}" readonly />
259
- <label>${i18next.t('field.location')}</label>
260
- ${this.viewType === VIEW_TYPE.INVENTORY_SELECTED
261
- ? html` <input name="location" readonly .value="${this.selectedLocation?.name || ''}" /> `
262
- : html` <barcode-scanable-input name="location" custom-input></barcode-scanable-input>`}
263
- </fieldset>
264
379
  </form>
265
380
  </div>
381
+ <div button-space>
382
+ <mwc-button
383
+ @click=${e => this.previousCard(e)}
384
+ ?disabled=${this._disablePrevious}
385
+ raised
386
+ label="<"
387
+ ></mwc-button>
388
+ <span>${this._currentCard.currentPage || '0'}/${this._currentCard.totalPages || '0'}</span>
389
+ <mwc-button @click=${e => this.nextCard(e)} ?disabled=${this._disableNext} raised label=">"></mwc-button>
390
+ </div>
266
391
  </div>
267
392
  </div>
268
393
  `
@@ -271,15 +396,26 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
271
396
  constructor() {
272
397
  super()
273
398
  this.isReleasing = false
399
+ this.locationSortingRules = []
274
400
  this._hideCCColumnSetting = false
275
- this.locationData = { records: [] }
276
- this.inventoryData = { records: [] }
277
- this.formattedLocations = []
278
- this.warehouses = []
279
- this.zones = []
280
- this.rows = []
281
- this.columns = []
282
- this.selectedLocation = { records: [] }
401
+ this._selectedInventoryCheckItem = null
402
+ this.data = { records: [] }
403
+ this._enableCartonLabel = false
404
+ this._currentCard = {
405
+ checkedInventoryCount: 0
406
+ }
407
+ this._editMode = {
408
+ inspectedBatchNo: false,
409
+ inspectedQty: false,
410
+ inspectedUomValue: false
411
+ }
412
+ this._editedCard = {}
413
+ this._arrayIndex = 0
414
+ this.itemsPerPage = 1
415
+ this.totalItems = 0
416
+ this.totalPages = Math.ceil(this.totalItems / this.itemsPerPage)
417
+ this.currentPage = Math.floor(this._arrayIndex / this.itemsPerPage) + 1
418
+ this._incompleteInspection = true
283
419
  }
284
420
 
285
421
  get context() {
@@ -297,50 +433,20 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
297
433
  return this.renderRoot.querySelector('form#input-form')
298
434
  }
299
435
 
300
- get conditionForm() {
301
- return this.renderRoot.querySelector('form#condition-form')
302
- }
303
-
304
- get warehouseSelector() {
305
- return this.conditionForm.querySelector('select[name=warehouse]')
306
- }
307
-
308
- get zoneSelector() {
309
- return this.conditionForm.querySelector('select[name=zone]')
310
- }
311
-
312
- get rowSelector() {
313
- return this.conditionForm.querySelector('select[name=row]')
314
- }
315
-
316
- get columnSelector() {
317
- return this.conditionForm.querySelector('select[name=column]')
318
- }
319
-
320
436
  get cycleCountNoInput() {
321
437
  return this.renderRoot.querySelector('barcode-scanable-input[name=cycleCountNo]').renderRoot.querySelector('input')
322
438
  }
323
439
 
324
- get palletIdInput() {
325
- if (this.viewType === VIEW_TYPE.INVENTORY_SELECTED || this.viewType === VIEW_TYPE.MISSING_PALLET_SELECTED) {
326
- return this.renderRoot.querySelector('input[name=palletId]')
327
- } else {
328
- return this.renderRoot.querySelector('barcode-scanable-input[name=palletId]').renderRoot.querySelector('input')
329
- }
440
+ get locationNameInput() {
441
+ return this.renderRoot.querySelector('barcode-scanable-input[name=locationName]')?.renderRoot.querySelector('input')
330
442
  }
331
443
 
332
- get locationInput() {
333
- // if (this.viewType === VIEW_TYPE.INVENTORY_SELECTED) {
334
- // return this.renderRoot.querySelector('input[name=location]')
335
- // } else {
336
- // return this.renderRoot.querySelector('barcode-scanable-input[name=location]').renderRoot.querySelector('input')
337
- // }
444
+ get cartonIdInput() {
445
+ return this.renderRoot.querySelector('barcode-scanable-input[name=cartonId]')?.renderRoot.querySelector('input')
446
+ }
338
447
 
339
- if (this.renderRoot?.querySelector('barcode-scanable-input[name=location]')) {
340
- return this.renderRoot.querySelector('barcode-scanable-input[name=location]').renderRoot.querySelector('input')
341
- } else {
342
- return this.renderRoot.querySelector('input[name=location]')
343
- }
448
+ get palletIdInput() {
449
+ return this.renderRoot.querySelector('barcode-scanable-input[name=palletId]')?.renderRoot.querySelector('input')
344
450
  }
345
451
 
346
452
  get inspectedBatchNoInput() {
@@ -364,146 +470,70 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
364
470
  }
365
471
 
366
472
  async pageInitialized() {
367
- this.locationSortingRules = await fetchLocationSortingRule(LOCATION_SORTING_RULE.INSPECTING_PRODUCT.value)
368
-
369
- this.locationConfig = {
370
- pagination: { infinite: true },
371
- rows: {
372
- appendable: false,
373
- handlers: {
374
- click: async (columns, data, column, record, rowIndex) => {
375
- if (!this.selectedLocation?.id !== record.id) {
376
- this.selectedInventory = null
377
- this.selectedLocation = record
378
- this.inventoryData = { records: this.selectedLocation.inventories }
379
- this.viewType = VIEW_TYPE.LOCATION_SELECTED
380
- this.updateContext(this.viewType)
381
- await this.updateComplete
382
- this.selectOnInput(this.palletIdInput)
383
- }
384
- }
385
- }
386
- },
387
- list: { fields: ['completed', 'name', 'palletQty'] },
388
- columns: [
389
- { type: 'gutter', gutterName: 'sequence' },
390
- { type: 'boolean', name: 'completed', header: i18next.t('button.completed'), width: 80 },
391
- { type: 'string', name: 'name', header: i18next.t('field.name'), width: 150 },
392
- {
393
- type: 'integer',
394
- name: 'palletQty',
395
- header: i18next.t('field.pallet_qty'),
396
- width: 80
397
- }
398
- ]
399
- }
473
+ const [locationSortingTask, cameraScanOnly, enableCarton] = [
474
+ fetchLocationSortingRule(LOCATION_SORTING_RULE.INSPECTING_PRODUCT.value),
475
+ fetchSettingRule('camera-scan-only'),
476
+ fetchSettingRule('enable-carton-label')
477
+ ]
400
478
 
401
- this.inventoryConfig = {
402
- pagination: { infinite: true },
403
- rows: {
404
- appendable: false,
405
- handlers: {
406
- click: async (columns, data, column, record, rowIndex) => {
407
- if (!this.selectedInventory?.id !== record.id) {
408
- this.selectedInventory = record
409
- this.locationInput.value = this.selectedLocation.name
410
- this.viewType = VIEW_TYPE.INVENTORY_SELECTED
411
- await this.checkOrderInventory()
412
- this.updateContext(this.viewType)
413
- await this.updateComplete
414
- this.selectOnInput(this.inspectedBatchNoInput)
415
- }
416
- }
417
- }
418
- },
419
- list: {
420
- fields: [
421
- 'completed',
422
- 'palletId',
423
- 'batchId',
424
- 'inspectedBatchNo',
425
- 'qty',
426
- 'inspectedQty',
427
- 'uom',
428
- 'uomValue',
429
- 'inspectedUomValue',
430
- 'inspectedLocation',
431
- 'orderInventoryStatus'
432
- ]
433
- },
434
- columns: [
435
- { type: 'gutter', gutterName: 'sequence' },
436
- { type: 'boolean', name: 'completed', header: i18next.t('button.completed'), width: 80 },
437
- { type: 'string', name: 'palletId', header: i18next.t('label.lot_id'), width: 160 },
438
- { type: 'string', name: 'batchId', header: i18next.t('label.batch_id'), width: 120 },
439
- {
440
- type: 'string',
441
- name: 'orderInventoryStatus',
442
- header: i18next.t('label.status'),
443
- width: 100
444
- },
445
- {
446
- type: 'string',
447
- name: 'inspectedBatchNo',
448
- header: i18next.t('label.inspected_batch_no'),
449
- width: 100
450
- },
451
- {
452
- type: 'integer',
453
- name: 'inspectedQty',
454
- header: i18next.t('label.inspected_qty'),
455
- width: 100
456
- },
457
- {
458
- type: 'float',
459
- name: 'inspectedUomValue',
460
- header: i18next.t('label.inspected_uom_value'),
461
- width: 100
462
- },
463
- {
464
- type: 'object',
465
- name: 'inspectedLocation',
466
- header: i18next.t('label.inspected_location'),
467
- width: 100
468
- }
469
- ]
470
- }
479
+ this.locationSortingRules = await locationSortingTask
471
480
 
472
- const missingInventoryColumns = ['sequence', 'palletId', 'batchId', 'uom']
473
- this.missingInventoryConfig = {
474
- pagination: { infinite: true },
475
- rows: {
476
- appendable: false,
477
- handlers: {
478
- click: async (columns, data, column, record, rowIndex) => {
479
- if (!this.selectedInventory?.id !== record.id) {
480
- this.selectedInventory = record
481
- this.viewType = VIEW_TYPE.MISSING_PALLET_SELECTED
482
- this.selectOnInput(this.inspectedBatchNoInput)
483
- this.updateContext(this.viewType)
484
- }
485
- }
486
- }
487
- },
488
- list: { fields: missingInventoryColumns },
489
- columns: this.inventoryConfig.columns.filter(
490
- col => missingInventoryColumns.indexOf(col.name ? col.name : col.gutterName) >= 0
491
- )
481
+ this._pageSettings = {
482
+ ...this._pageSettings,
483
+ cameraScanOnly: (await cameraScanOnly) || false,
484
+ enableCarton: (await enableCarton) || false
492
485
  }
486
+
487
+ this.updateContext()
493
488
  }
494
489
 
495
490
  pageUpdated() {
496
491
  if (this.active) {
497
- this.selectOnInput(this.cycleCountNoInput)
492
+ if (this.cycleCountNo) {
493
+ if (this._arrayIndex < this.data.records.length) {
494
+ this._disableNext = false
495
+ this._disablePrevious = false
496
+ if (this.data.records.length - 1 == this._arrayIndex) {
497
+ this._disableNext = true
498
+ this._disablePrevious = false
499
+ }
500
+ }
501
+ if (this._arrayIndex == 0) {
502
+ this._disablePrevious = true
503
+ this._disableNext = false
504
+ }
505
+ if (this.data.records.length == 1) {
506
+ this._disableNext = true
507
+ this._disablePrevious = true
508
+ }
509
+ this.selectOnInput(this.cycleCountNoInput)
510
+
511
+ this._currentCard = this.data.records[this._arrayIndex] ? this.data.records[this._arrayIndex] : {}
512
+
513
+ const currentStatus = this._currentCard.wsdStatus
514
+ this._incompleteInspection = currentStatus !== 'INSPECTED' && currentStatus !== 'NOT TALLY'
515
+ this.updateCurrentCard()
516
+
517
+ this.calculateCheckedInventoryCount()
518
+ this.updateContext()
519
+ }
498
520
  }
499
521
  }
500
522
 
501
523
  async fetchCycleCountWorksheet() {
502
- const response = await client.query({
503
- query: gql`
504
- query cycleCountWorksheet($inventoryCheckNo: String!, $locationSortingRules: [Sorting]) {
505
- cycleCountWorksheet(inventoryCheckNo: $inventoryCheckNo, locationSortingRules: $locationSortingRules) {
524
+ try {
525
+ const isCartonEnabled = this._pageSettings?.enableCarton
526
+ const worksheetQuery = isCartonEnabled ? 'cycleCountWorksheetForCarton' : 'cycleCountWorksheetForPallet'
527
+
528
+ const response = await client.query({
529
+ query: gql`
530
+ query ${worksheetQuery}($inventoryCheckNo: String!, $locationSortingRules: [Sorting]) {
531
+ ${worksheetQuery}(
532
+ inventoryCheckNo: $inventoryCheckNo
533
+ locationSortingRules: $locationSortingRules
534
+ ) {
506
535
  worksheetInfo {
536
+ status
507
537
  startedAt
508
538
  bizplace {
509
539
  id
@@ -514,9 +544,11 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
514
544
  }
515
545
  worksheetDetailInfos {
516
546
  name
547
+ cartonId
517
548
  palletId
518
549
  batchId
519
550
  qty
551
+ packingType
520
552
  uomValue
521
553
  uom
522
554
  status
@@ -534,9 +566,14 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
534
566
  row
535
567
  }
536
568
  product {
569
+ id
570
+ sku
537
571
  name
538
572
  description
539
573
  }
574
+ productDetail {
575
+ id
576
+ }
540
577
  description
541
578
  location {
542
579
  id
@@ -548,286 +585,308 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
548
585
  column
549
586
  row
550
587
  }
551
- relatedOrderInv {
588
+ relatedInvCheckItem {
552
589
  inventory {
553
590
  id
591
+ lockedQty
554
592
  }
555
593
  status
594
+ countNo
556
595
  }
557
596
  }
558
597
  }
559
598
  }
560
- `,
561
- variables: {
562
- inventoryCheckNo: this.cycleCountNo,
563
- locationSortingRules: this.locationSortingRules
564
- }
565
- })
566
-
567
- if (!response.errors) {
568
- const worksheetInfo = response.data.cycleCountWorksheet.worksheetInfo
569
- const worksheetDetailInfos = response.data.cycleCountWorksheet.worksheetDetailInfos
570
- this.fillUpForm(this.infoForm, worksheetInfo)
571
- this.formattedLocations = this.formatLocations(worksheetDetailInfos)
572
- this.missingInventoryData = { records: this.formatMissingInventories(worksheetDetailInfos) }
573
- this._hideCCColumnSetting = await fetchSettingRule('hide-cc-columns', worksheetInfo.partnerDomainId)
574
- this.fillUpGrist()
575
- this.updateContext()
576
- }
577
- }
578
-
579
- resetLocation() {
580
- this.zoneSelector.value = ''
581
- this.rowSelector.value = ''
582
- this.columnSelector.value = ''
583
- }
599
+ `,
600
+ variables: {
601
+ inventoryCheckNo: this.cycleCountNo,
602
+ locationSortingRules: this.locationSortingRules
603
+ }
604
+ })
584
605
 
585
- formatLocations(worksheetDetailInfos) {
586
- const locations = worksheetDetailInfos.reduce((locations, wsdInfo) => {
587
- if (wsdInfo.relatedOrderInv.status !== 'MISSING') {
588
- const idx = locations.findIndex(loc => {
589
- if (wsdInfo.inspectedLocation) {
590
- return loc.name === wsdInfo.inspectedLocation.name
591
- }
592
- return loc.name === wsdInfo.location.name
593
- })
594
- if (idx >= 0) {
595
- locations[idx].palletQty++
596
- locations[idx].inventories.push(this.formatInventory(wsdInfo))
597
- } else {
598
- locations.push({
599
- id: wsdInfo.inspectedLocation?.id || wsdInfo.location.id,
600
- name: wsdInfo.inspectedLocation?.name || wsdInfo.location.name,
601
- palletQty: 1,
602
- inventories: [this.formatInventory(wsdInfo)],
603
- warehouse: wsdInfo.inspectedLocation?.warehouse || wsdInfo.location.warehouse,
604
- zone: wsdInfo.inspectedLocation?.zone || wsdInfo.location.zone,
605
- column: wsdInfo.inspectedLocation?.column || wsdInfo.location.column,
606
- row: wsdInfo.inspectedLocation?.row || wsdInfo.location.row
606
+ if (!response.errors) {
607
+ const worksheetData = response.data[worksheetQuery]
608
+ const { worksheetInfo, worksheetDetailInfos } = worksheetData
609
+ const partnerDomainId = worksheetInfo.partnerDomainId
610
+ this.bizplaceName = worksheetInfo.bizplace.name
611
+ this.bizplaceId = worksheetInfo.bizplace.id
612
+ this.worksheetStatus = worksheetInfo.status
613
+
614
+ // Fetch settings in parallel
615
+ const [enableCartonLabel, hideCCColumnSetting] = await Promise.all([
616
+ fetchSettingRule('enable-carton-label', partnerDomainId),
617
+ fetchSettingRule('hide-cc-columns', partnerDomainId)
618
+ ])
619
+
620
+ this._enableCartonLabel = enableCartonLabel
621
+ this._hideCCColumnSetting = hideCCColumnSetting
622
+
623
+ if (isCartonEnabled) {
624
+ const groupedRecords = worksheetDetailInfos.reduce((acc, item) => {
625
+ const key = `${item.productDetail.id}-${item.cartonId}-${item.batchId}-${item.location.name}`
626
+ if (!acc[key])
627
+ acc[key] = {
628
+ items: [],
629
+ totalInspectedQty: 0,
630
+ totalLockedQty: 0
631
+ }
632
+ acc[key].items.push(item)
633
+ acc[key].totalInspectedQty += item.inspectedQty
634
+ acc[key].totalLockedQty += item.relatedInvCheckItem?.inventory?.lockedQty || 0
635
+ return acc
636
+ }, {})
637
+
638
+ const totalItems = Object.keys(groupedRecords).length
639
+ const itemsPerPage = 1
640
+ const totalPages = Math.ceil(totalItems / itemsPerPage)
641
+
642
+ this.data.records = Object.values(groupedRecords).map((groupObj, index) => {
643
+ const group = groupObj.items
644
+ const { inspectedQty, lockedQty, ...worksheetDetails } = this.mapWorksheetDetails(group[0])
645
+
646
+ return {
647
+ qty: group.reduce((sum, item) => sum + item.qty, 0),
648
+ inspectedQty: groupObj.totalInspectedQty,
649
+ lockedQty: groupObj.totalLockedQty,
650
+ ...worksheetDetails,
651
+ totalItems: totalItems,
652
+ itemsPerPage: itemsPerPage,
653
+ totalPages: totalPages,
654
+ currentPage: index + 1
655
+ }
607
656
  })
657
+ } else {
658
+ this.data = { records: this.formatWorksheetDetailInfos(worksheetDetailInfos) }
608
659
  }
609
- }
610
-
611
- return locations
612
- }, [])
613
660
 
614
- worksheetDetailInfos
615
- .filter(wsdInfo => !wsdInfo.location && wsdInfo.relatedOrderInv.status === ORDER_INVENTORY_STATUS.ADDED)
616
- .forEach(wsdInfo => {
617
- const idx = locations.findIndex(loc => loc.id === wsdInfo)
618
- locations[idx].inventories.push(this.formatInventory(wsdInfo))
619
- })
661
+ this.fillUpForm(this.infoForm, worksheetInfo)
662
+ this._currentCard = this.data.records[this._arrayIndex]
663
+ this.updateCurrentCard()
664
+ this.missingInventoryData = { records: this.formatMissingInventories(worksheetDetailInfos) }
665
+ this.calculateCheckedInventoryCount()
666
+ this.updateNavigationButtons(worksheetDetailInfos.length, this._arrayIndex)
620
667
 
621
- locations.forEach(location => {
622
- if (location.inventories.every(inv => inv.completed)) {
623
- location.completed = true
624
- } else {
625
- location.completed = false
668
+ this.updateContext()
626
669
  }
627
- location.inventories.sort((a, b) => a.completed - b.completed)
628
- })
670
+ } catch (error) {
671
+ showToast(error)
672
+ }
673
+ }
629
674
 
630
- return locations
675
+ updateNavigationButtons(total, index) {
676
+ this._disableNext = total - 1 === index || total === 1
677
+ this._disablePrevious = index === 0 || total === 1
631
678
  }
632
679
 
633
- formatInventory(wsdInfo) {
680
+ mapWorksheetDetails(record) {
681
+ const {
682
+ name,
683
+ product,
684
+ productDetail,
685
+ inspectedBatchNo,
686
+ inspectedUomValue,
687
+ inspectedLocation,
688
+ relatedInvCheckItem,
689
+ status,
690
+ location
691
+ } = record
692
+
634
693
  return {
635
- worksheetDetailName: wsdInfo.name,
636
- productName: wsdInfo.product && wsdInfo.product.name,
637
- productDescription: wsdInfo.product && wsdInfo.product.description,
638
- completed: wsdInfo.status !== WORKSHEET_STATUS.EXECUTING.value,
639
- palletId: wsdInfo.palletId,
640
- batchId: wsdInfo.batchId,
641
- inspectedBatchNo: wsdInfo.inspectedBatchNo || '',
642
- qty: wsdInfo.qty,
643
- inspectedQty: wsdInfo.inspectedQty || 0,
644
- uomValue: wsdInfo.uomValue,
645
- uom: wsdInfo.uom,
646
- inspectedUomValue: wsdInfo.inspectedUomValue || 0,
647
- inspectedLocation: wsdInfo.inspectedLocation || 0,
648
- inventoryId: wsdInfo.relatedOrderInv.inventory.id,
649
- orderInventoryStatus: wsdInfo.relatedOrderInv.status
694
+ ...record,
695
+ worksheetDetailName: name,
696
+ productName: product?.name || '',
697
+ productSku: product?.sku || '',
698
+ productDetailId: productDetail?.id || '',
699
+ inspectedBatchNo: inspectedBatchNo || '',
700
+ inspectedUomValue: inspectedUomValue,
701
+ inspectedLocation: inspectedLocation?.name || null,
702
+ inventoryCheckItemStatus: relatedInvCheckItem?.status,
703
+ countNo: relatedInvCheckItem?.countNo,
704
+ locationId: location?.id,
705
+ locationName: location?.name || '',
706
+ wsdStatus: status,
707
+ lockedQty: relatedInvCheckItem?.inventory?.lockedQty || 0
650
708
  }
651
709
  }
652
710
 
711
+ formatWorksheetDetailInfos(wsdInfos) {
712
+ const totalItems = wsdInfos.length
713
+ const itemsPerPage = 1
714
+ const totalPages = Math.ceil(totalItems / itemsPerPage)
715
+
716
+ return wsdInfos.map((record, index) => {
717
+ return {
718
+ ...this.mapWorksheetDetails(record),
719
+ totalItems: totalItems,
720
+ itemsPerPage: itemsPerPage,
721
+ totalPages: totalPages,
722
+ currentPage: Math.floor(index / itemsPerPage) + 1
723
+ }
724
+ })
725
+ }
726
+
653
727
  formatMissingInventories(wsdInfos) {
654
728
  return wsdInfos
655
- .filter(wsdInfo => wsdInfo.relatedOrderInv.status === ORDER_INVENTORY_STATUS.MISSING.value)
656
- .map(wsdInfo => this.formatInventory(wsdInfo))
729
+ .filter(wsdInfo => wsdInfo.relatedInvCheckItem.status === INVENTORY_CHECK_ITEM_STATUS.MISSING.value)
730
+ .map(this.mapWorksheetDetails)
657
731
  }
658
732
 
659
- fillUpGrist() {
660
- this.locationData = { records: [] }
661
- this.inventoryData = { records: [] }
733
+ async submitInventoryCheck() {
734
+ try {
735
+ await this.checkInputFormValidity()
662
736
 
663
- const selectedWarehouseName = this.warehouseSelector?.value.trim()
664
- const selectedZone = this.zoneSelector.value
665
- this.selectedRow = this.rowSelector.value
666
- this.selectedColumn = this.columnSelector.value
737
+ const {
738
+ name,
739
+ inspectedBatchNo,
740
+ inspectedQty: rawInspectedQty,
741
+ inspectedUomValue: rawInspectedUomValue,
742
+ cartonId,
743
+ palletId,
744
+ productDetailId,
745
+ batchId,
746
+ locationId
747
+ } = this._currentCard
748
+
749
+ const inspectedQty = Number(rawInspectedQty)
750
+ let inspectedUomValue = Number(rawInspectedUomValue)
751
+
752
+ // If the currentCard has both a cartonId and a palletId, set inspectedUomValue to be the same as inspectedQty
753
+ if (cartonId && palletId) {
754
+ inspectedUomValue = inspectedQty
755
+ }
667
756
 
668
- this.warehouses = Array.from(new Set(this.formattedLocations.map(loc => loc.warehouse.name).sort()))
757
+ const variables = {
758
+ inspectedBatchNo,
759
+ inspectedQty,
760
+ inspectedUomValue
761
+ }
669
762
 
670
- if (selectedWarehouseName) {
671
- this.zones = Array.from(
672
- new Set(
673
- this.formattedLocations
674
- .filter(loc => loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName)
675
- .map(loc => loc.zone)
676
- .sort()
677
- )
678
- )
679
- } else {
680
- this.zones = []
681
- }
763
+ let response
682
764
 
683
- let rows = []
684
- let columns = []
685
-
686
- if (selectedWarehouseName && selectedZone) {
687
- rows = Array.from(
688
- new Set(
689
- this.formattedLocations
690
- .filter(
691
- loc =>
692
- loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName && loc.zone === selectedZone
693
- )
694
- .map(loc => loc.row)
695
- .sort()
696
- )
697
- )
765
+ if (!this._enableCartonLabel) {
766
+ // Mutate for inspecting pallet
767
+ Object.assign(variables, { worksheetDetailName: name })
768
+ response = await client.mutate({
769
+ mutation: gql`
770
+ mutation inspectingPallet(
771
+ $worksheetDetailName: String!
772
+ $inspectedBatchNo: String!
773
+ $inspectedQty: Int!
774
+ $inspectedUomValue: Float!
775
+ ) {
776
+ inspectingPallet(
777
+ worksheetDetailName: $worksheetDetailName
778
+ inspectedBatchNo: $inspectedBatchNo
779
+ inspectedQty: $inspectedQty
780
+ inspectedUomValue: $inspectedUomValue
781
+ )
782
+ }
783
+ `,
784
+ variables: variables
785
+ })
786
+ } else {
787
+ // Mutate for inspecting carton
788
+ Object.assign(variables, {
789
+ productDetailId,
790
+ cartonId,
791
+ batchId,
792
+ locationId
793
+ })
794
+ response = await client.mutate({
795
+ mutation: gql`
796
+ mutation inspectingCarton(
797
+ $productDetailId: String!
798
+ $cartonId: String!
799
+ $batchId: String!
800
+ $locationId: String!
801
+ $inspectedBatchNo: String!
802
+ $inspectedQty: Int!
803
+ $inspectedUomValue: Float!
804
+ ) {
805
+ inspectingCarton(
806
+ productDetailId: $productDetailId
807
+ cartonId: $cartonId
808
+ batchId: $batchId
809
+ locationId: $locationId
810
+ inspectedBatchNo: $inspectedBatchNo
811
+ inspectedQty: $inspectedQty
812
+ inspectedUomValue: $inspectedUomValue
813
+ )
814
+ }
815
+ `,
816
+ variables: variables
817
+ })
818
+ }
698
819
 
699
- columns = Array.from(
700
- new Set(
701
- this.formattedLocations
702
- .filter(
703
- loc =>
704
- loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName && loc.zone === selectedZone
705
- )
706
- .map(loc => loc.column)
707
- .sort()
708
- )
709
- )
820
+ if (!response.errors) {
821
+ await this.fetchCycleCountWorksheet()
822
+ this.pageUpdated()
823
+ this.showToast({ message: i18next.t('text.the_inventory_has_been_successfully_checked') })
824
+ }
825
+ } catch (e) {
826
+ this.showToast(e)
710
827
  }
828
+ }
711
829
 
712
- if (this.selectedRow) {
713
- columns = Array.from(
714
- new Set(
715
- this.formattedLocations
716
- .filter(
717
- loc =>
718
- loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName &&
719
- loc.zone === selectedZone &&
720
- loc.row === this.selectedRow
721
- )
722
- .map(loc => loc.column)
723
- .sort()
724
- )
725
- )
726
- }
830
+ updateContext() {
831
+ let actions = []
727
832
 
728
- if (this.selectedColumn) {
729
- rows = Array.from(
730
- new Set(
731
- this.formattedLocations
732
- .filter(
733
- loc =>
734
- loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName &&
735
- loc.zone === selectedZone &&
736
- loc.column === this.selectedColumn
737
- )
738
- .map(loc => loc.row)
739
- .sort()
740
- )
833
+ // Check if all cards have a status of 'NOT_TALLY' or 'DONE'
834
+ if (this.data.records.length > 0 && this.data.records) {
835
+ const inventoryCompleted = this.data.records.every(record =>
836
+ ['NOT_TALLY', 'GROUP_NOT_TALLY', 'DONE'].includes(record.wsdStatus)
741
837
  )
742
- }
743
838
 
744
- let records = []
745
- if (selectedWarehouseName && selectedZone && (this.selectedRow || this.selectedColumn)) {
746
- records = this.formattedLocations
747
- .filter(({ warehouse, zone, row, column }) => {
748
- if (warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName && zone === selectedZone) {
749
- if (this.selectedRow && this.selectedColumn)
750
- return row === this.selectedRow && column === this.selectedColumn
751
- if (this.selectedRow) return row === this.selectedRow
752
- if (this.selectedColumn) return column === this.selectedColumn
753
- } else {
754
- return false
755
- }
839
+ if (inventoryCompleted) {
840
+ actions.push({
841
+ title: i18next.t('button.complete'),
842
+ action: this.completeCycleCount.bind(this),
843
+ ...CommonButtonStyles.submit
756
844
  })
757
- .sort(record => (record.completed ? 1 : -1))
758
- }
759
-
760
- this.rows = rows
761
- this.columns = columns
762
- this.locationData = { records }
763
- }
764
-
765
- updateContext(type) {
766
- let actions = []
767
- switch (type) {
768
- case VIEW_TYPE.INVENTORY_SELECTED:
769
- if (this.selectedInventory) {
770
- if (
771
- this.selectedInventory.completed &&
772
- this.selectedInventory.orderInventoryStatus !== ORDER_INVENTORY_STATUS.TERMINATED.value
773
- ) {
774
- if (!this.isReleasing)
775
- actions.push({
776
- title: i18next.t('button.undo'),
777
- action: this.undoInventoryCheck.bind(this),
778
- ...CommonButtonStyles.undo
779
- })
780
- } else {
781
- actions.push({
782
- title: i18next.t('button.check_missing_x', { state: { x: i18next.t('label.pallet') } }),
783
- action: this.checkMissingPallet.bind(this),
784
- ...CommonButtonStyles.confirm
785
- })
786
- actions.push({
787
- title: i18next.t('button.check'),
788
- action: this.submitInventoryCheck.bind(this),
789
- ...CommonButtonStyles.submit
790
- })
791
- }
792
- }
793
- break
845
+ }
794
846
 
795
- case VIEW_TYPE.MISSING_PALLET_SELECTED:
796
- if (this.selectedInventory) {
847
+ if (this.worksheetStatus == 'EXECUTING') {
848
+ const status = this._currentCard.inventoryCheckItemStatus
849
+ if (['MISSING', 'RELOCATED', 'INSPECTED', 'NOT_TALLY', 'GROUP_NOT_TALLY'].includes(status)) {
797
850
  actions.push({
798
851
  title: i18next.t('button.undo'),
799
852
  action: this.undoInventoryCheck.bind(this),
800
853
  ...CommonButtonStyles.undo
801
854
  })
855
+ } else if (status !== 'ADDED') {
856
+ actions.push({
857
+ title: i18next.t('button.check'),
858
+ action: this.submitInventoryCheck.bind(this),
859
+ ...CommonButtonStyles.submit
860
+ })
861
+
862
+ actions.push({
863
+ title: i18next.t('button.check_missing_x', { state: { x: i18next.t('label.inventory') } }),
864
+ action: this.checkMissingInventory.bind(this),
865
+ ...CommonButtonStyles.confirm
866
+ })
867
+ }
868
+
869
+ if (!['RELOCATED', 'INSPECTED', 'NOT_TALLY', 'GROUP_NOT_TALLY', 'ADDED', 'MISSING'].includes(status)) {
802
870
  actions.push({
803
871
  title: i18next.t('button.relocate'),
804
- action: this.relocatePallet.bind(this),
872
+ action: this.relocateInventory.bind(this),
805
873
  ...CommonButtonStyles.relocate
806
874
  })
807
875
  }
808
- break
809
- }
810
-
811
- actions.push({
812
- title: i18next.t('button.check_unknown_pallet'),
813
- action: this.checkUnknownPallet.bind(this),
814
- ...CommonButtonStyles.confirm
815
- })
816
876
 
817
- actions.push({
818
- title: i18next.t('button.add_x', { state: { x: i18next.t('label.pallet') } }),
819
- action: this.addExtraPallet.bind(this),
820
- ...CommonButtonStyles.additional
821
- })
877
+ actions.push({
878
+ title: i18next.t('button.check_unknown_inventory'),
879
+ action: this.checkUnknownInventory.bind(this),
880
+ ...CommonButtonStyles.confirm
881
+ })
822
882
 
823
- if (this.formattedLocations?.length && this.formattedLocations.every(loc => loc.completed)) {
824
- actions.push({
825
- title: i18next.t('button.complete'),
826
- action: this.completeCycleCount.bind(this),
827
- ...CommonButtonStyles.submit
828
- })
883
+ actions.push({
884
+ title: i18next.t('button.add_x', { state: { x: i18next.t('label.inventory') } }),
885
+ action: this.addExtraInventory.bind(this),
886
+ ...CommonButtonStyles.additional
887
+ })
888
+ }
829
889
  }
830
-
831
890
  store.dispatch({
832
891
  type: UPDATE_CONTEXT,
833
892
  context: {
@@ -837,243 +896,126 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
837
896
  })
838
897
  }
839
898
 
840
- async addExtraPallet() {
841
- try {
842
- await this.checkInputFormValidity()
843
-
844
- const palletId = this.palletIdInput.value
845
-
846
- const isInventoryOwner = await this.checkPalletInformation(palletId, this.bizplaceNameInput.value)
847
-
848
- if (isInventoryOwner) {
849
- var locationName = this.locationInput.value
850
- let location
851
- let inventory
852
-
853
- for (let i = 0; i < this.formattedLocations.length; i++) {
854
- location = this.formattedLocations[i]
855
-
856
- for (let j = 0; j < location.inventories.length; j++) {
857
- if (palletId === location.inventories[j].palletId) {
858
- inventory = location.inventories[j]
859
- break
860
- }
899
+ fillUpForm(form, data) {
900
+ form.reset()
901
+ for (let key in data) {
902
+ Array.from(form.querySelectorAll('input')).forEach(field => {
903
+ if (field.name === key && field.type === 'checkbox') {
904
+ field.checked = data[key]
905
+ } else if (field.name === key && field.type === 'datetime-local') {
906
+ const datetime = Number(data[key])
907
+ const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
908
+ field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
909
+ } else if (field.name === key) {
910
+ if (data[key] instanceof Object) {
911
+ const objectData = data[key]
912
+ field.value = `${objectData.name}`
913
+ } else {
914
+ field.value = data[key]
861
915
  }
862
-
863
- if (inventory) break
864
916
  }
917
+ })
918
+ }
919
+ }
865
920
 
866
- if (inventory && location.id !== this.selectedLocation.id) {
867
- const result = await CustomAlert({
868
- title: i18next.t('title.same_pallet_is_found'),
869
- text: i18next.t('text.same_pallet_is_found_in_location', { state: { location: location.name } }),
870
- confirmButton: { text: i18next.t('button.relocate') },
871
- cancelButton: { text: i18next.t('button.cancel') }
872
- })
873
-
874
- if (!result.value) {
875
- return
876
- }
921
+ async checkInputFormValidity() {
922
+ let { inspectedBatchNo, inspectedQty, inspectedUomValue, cartonId, palletId } = this._currentCard
923
+ inspectedQty = Number(inspectedQty)
877
924
 
878
- let { inspectedBatchNo, inspectedQty, inspectedUomValue } = Object.fromEntries(
879
- new FormData(this.inputForm).entries()
880
- )
925
+ // If the currentCard has both a cartonId and a palletId, set inspectedUomValue to be the same as inspectedQty
926
+ if (cartonId && palletId) {
927
+ inspectedUomValue = inspectedQty
928
+ } else {
929
+ inspectedUomValue = Number(inspectedUomValue)
930
+ }
881
931
 
882
- inventory.inspectedBatchNo = inspectedBatchNo
883
- inventory.inspectedQty = Number(inspectedQty)
884
- inventory.inspectedUomValue = Number(inspectedUomValue)
932
+ if (!inspectedBatchNo) {
933
+ throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('field.inspected_batch_no') } }))
934
+ }
885
935
 
886
- this.selectedInventory = inventory
887
- await this.relocatePallet()
888
- return
889
- } else if (inventory) {
890
- this.selectOnInput(this.palletIdInput)
891
- throw new Error(i18next.t('title.same_pallet_is_found'))
892
- }
936
+ if (!inspectedQty) {
937
+ throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('field.inspected_qty') } }))
938
+ }
893
939
 
894
- const result = await CustomAlert({
895
- title: i18next.t('title.are_you_sure'),
896
- text: i18next.t('button.add_x', { state: { x: i18next.t('label.pallet') } }),
897
- confirmButton: { text: i18next.t('button.confirm') },
898
- cancelButton: { text: i18next.t('button.cancel') }
899
- })
940
+ if (inspectedQty <= 0) {
941
+ throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('field.inspected_qty') } }))
942
+ }
900
943
 
901
- if (!result.value) {
902
- return
903
- }
944
+ if (!this._enableCartonLabel) {
945
+ if (!inspectedUomValue) {
946
+ throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('field.inspected_uom_value') } }))
947
+ }
904
948
 
905
- let { inspectedBatchNo, inspectedQty, inspectedUomValue } = Object.fromEntries(
906
- new FormData(this.inputForm).entries()
949
+ if (inspectedUomValue <= 0) {
950
+ throw new Error(
951
+ i18next.t('text.x_should_be_positive', { state: { x: i18next.t('field.inspected_uom_value') } })
907
952
  )
908
- inspectedQty = Number(inspectedQty)
909
- inspectedUomValue = Number(inspectedUomValue)
953
+ }
954
+ }
955
+ }
956
+
957
+ async undoInventoryCheck() {
958
+ await sleep(1010)
959
+ try {
960
+ const { name, cartonId, productDetailId, batchId, locationId } = this._currentCard
910
961
 
911
- const response = await client.mutate({
962
+ const result = await CustomAlert({
963
+ title: i18next.t('title.are_you_sure'),
964
+ text: i18next.t('text.undo_inspection'),
965
+ confirmButton: { text: i18next.t('button.confirm') },
966
+ cancelButton: { text: i18next.t('button.cancel') }
967
+ })
968
+
969
+ let response
970
+
971
+ if (!this._enableCartonLabel) {
972
+ response = await client.mutate({
912
973
  mutation: gql`
913
- mutation addExtraPallet(
914
- $cycleCountNo: String!
915
- $palletId: String!
916
- $inspectedBatchNo: String!
917
- $inspectedQty: Int!
918
- $inspectedUomValue: Float!
919
- $locationName: String!
920
- ) {
921
- addExtraPallet(
922
- cycleCountNo: $cycleCountNo
923
- palletId: $palletId
924
- inspectedBatchNo: $inspectedBatchNo
925
- inspectedQty: $inspectedQty
926
- inspectedUomValue: $inspectedUomValue
927
- locationName: $locationName
928
- )
974
+ mutation undoInspection($worksheetDetailName: String!) {
975
+ undoInspection(worksheetDetailName: $worksheetDetailName)
929
976
  }
930
977
  `,
931
- variables: {
932
- cycleCountNo: this.cycleCountNo,
933
- palletId,
934
- inspectedBatchNo,
935
- inspectedQty,
936
- inspectedUomValue,
937
- locationName
938
- }
978
+ variables: { worksheetDetailName: name }
939
979
  })
940
-
941
- if (!response.errors) {
942
- await this.fetchCycleCountWorksheet()
943
- this.renewInventoryGrist()
944
- this.inputForm.reset()
945
- this.palletIdInput.value = ''
946
- this.locationInput.value = ''
947
- }
948
980
  } else {
949
- await CustomAlert({
950
- title: i18next.t('title.inventory_not_found'),
951
- text: i18next.t('text.inventory_does_not_belong_to_current_company_account'),
952
- confirmButton: { text: i18next.t('button.okay') }
981
+ response = await client.mutate({
982
+ mutation: gql`
983
+ mutation undoInspectionCarton(
984
+ $productDetailId: String!
985
+ $cartonId: String!
986
+ $batchId: String!
987
+ $locationId: String!
988
+ ) {
989
+ undoInspectionCarton(
990
+ productDetailId: $productDetailId
991
+ cartonId: $cartonId
992
+ batchId: $batchId
993
+ locationId: $locationId
994
+ )
995
+ }
996
+ `,
997
+ variables: { productDetailId, cartonId, batchId, locationId }
953
998
  })
954
-
955
- this.inputForm.reset()
956
- this.palletIdInput.value = ''
957
- this.locationInput.value = ''
958
- }
959
- } catch (e) {
960
- this.showToast(e)
961
- }
962
- }
963
-
964
- checkUnknownPallet() {
965
- openPopup(
966
- html`
967
- <check-inventory-popup
968
- .bizplaceName="${this.bizplaceNameInput.value}"
969
- .cycleCountNo="${this.cycleCountNo}"
970
- .selectedLocation="${this.selectedLocation?.name ? this.selectedLocation.name : null}"
971
- .selectedInventory="${this.selectedInventory?.palletId ? this.selectedInventory.palletId : null}"
972
- .missingInventory="${this.missingInventoryData}"
973
- @relocate-missing-inventory="${async e => {
974
- history.back()
975
- this.viewType = VIEW_TYPE.MISSING_PALLET_SELECTED
976
- this.updateContext(this.viewType)
977
- this.selectedInventory = e.detail.missingRecord
978
- this.locationInput.value = e.detail.locationInput
979
- await CustomAlert({
980
- title: i18next.t('title.found_in_missing_list'),
981
- text: i18next.t('text.kindly_inspect_and_relocate_this_inventory'),
982
- confirmButton: { text: i18next.t('button.okay') }
983
- })
984
- }}"
985
- @relocate-inventory="${async e => {
986
- history.back()
987
- this.viewType = VIEW_TYPE.MISSING_PALLET_SELECTED
988
- this.updateContext(this.viewType)
989
- this.selectedInventory = e.detail.recordInformation
990
- this.locationInput.value = e.detail.locationInput
991
- await CustomAlert({
992
- title: i18next.t('title.system_and_physical_location_is_different'),
993
- text: i18next.t('text.kindly_inspect_and_relocate_this_inventory'),
994
- confirmButton: { text: i18next.t('button.okay') }
995
- })
996
- }}"
997
- @same-location="${async e => {
998
- history.back()
999
- this.viewType = VIEW_TYPE.INVENTORY_SELECTED
1000
- this.updateContext(this.viewType)
1001
- this.selectedInventory = e.detail.recordInformation
1002
- await CustomAlert({
1003
- title: i18next.t('title.inventory_in_current_location'),
1004
- text: i18next.t('text.kindly_continue_inspect_the_inventory'),
1005
- confirmButton: { text: i18next.t('button.okay') }
1006
- })
1007
- }}"
1008
- @not-in-cc="${async e => {
1009
- history.back()
1010
- this.viewType = VIEW_TYPE.INVENTORY_SELECTED
1011
- this.updateContext(this.viewType)
1012
- await CustomAlert({
1013
- title: i18next.t('title.inventory_not_found'),
1014
- text: i18next.t('text.pallet_(x)_is_not_found_in_cycle_count_worksheet_(y)', {
1015
- x: e.detail.palletId,
1016
- y: e.detail.cycleCountNo
1017
- }),
1018
- confirmButton: { text: i18next.t('button.okay') }
1019
- })
1020
- }}"
1021
- ></check-inventory-popup>
1022
- `,
1023
- {
1024
- backdrop: true,
1025
- size: 'medium',
1026
- title: i18next.t('title.check_unknown_inventory')
1027
999
  }
1028
- )
1029
- }
1030
-
1031
- async checkOrderInventory() {
1032
- try {
1033
- const filters = [
1034
- { name: 'inventoryId', operator: 'eq', value: this.selectedInventory.inventoryId },
1035
- {
1036
- name: 'status',
1037
- operator: 'notin',
1038
- value: [ORDER_INVENTORY_STATUS.TERMINATED.value, ORDER_INVENTORY_STATUS.CANCELLED.value]
1039
- },
1040
- { name: 'type', operator: 'eq', value: ORDER_TYPES.RELEASE_OF_GOODS.value }
1041
- ]
1042
-
1043
- const response = await client.query({
1044
- query: gql`
1045
- query orderInventories($filters: [Filter!]) {
1046
- orderInventories(filters: $filters) {
1047
- items {
1048
- id
1049
- name
1050
- }
1051
- total
1052
- }
1053
- }
1054
- `,
1055
- variables: { filters }
1056
- })
1057
1000
 
1058
1001
  if (!response.errors) {
1059
- const orderInventories = response.data.orderInventories.items
1060
-
1061
- if (orderInventories.length > 0) {
1062
- this.isReleasing = true
1063
- } else {
1064
- this.isReleasing = false
1065
- }
1002
+ await this.fetchCycleCountWorksheet()
1003
+ this.resetInput()
1004
+ this.showToast({ message: i18next.t('text.the_inventory_has_been_successfully_reverted') })
1066
1005
  }
1067
1006
  } catch (e) {
1068
1007
  this.showToast(e)
1069
1008
  }
1070
1009
  }
1071
1010
 
1072
- async checkMissingPallet() {
1011
+ async checkMissingInventory() {
1012
+ await sleep(1010)
1073
1013
  try {
1014
+ const { name, cartonId, productDetailId, batchId, locationId } = this._currentCard
1015
+
1074
1016
  const result = await CustomAlert({
1075
1017
  title: i18next.t('title.are_you_sure'),
1076
- text: i18next.t('button.check_missing_x', { state: { x: i18next.t('field.lot_id') } }),
1018
+ text: i18next.t('button.check_missing_x', { state: { x: i18next.t('field.inventory') } }),
1077
1019
  confirmButton: { text: i18next.t('button.confirm') },
1078
1020
  cancelButton: { text: i18next.t('button.cancel') }
1079
1021
  })
@@ -1082,142 +1024,152 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
1082
1024
  return
1083
1025
  }
1084
1026
 
1085
- const response = await client.mutate({
1086
- mutation: gql`
1087
- mutation checkMissingPallet($worksheetDetailName: String!) {
1088
- checkMissingPallet(worksheetDetailName: $worksheetDetailName)
1089
- }
1090
- `,
1091
- variables: { worksheetDetailName: this.selectedInventory.worksheetDetailName }
1092
- })
1027
+ let response
1028
+
1029
+ if (!this._enableCartonLabel) {
1030
+ response = await client.mutate({
1031
+ mutation: gql`
1032
+ mutation checkMissingInventory($worksheetDetailName: String!) {
1033
+ checkMissingInventory(worksheetDetailName: $worksheetDetailName)
1034
+ }
1035
+ `,
1036
+ variables: { worksheetDetailName: name }
1037
+ })
1038
+ } else {
1039
+ response = await client.mutate({
1040
+ mutation: gql`
1041
+ mutation checkMissingInventoryCarton(
1042
+ $productDetailId: String!
1043
+ $cartonId: String!
1044
+ $batchId: String!
1045
+ $locationId: String!
1046
+ ) {
1047
+ checkMissingInventoryCarton(
1048
+ productDetailId: $productDetailId
1049
+ cartonId: $cartonId
1050
+ batchId: $batchId
1051
+ locationId: $locationId
1052
+ )
1053
+ }
1054
+ `,
1055
+ variables: { productDetailId, cartonId, batchId, locationId }
1056
+ })
1057
+ }
1093
1058
 
1094
1059
  if (!response.errors) {
1095
1060
  await this.fetchCycleCountWorksheet()
1096
- this.renewInventoryGrist()
1061
+ this.showToast({ message: i18next.t('text.the_inventory_has_been_marked_as_missing') })
1097
1062
  }
1098
1063
  } catch (e) {
1099
1064
  this.showToast(e)
1100
1065
  }
1101
1066
  }
1102
1067
 
1103
- async relocatePallet() {
1104
- try {
1105
- await this.checkInputFormValidity()
1106
-
1107
- const result = await CustomAlert({
1108
- title: i18next.t('title.are_you_sure'),
1109
- text: i18next.t('button.relocate'),
1110
- confirmButton: { text: i18next.t('button.confirm') },
1111
- cancelButton: { text: i18next.t('button.cancel') }
1112
- })
1113
-
1114
- if (!result.value) {
1115
- return
1068
+ async checkUnknownInventory() {
1069
+ await sleep(1010)
1070
+ openPopup(
1071
+ html`
1072
+ <check-inventory-popup
1073
+ .bizplaceId="${this.bizplaceId}"
1074
+ .missingInventory="${this.missingInventoryData}"
1075
+ .enableCartonLabel="${this._enableCartonLabel}"
1076
+ ></check-inventory-popup>
1077
+ `,
1078
+ {
1079
+ backdrop: true,
1080
+ size: 'medium',
1081
+ title: i18next.t('title.check_unknown_inventory')
1116
1082
  }
1083
+ )
1084
+ }
1117
1085
 
1118
- const { inspectedBatchNo, inspectedQty, inspectedUomValue } = Object.fromEntries(
1119
- new FormData(this.inputForm).entries()
1120
- )
1121
-
1122
- const response = await client.mutate({
1123
- mutation: gql`
1124
- mutation relocatePallet(
1125
- $worksheetDetailName: String!
1126
- $inspectedBatchNo: String!
1127
- $inspectedQty: Int!
1128
- $inspectedUomValue: Float!
1129
- $inspectedLocationName: String!
1130
- ) {
1131
- relocatePallet(
1132
- worksheetDetailName: $worksheetDetailName
1133
- inspectedBatchNo: $inspectedBatchNo
1134
- inspectedQty: $inspectedQty
1135
- inspectedUomValue: $inspectedUomValue
1136
- inspectedLocationName: $inspectedLocationName
1137
- )
1138
- }
1086
+ async addExtraInventory() {
1087
+ await sleep(1010)
1088
+ try {
1089
+ openPopup(
1090
+ html`
1091
+ <add-extra-inventory-popup
1092
+ .bizplaceId="${this.bizplaceId}"
1093
+ .bizplaceName="${this.bizplaceName}"
1094
+ .cycleCountNo="${this.cycleCountNo}"
1095
+ .countNo="${this._currentCard.countNo}"
1096
+ .enableCartonLabel="${this._enableCartonLabel}"
1097
+ @add-inventory="${async e => {
1098
+ history.back()
1099
+ await this.fetchCycleCountWorksheet()
1100
+ this.pageUpdated()
1101
+ this.updateContext()
1102
+ }}"
1103
+ ></add-extra-inventory-popup>
1139
1104
  `,
1140
- variables: {
1141
- worksheetDetailName: this.selectedInventory.worksheetDetailName,
1142
- inspectedBatchNo,
1143
- inspectedQty: Number(inspectedQty),
1144
- inspectedUomValue: Number(inspectedUomValue),
1145
- inspectedLocationName: this.locationInput.value
1105
+ {
1106
+ backdrop: true,
1107
+ size: 'medium',
1108
+ title: i18next.t('title.add_inventory')
1146
1109
  }
1147
- })
1148
-
1149
- if (!response.errors) {
1150
- await this.fetchCycleCountWorksheet()
1151
- this.renewInventoryGrist()
1152
- this.inspectedQtyInput.value = ''
1153
- }
1110
+ )
1154
1111
  } catch (e) {
1155
1112
  this.showToast(e)
1156
1113
  }
1157
1114
  }
1158
1115
 
1159
- async submitInventoryCheck() {
1116
+ async relocateInventory() {
1160
1117
  try {
1118
+ await sleep(1010)
1161
1119
  await this.checkInputFormValidity()
1162
1120
 
1163
- let { inspectedBatchNo, inspectedQty, inspectedUomValue } = Object.fromEntries(
1164
- new FormData(this.inputForm).entries()
1165
- )
1121
+ let { inspectedQty, inspectedUomValue, cartonId, palletId } = this._currentCard
1166
1122
  inspectedQty = Number(inspectedQty)
1167
- inspectedUomValue = Number(inspectedUomValue)
1168
1123
 
1169
- const response = await client.mutate({
1170
- mutation: gql`
1171
- mutation inspecting(
1172
- $worksheetDetailName: String!
1173
- $inspectedBatchNo: String!
1174
- $inspectedQty: Int!
1175
- $inspectedUomValue: Float!
1176
- ) {
1177
- inspecting(
1178
- worksheetDetailName: $worksheetDetailName
1179
- inspectedBatchNo: $inspectedBatchNo
1180
- inspectedQty: $inspectedQty
1181
- inspectedUomValue: $inspectedUomValue
1182
- )
1183
- }
1124
+ // If the currentCard has both cartonId & palletId, set inspectedUomValue to be the same as inspectedQty
1125
+ if (cartonId && palletId) {
1126
+ inspectedUomValue = inspectedQty
1127
+ } else {
1128
+ inspectedUomValue = Number(inspectedUomValue)
1129
+ }
1130
+
1131
+ openPopup(
1132
+ html`
1133
+ <relocate-inventory-popup
1134
+ .bizplaceName="${this.bizplaceName}"
1135
+ .cycleCountNo="${this.cycleCountNo}"
1136
+ .currentCard="${this._currentCard}"
1137
+ .enableCartonLabel="${this._enableCartonLabel}"
1138
+ @relocate="${async e => {
1139
+ history.back()
1140
+ await this.fetchCycleCountWorksheet()
1141
+ this.pageUpdated()
1142
+ this.updateContext()
1143
+ }}"
1144
+ ></relocate-inventory-popup>
1184
1145
  `,
1185
- variables: {
1186
- worksheetDetailName: this.selectedInventory.worksheetDetailName,
1187
- inspectedBatchNo,
1188
- inspectedQty,
1189
- inspectedUomValue
1146
+ {
1147
+ backdrop: true,
1148
+ size: 'medium',
1149
+ title: i18next.t('title.relocate_inventory')
1190
1150
  }
1191
- })
1192
-
1193
- if (!response.errors) {
1194
- await this.fetchCycleCountWorksheet()
1195
- this.renewInventoryGrist()
1196
- this.resetInput()
1197
- }
1151
+ )
1198
1152
  } catch (e) {
1199
1153
  this.showToast(e)
1200
1154
  }
1201
1155
  }
1202
1156
 
1203
- async undoInventoryCheck() {
1157
+ async checkPalletInformation(palletId, bizplaceName) {
1204
1158
  try {
1205
- const response = await client.mutate({
1206
- mutation: gql`
1207
- mutation undoInspection($worksheetDetailName: String!) {
1208
- undoInspection(worksheetDetailName: $worksheetDetailName)
1159
+ const response = await client.query({
1160
+ query: gql`
1161
+ query checkInventoryOwner($palletId: String!, $bizplaceName: String!) {
1162
+ checkInventoryOwner(palletId: $palletId, bizplaceName: $bizplaceName)
1209
1163
  }
1210
1164
  `,
1211
- variables: { worksheetDetailName: this.selectedInventory.worksheetDetailName }
1165
+ variables: { palletId, bizplaceName }
1212
1166
  })
1213
1167
 
1214
1168
  if (!response.errors) {
1215
- await this.fetchCycleCountWorksheet()
1216
- this.renewInventoryGrist()
1217
- this.resetInput()
1169
+ return response.data.checkInventoryOwner
1218
1170
  }
1219
1171
  } catch (e) {
1220
- this.showToast(e)
1172
+ return false
1221
1173
  }
1222
1174
  }
1223
1175
 
@@ -1269,152 +1221,125 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
1269
1221
  }
1270
1222
  }
1271
1223
 
1272
- resetInput() {
1273
- this.inspectedQtyInput.value = ''
1274
- this.locationInput.value = ''
1275
- this.inspectedUomValueInput.value = ''
1276
- }
1224
+ async fetchOrFilterItem(filters) {
1225
+ let matchedItem = null
1277
1226
 
1278
- renewInventoryGrist() {
1279
- this.selectedLocation = this.selectedLocation?.id
1280
- ? this.formattedLocations.find(loc => loc.id === this.selectedLocation.id)
1281
- : []
1282
- this.inventoryData = { records: this.selectedLocation?.inventories || [] }
1283
- this.selectedInventory = null
1284
- this.updateContext()
1285
- }
1286
-
1287
- async checkPalletInformation(palletId, bizplaceName) {
1288
- try {
1289
- const response = await client.query({
1290
- query: gql`
1291
- query checkInventoryOwner($palletId: String!, $bizplaceName: String!) {
1292
- checkInventoryOwner(palletId: $palletId, bizplaceName: $bizplaceName)
1293
- }
1294
- `,
1295
- variables: { palletId, bizplaceName }
1296
- })
1297
-
1298
- if (!response.errors) {
1299
- return response.data.checkInventoryOwner
1227
+ matchedItem = this.data.records.find(item => {
1228
+ let match = true
1229
+ if (filters.locationName) {
1230
+ match = match && item.location?.name === filters.locationName
1300
1231
  }
1301
- } catch (e) {
1302
- return false
1303
- }
1232
+ if (filters.cartonId) {
1233
+ match = match && item.cartonId === filters.cartonId
1234
+ }
1235
+ if (filters.palletId) {
1236
+ match = match && item.palletId === filters.palletId
1237
+ }
1238
+ return match
1239
+ })
1240
+
1241
+ return matchedItem
1304
1242
  }
1305
1243
 
1306
- async validateLocation(scannedLocation) {
1307
- try {
1308
- const response = await client.query({
1309
- query: gql`
1310
- query locations($filters: [Filter!]) {
1311
- locations(filters: $filters) {
1312
- items {
1313
- id
1314
- name
1315
- }
1316
- }
1317
- }
1318
- `,
1319
- variables: { filters: [{ name: 'name', operator: 'eq', value: scannedLocation }] }
1320
- })
1244
+ updateInventoryState(matchedItem) {
1245
+ // Find the index of the matched item in this.data.records
1246
+ let index = this.data.records.findIndex(item => item.worksheetDetailName === matchedItem.worksheetDetailName)
1321
1247
 
1322
- if (!response.errors) {
1323
- const locations = response.data.locations.items || []
1248
+ if (index > -1) {
1249
+ // Update _arrayIndex to the index of the matched item
1250
+ this._arrayIndex = index
1324
1251
 
1325
- if (!locations?.length) {
1326
- return false
1327
- } else {
1328
- return true
1329
- }
1330
- }
1331
- } catch (e) {
1332
- this.showToast(e)
1252
+ // Update _currentCard to the matched item
1253
+ this._currentCard = this.data.records[this._arrayIndex]
1333
1254
  }
1255
+ this.requestUpdate()
1256
+ this.pageUpdated()
1334
1257
  }
1335
1258
 
1336
- async checkInputFormValidity() {
1337
- let { inspectedBatchNo, inspectedQty, inspectedUomValue, location } = Object.fromEntries(
1338
- new FormData(this.inputForm).entries()
1259
+ updateCurrentCard() {
1260
+ this._currentCard = this.data.records[this._arrayIndex] ? { ...this.data.records[this._arrayIndex] } : {}
1261
+
1262
+ const currentStatus = this._currentCard.inventoryCheckItemStatus
1263
+
1264
+ // Check the status and mark the currentCard as "checked" if it matches any status
1265
+ this._currentCard.checked = ['INSPECTED', 'RELOCATED', 'ADDED', 'NOT_TALLY', 'GROUP_NOT_TALLY'].includes(
1266
+ currentStatus
1339
1267
  )
1340
- inspectedQty = Number(inspectedQty)
1341
- inspectedUomValue = Number(inspectedUomValue)
1268
+ }
1342
1269
 
1343
- const palletId = this.palletIdInput.value
1344
- if (!palletId) {
1345
- this.selectOnInput(this.palletIdInput)
1346
- throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('label.lot_id') } }))
1270
+ resetInput() {
1271
+ this._currentCard.inspectedBatchInput = ''
1272
+ this._currentCard.inspectedQtyInput = 0
1273
+ if (!this._enableCartonLabel) {
1274
+ this._currentCard.inspectedUomValueInput = 0
1347
1275
  }
1276
+ }
1348
1277
 
1349
- if (!inspectedBatchNo) {
1350
- this.selectOnInput(this.inspectedBatchNoInput)
1351
- throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('field.inspected_batch_no') } }))
1352
- }
1278
+ calculateCheckedInventoryCount() {
1279
+ this._currentCard.checkedInventoryCount = this.data.records.reduce((count, record) => {
1280
+ if (
1281
+ ['INSPECTED', 'RELOCATED', 'ADDED', 'NOT_TALLY', 'GROUP_NOT_TALLY'].includes(record.relatedInvCheckItem.status)
1282
+ ) {
1283
+ return count + 1
1284
+ }
1285
+ return count
1286
+ }, 0)
1287
+ }
1353
1288
 
1354
- if (!inspectedQty) {
1355
- this.selectOnInput(this.inspectedQtyInput)
1356
- throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('field.inspected_qty') } }))
1289
+ clearView() {
1290
+ this.data = { records: [] }
1291
+ this.cycleCountNo = null
1292
+ this._currentCard = {
1293
+ checkedInventoryCount: 0
1357
1294
  }
1358
-
1359
- if (inspectedQty <= 0) {
1360
- this.selectOnInput(this.inspectedQtyInput)
1361
- throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('field.inspected_qty') } }))
1295
+ this._selectedInventoryCheckItem = null
1296
+ this.formattedLocations = []
1297
+ this._editedCard = {}
1298
+ this.editMode = {
1299
+ inspectedBatchNo: false,
1300
+ inspectedQty: false,
1301
+ inspectedUomValue: false
1362
1302
  }
1303
+ this._arrayIndex = 0
1304
+ this.itemsPerPage = 1
1305
+ this.totalItems = 0
1306
+ this.inputForm.reset()
1307
+ this.infoForm.reset()
1308
+ this.updateContext()
1309
+ }
1363
1310
 
1364
- if (!inspectedUomValue) {
1365
- this.selectOnInput(this.inspectedUomValueInput)
1366
- throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('field.inspected_uom_value') } }))
1367
- }
1311
+ nextCard() {
1312
+ this._arrayIndex = this._arrayIndex + 1
1313
+ this._disablePrevious = false
1314
+ this._scannedQty = 0
1315
+ this.pageUpdated()
1316
+ this.updateContext()
1317
+ }
1368
1318
 
1369
- if (inspectedUomValue <= 0) {
1370
- this.selectOnInput(this.inspectedUomValueInput)
1371
- throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('field.inspected_uom_value') } }))
1372
- }
1319
+ previousCard() {
1320
+ this._arrayIndex = this._arrayIndex - 1
1321
+ this._disableNext = false
1322
+ this._scannedQty = 0
1323
+ this.pageUpdated()
1324
+ this.updateContext()
1325
+ }
1373
1326
 
1374
- if (this.locationInput) {
1375
- const locationName = this.locationInput?.value
1376
- if (!locationName) {
1377
- this.selectOnInput(this.locationInput)
1378
- throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('label.location') } }))
1379
- } else {
1380
- const locationExist = await this.validateLocation(locationName)
1381
- if (!locationExist) {
1382
- throw new Error(i18next.t('text.invalid_x', { state: { x: i18next.t('label.location') } }))
1383
- }
1384
- }
1385
- }
1327
+ _enableEditMode(field) {
1328
+ this._editMode = { ...this._editMode, [field]: true }
1329
+ this._editedCard = { ...this._editedCard, [field]: this._currentCard[field] }
1386
1330
  }
1387
1331
 
1388
- clearView() {
1389
- this.locationData = { records: [] }
1390
- this.inventoryData = { records: [] }
1391
- this.selectedLocation = null
1392
- this.selectedInventory = null
1393
- this.formattedLocations = []
1394
- this.inputForm.reset()
1395
- this.conditionForm?.reset()
1332
+ _disableEditMode(field) {
1333
+ this._editMode = { ...this._editMode, [field]: false }
1396
1334
  }
1397
1335
 
1398
- fillUpForm(form, data) {
1399
- form.reset()
1400
- for (let key in data) {
1401
- Array.from(form.querySelectorAll('input')).forEach(field => {
1402
- if (field.name === key && field.type === 'checkbox') {
1403
- field.checked = data[key]
1404
- } else if (field.name === key && field.type === 'datetime-local') {
1405
- const datetime = Number(data[key])
1406
- const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
1407
- field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
1408
- } else if (field.name === key) {
1409
- if (data[key] instanceof Object) {
1410
- const objectData = data[key]
1411
- field.value = `${objectData.name}`
1412
- } else {
1413
- field.value = data[key]
1414
- }
1415
- }
1416
- })
1417
- }
1336
+ _handleEditInput(field, value) {
1337
+ this._editedCard = { ...this._editedCard, [field]: value }
1338
+ }
1339
+
1340
+ _saveEdit(field) {
1341
+ this._currentCard = { ...this._currentCard, [field]: this._editedCard[field] }
1342
+ this._disableEditMode(field)
1418
1343
  }
1419
1344
 
1420
1345
  showToast({ type, message }) {