@things-factory/operato-wms 3.7.13 → 3.8.1

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 (83) hide show
  1. package/client/pages/adjustment/transfer-inventory.js +364 -158
  2. package/client/pages/bulk-operation/bulk-operation.js +316 -0
  3. package/client/pages/bulk-operation/validate-ro-popup.js +445 -0
  4. package/client/pages/components/select-product-popup.js +1 -1
  5. package/client/pages/constants/inventory.js +1 -0
  6. package/client/pages/constants/location.js +33 -6
  7. package/client/pages/constants/worksheet.js +2 -2
  8. package/client/pages/inbound/inbound-worksheet.js +81 -15
  9. package/client/pages/inbound/putaway-product.js +61 -9
  10. package/client/pages/inbound/putaway-worksheet-generate-popup.js +29 -5
  11. package/client/pages/inbound/unload-product.js +80 -19
  12. package/client/pages/inbound/worksheet-putaway-return.js +14 -5
  13. package/client/pages/inbound/worksheet-putaway.js +13 -8
  14. package/client/pages/inbound/worksheet-unloading-return.js +14 -5
  15. package/client/pages/inventory/inventory-adjustment-approval.js +15 -23
  16. package/client/pages/inventory/inventory-adjustment.js +81 -76
  17. package/client/pages/inventory/inventory-by-product-detail.js +1 -1
  18. package/client/pages/inventory/inventory-by-product.js +1 -1
  19. package/client/pages/inventory/inventory-history-by-pallet.js +1 -1
  20. package/client/pages/inventory/inventory-history.js +2 -2
  21. package/client/pages/inventory/onhand-inventory.js +1 -2
  22. package/client/pages/inventory-check/create-cycle-count.js +1 -6
  23. package/client/pages/master/location-list.js +58 -17
  24. package/client/pages/order/arrival-notice/arrival-notice-detail.js +15 -8
  25. package/client/pages/order/arrival-notice/arrival-notice-list.js +87 -6
  26. package/client/pages/order/arrival-notice/arrival-notice-requests.js +83 -6
  27. package/client/pages/order/arrival-notice/create-arrival-notice.js +23 -2
  28. package/client/pages/order/arrival-notice/duplicate-arrival-notice.js +290 -25
  29. package/client/pages/order/arrival-notice/edit-product-popup.js +36 -5
  30. package/client/pages/order/release-order/b2b/b2b-order-requests.js +7 -7
  31. package/client/pages/order/release-order/b2c/b2c-order-requests.js +65 -5
  32. package/client/pages/order/release-order/release-extra-product-popup.js +12 -4
  33. package/client/pages/order/release-order/release-order-detail.js +1 -1
  34. package/client/pages/order/return-order/create-return-order.js +1 -1
  35. package/client/pages/order/return-order/return-order-detail.js +6 -5
  36. package/client/pages/order/transport-order/delivery-order-list.js +4 -1
  37. package/client/pages/outbound/inventory-assign-popup.js +1 -1
  38. package/client/pages/outbound/merged-outbound-worksheet.js +9 -5
  39. package/client/pages/outbound/picking-product.js +202 -162
  40. package/client/pages/outbound/picking-replacement-popup.js +2 -2
  41. package/client/pages/outbound/single-outbound-worksheet.js +47 -1
  42. package/client/pages/outbound/worksheet-loading.js +14 -5
  43. package/client/pages/outbound/worksheet-picking.js +10 -5
  44. package/client/pages/report/custom-elccl/elccl-inventory-report.js +31 -30
  45. package/client/pages/report/custom-elccl/elccl-inventory-summary-report.js +23 -26
  46. package/client/pages/report/inventory-pallet-storage-report.js +11 -10
  47. package/client/pages/report/inventory-report.js +41 -43
  48. package/client/pages/report/inventory-summary-report.js +25 -28
  49. package/client/route.js +5 -0
  50. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js +1 -1
  51. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js.map +1 -1
  52. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js +1 -1
  53. package/dist-server/graphql/resolvers/index.js +3 -1
  54. package/dist-server/graphql/resolvers/index.js.map +1 -1
  55. package/dist-server/graphql/resolvers/shipping-provider/index.js +6 -0
  56. package/dist-server/graphql/resolvers/shipping-provider/index.js.map +1 -0
  57. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js +20 -0
  58. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js.map +1 -0
  59. package/dist-server/graphql/types/custom/elccl/elccl-inventory-report.js +1 -1
  60. package/dist-server/graphql/types/index.js +5 -2
  61. package/dist-server/graphql/types/index.js.map +1 -1
  62. package/dist-server/graphql/types/shipping-provider/index.js +10 -0
  63. package/dist-server/graphql/types/shipping-provider/index.js.map +1 -0
  64. package/dist-server/graphql/types/shipping-provider/shipping-provider-list.js +13 -0
  65. package/dist-server/graphql/types/shipping-provider/shipping-provider-list.js.map +1 -0
  66. package/dist-server/graphql/types/shipping-provider/shipping-provider.js +13 -0
  67. package/dist-server/graphql/types/shipping-provider/shipping-provider.js.map +1 -0
  68. package/package.json +37 -37
  69. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +4 -2
  70. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +1 -1
  71. package/server/graphql/resolvers/index.ts +3 -1
  72. package/server/graphql/resolvers/shipping-provider/index.ts +5 -0
  73. package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +20 -0
  74. package/server/graphql/types/custom/elccl/elccl-inventory-report.ts +1 -1
  75. package/server/graphql/types/index.ts +5 -2
  76. package/server/graphql/types/shipping-provider/index.ts +8 -0
  77. package/server/graphql/types/shipping-provider/shipping-provider-list.ts +7 -0
  78. package/server/graphql/types/shipping-provider/shipping-provider.ts +7 -0
  79. package/things-factory.config.js +6 -0
  80. package/translations/en.json +27 -0
  81. package/translations/ko.json +84 -36
  82. package/translations/ms.json +85 -37
  83. package/translations/zh.json +98 -51
@@ -9,18 +9,20 @@ import { isMobileDevice } from '@things-factory/utils'
9
9
  import gql from 'graphql-tag'
10
10
  import { css, html } from 'lit-element'
11
11
  import { connect } from 'pwa-helpers/connect-mixin.js'
12
- import { CARTON, PALLET } from '../constants'
12
+ import { CARTON, LOT } from '../constants'
13
13
  import '../inbound/select-location-popup'
14
14
 
15
- const INVENTORY_TYPES = { PALLET, CARTON }
15
+ const INVENTORY_TYPES = { LOT, CARTON }
16
16
  class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
17
17
  static get properties() {
18
18
  return {
19
19
  _palletId: String,
20
20
  _cartonId: String,
21
+ _requireNewId: Boolean,
22
+ _selectedInventory: Object,
21
23
  refInventoryType: String,
22
- config: Object,
23
- data: Object
24
+ _data: Object,
25
+ _gristConfig: Object
24
26
  }
25
27
  }
26
28
 
@@ -32,14 +34,28 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
32
34
  :host {
33
35
  display: flex;
34
36
  flex-direction: column;
35
- overflow: hidden;
37
+ overflow: auto;
36
38
  }
37
39
 
38
- data-grist {
40
+ .grist {
41
+ min-height: 180px;
42
+ background-color: var(--main-section-background-color);
43
+ display: flex;
44
+ flex: 1;
39
45
  overflow: auto;
46
+ }
47
+
48
+ data-grist {
40
49
  flex: 1;
41
50
  }
42
51
 
52
+ h2 {
53
+ padding: var(--subtitle-padding);
54
+ font: var(--subtitle-font);
55
+ color: var(--subtitle-text-color);
56
+ border-bottom: var(--subtitle-border-bottom);
57
+ }
58
+
43
59
  .grist h2 {
44
60
  margin: var(--grist-title-margin);
45
61
  border: var(--grist-title-border);
@@ -57,6 +73,50 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
57
73
  h2 + data-grist {
58
74
  padding-top: var(--grist-title-with-grid-padding);
59
75
  }
76
+
77
+ .button-container {
78
+ grid-column: span 12 / auto;
79
+ text-align: center;
80
+ }
81
+
82
+ .button-container > button {
83
+ background-color: var(--button-background-color);
84
+ border: var(--button-border);
85
+ border-radius: var(--button-border-radius);
86
+ padding: var(--button-padding);
87
+ color: var(--button-color);
88
+ font: var(--button-font);
89
+ text-transform: var(--button-text-transform);
90
+ }
91
+
92
+ .input-section {
93
+ flex: 1;
94
+ display: flex;
95
+ }
96
+
97
+ .left-column {
98
+ flex: 1;
99
+ display: flex;
100
+ flex-direction: column;
101
+ }
102
+
103
+ .right-column {
104
+ flex: 1;
105
+ display: flex;
106
+ flex-direction: column;
107
+ }
108
+
109
+ .content-title {
110
+ font-size: var(--fontsize-medium) !important;
111
+ color: var(--title-text-color) !important;
112
+ }
113
+
114
+ .content {
115
+ font-size: 14px !important;
116
+ font-weight: bold !important;
117
+ color: var(--primary-color) !important;
118
+ margin-botton: 5px;
119
+ }
60
120
  `
61
121
  ]
62
122
  }
@@ -65,11 +125,13 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
65
125
  var actions = []
66
126
 
67
127
  if (this._palletId || this._cartonId) {
68
- actions.push({
69
- title: i18next.t('button.transfer'),
70
- action: this._transferInventory.bind(this),
71
- ...CommonButtonStyles.transfer
72
- })
128
+ actions = [
129
+ ...actions,
130
+ {
131
+ title: i18next.t('button.done'),
132
+ action: this.done.bind(this)
133
+ }
134
+ ]
73
135
  }
74
136
 
75
137
  return {
@@ -87,22 +149,54 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
87
149
  return this.shadowRoot.querySelector('form#input-form')
88
150
  }
89
151
 
152
+ get qtyInput() {
153
+ return this.shadowRoot.querySelector('input[name=qty]')
154
+ }
155
+
90
156
  get palletInput() {
91
- return this.shadowRoot.querySelector('barcode-scanable-input[name=palletId]').shadowRoot.querySelector('input')
157
+ return this.shadowRoot.querySelector('barcode-scanable-input[name=palletId]')?.shadowRoot.querySelector('input')
92
158
  }
93
159
 
94
160
  get cartonInput() {
95
- return this.shadowRoot.querySelector('barcode-scanable-input[name=cartonId]').shadowRoot.querySelector('input')
161
+ return this.shadowRoot.querySelector('barcode-scanable-input[name=cartonId]')?.shadowRoot.querySelector('input')
162
+ }
163
+
164
+ get newLotInput() {
165
+ return this.shadowRoot?.querySelector('barcode-scanable-input[name=newLotId]')?.shadowRoot.querySelector('input')
96
166
  }
97
167
 
98
- get fromLocationNameInput() {
99
- return this.shadowRoot.querySelector('input[name=fromLocationName]')
168
+ get newCartonInput() {
169
+ return this.shadowRoot?.querySelector('barcode-scanable-input[name=newCartonId]')?.shadowRoot.querySelector('input')
100
170
  }
101
171
 
172
+ // get fromLocationNameInput() {
173
+ // return this.shadowRoot.querySelector('input[name=fromLocationName]')
174
+ // }
175
+
102
176
  get toLocationNameInput() {
103
177
  return this.shadowRoot
104
178
  .querySelector('barcode-scanable-input[name=toLocationName]')
105
- .shadowRoot.querySelector('input')
179
+ ?.shadowRoot.querySelector('input')
180
+ }
181
+
182
+ focusOnPalletInput() {
183
+ setTimeout(() => this.palletInput.focus(), 100)
184
+ }
185
+
186
+ focusOnCartonInput() {
187
+ setTimeout(() => this.cartonInput.focus(), 100)
188
+ }
189
+
190
+ focusOnToLocationInput() {
191
+ setTimeout(() => this.toLocationNameInput.focus(), 100)
192
+ }
193
+
194
+ focusOnNewLotInput() {
195
+ if (this.newLotInput) setTimeout(() => this.newLotInput.focus(), 100)
196
+ }
197
+
198
+ focusOnNewCartonInput() {
199
+ if (this.newCartonInput) setTimeout(() => this.newCartonInput.focus(), 100)
106
200
  }
107
201
 
108
202
  render() {
@@ -126,9 +220,8 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
126
220
  )}
127
221
  </select>
128
222
 
129
- ${this.refInventoryType === INVENTORY_TYPES.PALLET.value
223
+ ${this.refInventoryType === INVENTORY_TYPES.LOT.value
130
224
  ? html`
131
- <label>${i18next.t('label.lot_id')}</label>
132
225
  <barcode-scanable-input
133
226
  name="palletId"
134
227
  custom-input
@@ -137,107 +230,206 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
137
230
  e.preventDefault()
138
231
  if (this.palletInput.value) {
139
232
  this._palletId = this.palletInput.value
140
- this._fetchInventory(this.palletInput.value)
233
+ this.fetchInventory(this.palletInput.value)
141
234
  }
142
235
  }
143
236
  }}"
144
237
  ></barcode-scanable-input>
145
238
  `
146
- : html` <label>${i18next.t('label.carton_id')}</label>
147
- <barcode-scanable-input
148
- name="cartonId"
149
- custom-input
150
- @keypress="${e => {
151
- if (e.keyCode === 13) {
152
- e.preventDefault()
153
- if (this.cartonInput.value) {
154
- this._cartonId = this.cartonInput.value
155
- this._fetchInventory(this.cartonInput.value)
156
- }
239
+ : html` <barcode-scanable-input
240
+ name="cartonId"
241
+ custom-input
242
+ @keypress="${e => {
243
+ if (e.keyCode === 13) {
244
+ e.preventDefault()
245
+ if (this.cartonInput.value) {
246
+ this._cartonId = this.cartonInput.value
247
+ this.fetchInventory(this.cartonInput.value)
157
248
  }
158
- }}"
159
- ></barcode-scanable-input>`}
160
- </fieldset>
161
- </form>
162
-
163
- <form id="input-form" class="multi-column-form">
164
- <fieldset>
165
- <label>${i18next.t('label.from_location')}</label>
166
- <input
167
- name="fromLocationName"
168
- @keypress="${e => {
169
- if (e.keyCode === 13) {
170
- e.preventDefault()
171
- if (this.fromLocationNameInput.value) {
172
- this._transferInventory()
173
- }
174
- }
175
- }}"
176
- readonly
177
- />
178
-
179
- <label>${i18next.t('label.to_location')}</label>
180
- <barcode-scanable-input
181
- name="toLocationName"
182
- custom-input
183
- @keypress="${e => {
184
- if (e.keyCode === 13) {
185
- e.preventDefault()
186
- if (this.toLocationNameInput.value) {
187
- this._transferInventory()
188
- }
189
- }
190
- }}"
191
- ></barcode-scanable-input>
249
+ }
250
+ }}"
251
+ ></barcode-scanable-input>`}
192
252
  </fieldset>
193
253
  </form>
194
254
 
195
255
  <div class="grist">
196
- <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.inventory')}</h2>
197
- <data-grist .mode=${isMobileDevice() ? 'LIST' : 'GRID'} .config=${this.config} .data=${this.data}></data-grist>
256
+ <data-grist
257
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
258
+ .config=${this._gristConfig}
259
+ .data=${this._data}
260
+ ></data-grist>
198
261
  </div>
199
- `
200
- }
201
262
 
202
- constructor() {
203
- super()
204
- this._palletId = ''
205
- this._cartonId = ''
206
- this.refInventoryType = INVENTORY_TYPES.PALLET.value
263
+ <div class="input-section">
264
+ <div class="left-column">
265
+ <div class="single-column-form">
266
+ <fieldset>
267
+ <label class="content-title">${i18next.t('label.lot_id')}</label>
268
+ <label class="content">${this?._selectedInventory?.palletId || '-'}</label>
269
+
270
+ <label class="content-title">${i18next.t('label.from_location')}</label>
271
+ <label class="content">${this?._selectedInventory?.location?.name || '-'}</label>
272
+
273
+ <label class="content-title">${i18next.t('label.product')}</label>
274
+ <label class="content"
275
+ >${this?._selectedInventory?.product
276
+ ? '(' + this._selectedInventory.product.sku + ') ' + this?._selectedInventory?.product?.name
277
+ : '-'}</label
278
+ >
279
+ <label class="content-title">${i18next.t('label.packing_type')}</label>
280
+ <label class="content">${this?._selectedInventory?.packingType || '-'}</label>
281
+
282
+ <label class="content-title">${i18next.t('label.qty')}</label>
283
+ <label class="content">${this?._selectedInventory?.qty || '-'}</label>
284
+
285
+ <!-- <input name="fromLocationName" readonly /> -->
286
+ </fieldset>
287
+ </div>
288
+ </div>
289
+ <div class="right-column">
290
+ <form id="input-form" class="single-column-form">
291
+ <fieldset>
292
+ <label class="content-title">${i18next.t('label.transfer_qty')}</label>
293
+ <input
294
+ type="number"
295
+ name="qty"
296
+ min="0"
297
+ @change="${e => {
298
+ if (parseInt(this.qtyInput.value) < 0) {
299
+ this.qtyInput.value = 0
300
+ }
301
+ if (this._selectedInventory) {
302
+ if (this._selectedInventory.qty > parseInt(this.qtyInput.value)) {
303
+ this._requireNewId = true
304
+ } else {
305
+ if (parseInt(this.qtyInput.value) > this._selectedInventory.qty) {
306
+ this.qtyInput.value = this._selectedInventory.qty
307
+ }
308
+ this._requireNewId = false
309
+ }
310
+ }
311
+ }}"
312
+ @keypress="${e => {
313
+ if (e.keyCode === 13) {
314
+ e.preventDefault()
315
+ if (parseInt(this.qtyInput.value) < 0) {
316
+ this.qtyInput.value = 0
317
+ } else if (this.qtyInput.value && this.toLocationNameInput.value === '') {
318
+ this.focusOnToLocationInput()
319
+ }
320
+ }
321
+ }}"
322
+ />
323
+
324
+ <label class="content-title">${i18next.t('label.to_location')}</label>
325
+ <barcode-scanable-input
326
+ name="toLocationName"
327
+ custom-input
328
+ @keypress="${e => {
329
+ if (e.keyCode === 13) {
330
+ e.preventDefault()
331
+ if (this.toLocationNameInput.value) {
332
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) {
333
+ if (this._requireNewId) {
334
+ this.focusOnNewLotInput()
335
+ } else {
336
+ this.transferInventory(e)
337
+ }
338
+ } else {
339
+ this.focusOnNewCartonInput()
340
+ }
341
+ // this.transferInventory(e)
342
+ }
343
+ }
344
+ }}"
345
+ ></barcode-scanable-input>
346
+
347
+ ${this.refInventoryType === INVENTORY_TYPES.LOT.value
348
+ ? this._requireNewId
349
+ ? html` <label class="content-title">${i18next.t('label.new_lot_id')}</label>
350
+ <barcode-scanable-input
351
+ name="newLotId"
352
+ custom-input
353
+ @keypress="${e => {
354
+ if (e.keyCode === 13) {
355
+ e.preventDefault()
356
+ this.transferInventory(e)
357
+ }
358
+ }}"
359
+ ></barcode-scanable-input>`
360
+ : ``
361
+ : html`
362
+ <label class="content-title">${i18next.t('label.carton_id')}</label>
363
+ <barcode-scanable-input
364
+ name="newCartonId"
365
+ custom-input
366
+ @keypress="${e => {
367
+ if (e.keyCode === 13) {
368
+ e.preventDefault()
369
+ this.transferInventory(e)
370
+ }
371
+ }}"
372
+ ></barcode-scanable-input>
373
+ `}
374
+
375
+ <div class="button-container">
376
+ <button @click=${this.transferInventory.bind(this)}>${i18next.t('button.transfer')}</button>
377
+ </div>
378
+ </fieldset>
379
+ </form>
380
+ </div>
381
+ </div>
382
+ `
207
383
  }
208
384
 
209
385
  pageInitialized() {
210
- this.config = {
211
- rows: { appendable: false },
212
- pagination: { infinite: true },
386
+ this.refInventoryType = INVENTORY_TYPES.LOT.value
387
+ this._gristConfig = {
213
388
  list: {
214
389
  fields: [
215
- 'batchId',
216
- 'palletId',
217
- 'cartonId',
218
390
  'sku',
219
391
  'product',
392
+ 'cartonId',
393
+ 'palletId',
394
+ 'location',
395
+ 'batchId',
220
396
  'packingType',
221
397
  'packingSize',
222
398
  'qty',
223
399
  'expirationDate'
224
400
  ]
225
401
  },
402
+ pagination: { infinite: true },
403
+ rows: {
404
+ appendable: false,
405
+ handlers: {
406
+ click: async (columns, data, column, record, rowIndex) => {
407
+ try {
408
+ if (this.refInventoryType !== INVENTORY_TYPES.LOT.value) {
409
+ this._selectedInventory = record
410
+ }
411
+ } catch (ex) {
412
+ console.log(ex)
413
+ } finally {
414
+ }
415
+ }
416
+ }
417
+ },
226
418
  columns: [
227
419
  { type: 'gutter', gutterName: 'sequence' },
228
420
  {
229
421
  type: 'string',
230
- name: 'batchId',
422
+ name: 'sku',
231
423
  label: true,
232
- header: i18next.t('field.batch_id'),
424
+ header: i18next.t('field.sku'),
233
425
  width: 150
234
426
  },
235
427
  {
236
- type: 'string',
237
- name: 'palletId',
428
+ type: 'object',
429
+ name: 'product',
238
430
  label: true,
239
- header: i18next.t('field.lot_id'),
240
- width: 150
431
+ header: i18next.t('field.product'),
432
+ width: 200
241
433
  },
242
434
  {
243
435
  type: 'string',
@@ -248,30 +440,37 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
248
440
  },
249
441
  {
250
442
  type: 'string',
251
- name: 'sku',
443
+ name: 'palletId',
252
444
  label: true,
253
- header: i18next.t('field.sku'),
445
+ header: i18next.t('field.lot_id'),
254
446
  width: 150
255
447
  },
256
448
  {
257
449
  type: 'object',
258
- name: 'product',
450
+ name: 'location',
259
451
  label: true,
260
- header: i18next.t('field.product'),
452
+ header: i18next.t('field.location'),
261
453
  width: 200
262
454
  },
455
+ {
456
+ type: 'string',
457
+ name: 'batchId',
458
+ label: true,
459
+ header: i18next.t('field.batch_id'),
460
+ width: 150
461
+ },
263
462
  {
264
463
  type: 'string',
265
464
  name: 'packingType',
266
465
  label: true,
267
- header: i18next.t('field.packing_type'),
466
+ header: i18next.t('field.packing'),
268
467
  width: 150
269
468
  },
270
469
  {
271
470
  type: 'number',
272
471
  name: 'packingSize',
273
472
  label: true,
274
- header: i18next.t('field.packing_size'),
473
+ header: i18next.t('field.size'),
275
474
  width: 80
276
475
  },
277
476
  {
@@ -290,19 +489,23 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
290
489
  }
291
490
  ]
292
491
  }
492
+
493
+ this.clearView()
293
494
  }
294
495
 
295
496
  inventoryTypeChangeHandler(currentType) {
497
+ this.clearView()
498
+
296
499
  this.refInventoryType = currentType
297
500
 
298
- if (this.refInventoryType === INVENTORY_TYPES.PALLET.value) this._focusOnPalletInput()
299
- else this._focusOnCartonInput()
501
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) this.focusOnPalletInput()
502
+ else this.focusOnCartonInput()
300
503
  }
301
504
 
302
- async _fetchInventory(inventoryRefId) {
505
+ async fetchInventory(inventoryRefId) {
303
506
  try {
304
507
  let filters = []
305
- if (this.refInventoryType === INVENTORY_TYPES.PALLET.value) {
508
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) {
306
509
  filters.push({
307
510
  name: 'palletId',
308
511
  operator: 'eq',
@@ -318,7 +521,7 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
318
521
 
319
522
  const response = await client.query({
320
523
  query: gql`
321
- query inventories($filters: [Filter]) {
524
+ query inventories($filters: [Filter!]) {
322
525
  inventories(filters: $filters) {
323
526
  items {
324
527
  id
@@ -335,6 +538,7 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
335
538
  description
336
539
  }
337
540
  qty
541
+ lockedQty
338
542
  location {
339
543
  id
340
544
  name
@@ -354,55 +558,41 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
354
558
 
355
559
  if (!response.errors) {
356
560
  if (response.data.inventories.total == 0) {
357
- if (this.refInventoryType === INVENTORY_TYPES.PALLET.value) this._focusOnPalletInput()
358
- else this._focusOnCartonInput()
561
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) this.focusOnPalletInput()
562
+ else this.focusOnCartonInput()
359
563
  throw new Error(i18next.t('text.wrong_lot_id'))
360
564
  }
361
565
 
362
- this.data = {
566
+ this._data = {
363
567
  records: response.data.inventories.items.map(record => {
364
568
  return {
365
569
  ...record,
366
- sku: record.product.sku
570
+ sku: record.product.sku,
571
+ qty: record.qty - record.lockedQty > 0 ? record.qty - record.lockedQty : 0
367
572
  }
368
573
  })
369
574
  }
370
- const locations = [...new Set(this.data.records.map(record => record.location.name))]
371
- if (locations.length > 1) this._selectLocationPopup(this.data.records.map(record => record.location))
372
- else this.fromLocationNameInput.value = locations[0]
373
575
 
374
- this._focusOnToLocationInput()
576
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) {
577
+ this._selectedInventory = this._data.records[0]
578
+ }
579
+
375
580
  this.updateContext()
376
581
  }
377
582
  } catch (e) {
378
- this._clearView()
379
- if (this.refInventoryType === INVENTORY_TYPES.PALLET.value) this._focusOnPalletInput()
380
- else this._focusOnCartonInput()
381
- this._showToast(e)
583
+ this.clearView()
584
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) this.focusOnPalletInput()
585
+ else this.focusOnCartonInput()
586
+ this.showToast(e)
382
587
  }
383
588
  }
384
589
 
385
- _selectLocationPopup(locations) {
386
- openPopup(
387
- html`
388
- <select-location-popup
389
- .locations="${locations}"
390
- @location-selected="${e => {
391
- this.fromLocationNameInput.value = e.detail.location.name
392
- }}"
393
- ></select-location-popup>
394
- `,
395
- {
396
- backdrop: true,
397
- size: 'medium',
398
- title: i18next.t('title.select_location')
399
- }
400
- )
401
- }
590
+ async transferInventory(e) {
591
+ e.stopPropagation()
592
+ e.preventDefault()
402
593
 
403
- async _transferInventory() {
404
594
  try {
405
- this._validateLocation()
595
+ this._validate()
406
596
 
407
597
  const result = await CustomAlert({
408
598
  title: i18next.t('title.are_you_sure'),
@@ -415,80 +605,96 @@ class TransferInventory extends connect(store)(localize(i18next)(PageView)) {
415
605
  return
416
606
  }
417
607
 
608
+ let variables = {
609
+ originPalletId: this._selectedInventory.palletId,
610
+ palletId: this.refInventoryType === INVENTORY_TYPES.LOT.value ? this.newLotInput?.value : null,
611
+ cartonId: this.refInventoryType === INVENTORY_TYPES.CARTON.value ? this.newCartonInput?.value : null,
612
+ fromLocationName: this._selectedInventory.location.name,
613
+ toLocationName: this.toLocationNameInput.value,
614
+ qty: parseInt(this.qtyInput.value)
615
+ }
616
+
418
617
  const response = await client.mutate({
419
618
  mutation: gql`
420
619
  mutation inventoryTransfer(
620
+ $originPalletId: String!
421
621
  $palletId: String
422
622
  $cartonId: String
423
623
  $fromLocationName: String!
424
624
  $toLocationName: String!
625
+ $qty: Float!
425
626
  ) {
426
627
  inventoryTransfer(
628
+ originPalletId: $originPalletId
427
629
  palletId: $palletId
428
630
  cartonId: $cartonId
429
631
  fromLocationName: $fromLocationName
430
632
  toLocationName: $toLocationName
633
+ qty: $qty
431
634
  )
432
635
  }
433
636
  `,
434
- variables: {
435
- palletId: this.refInventoryType === INVENTORY_TYPES.PALLET.value ? this.palletInput.value : null,
436
- cartonId: this.refInventoryType === INVENTORY_TYPES.CARTON.value ? this.cartonInput.value : null,
437
- fromLocationName: this.fromLocationNameInput.value,
438
- toLocationName: this.toLocationNameInput.value
439
- }
637
+ variables
440
638
  })
441
639
 
442
640
  if (!response.errors) {
443
- this._showToast({ message: i18next.t('text.transfer_location_completed') })
444
- this._clearView()
445
- if (this.refInventoryType === INVENTORY_TYPES.PALLET) this._focusOnPalletInput()
446
- else this._focusOnCartonInput()
641
+ let id = this.refInventoryType === INVENTORY_TYPES.LOT.value ? this._palletId : this._cartonId
642
+ this.showToast({ message: i18next.t('text.transfer_location_completed') })
643
+ this.clearView()
644
+ this.fetchInventory(id)
447
645
  this.updateContext()
448
646
  }
449
647
  } catch (e) {
450
- this._showToast(e)
648
+ this.showToast(e)
451
649
  }
452
650
  }
453
651
 
454
- _validateLocation() {
652
+ _validate() {
653
+ if (!this._selectedInventory) {
654
+ throw new Error(i18next.t('text.please_select_an_inventory'))
655
+ }
656
+
657
+ if (!this.qtyInput.value > 0) {
658
+ throw new Error(i18next.t('text.please_enter_transfer_qty'))
659
+ }
660
+
455
661
  if (!this.toLocationNameInput.value) {
456
- this._focusOnToLocationInput()
662
+ this.focusOnToLocationInput()
457
663
  throw new Error(i18next.t('text.there_is_no_to_location'))
458
664
  }
459
665
 
460
- if (this.fromLocationNameInput.value == this.toLocationNameInput.value) {
666
+ if (this._selectedInventory?.location?.name == this.toLocationNameInput.value) {
461
667
  throw new Error(i18next.t('text.from_location_is_same_as_to_location'))
462
668
  }
463
- }
464
669
 
465
- _focusOnPalletInput() {
466
- setTimeout(() => this.palletInput.focus(), 100)
467
- }
468
-
469
- _focusOnCartonInput() {
470
- setTimeout(() => this.cartonInput.focus(), 100)
471
- }
472
-
473
- _focusOnToLocationInput() {
474
- setTimeout(() => this.toLocationNameInput.focus(), 100)
670
+ if (this.refInventoryType === INVENTORY_TYPES.CARTON.value && this?.cartonInput?.value.trim() == '') {
671
+ throw new Error(i18next.t('text.required_carton_id'))
672
+ }
475
673
  }
476
674
 
477
- _clearView() {
478
- this.inputForm.reset()
479
- this.data = { records: [] }
480
- this.toLocationNameInput.value = ''
481
- if (this.refInventoryType === INVENTORY_TYPES.PALLET.value) {
675
+ done() {
676
+ this.clearView()
677
+ if (this.refInventoryType === INVENTORY_TYPES.LOT.value) {
482
678
  this.palletInput.value = ''
483
679
  this._palletId = ''
484
680
  } else {
485
681
  this.cartonInput.value = ''
486
682
  this.cartonId = ''
487
683
  }
684
+ }
685
+
686
+ clearView() {
687
+ this.inputForm?.reset()
688
+ this._selectedInventory = null
689
+ this._requireNewId = false
690
+ this._data = { records: [] }
691
+ if (this?.toLocationNameInput) this.toLocationNameInput.value = ''
692
+ if (this?.newCartonInput) this.newCartonInput.value = ''
693
+ if (this?.newLotInput) this.newLotInput.value = ''
488
694
  this.updateContext()
489
695
  }
490
696
 
491
- _showToast({ type, message }) {
697
+ showToast({ type, message }) {
492
698
  document.dispatchEvent(
493
699
  new CustomEvent('notify', {
494
700
  detail: {