@things-factory/operato-wms 4.3.49 → 4.3.52

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.
@@ -1,14 +1,18 @@
1
1
  import '@things-factory/biz-ui'
2
+ import '@things-factory/warehouse-ui'
2
3
  import './validate-gan-popup'
3
4
  import './validate-ro-popup'
4
5
 
6
+ import gql from 'graphql-tag'
5
7
  import { css, html } from 'lit-element'
6
8
  import XLSX from 'xlsx'
7
9
 
8
10
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
9
11
  import { i18next, localize } from '@things-factory/i18n-base'
10
12
  import { openPopup } from '@things-factory/layout-base'
11
- import { PageView } from '@things-factory/shell'
13
+ import { client, PageView, navigate, CustomAlert } from '@things-factory/shell'
14
+ import { fetchSettingRule } from '../../fetch-setting-value'
15
+ import { sleep } from '@things-factory/utils'
12
16
 
13
17
  class BulkOperation extends localize(i18next)(PageView) {
14
18
  static get styles() {
@@ -137,11 +141,15 @@ class BulkOperation extends localize(i18next)(PageView) {
137
141
  return {
138
142
  _ganBizplaceId: String,
139
143
  _ganBizplaceName: String,
144
+ _ganPartnerDomainId: String,
140
145
  _ganDocument: Object,
141
146
  _roDocument: Object,
142
147
  _rawData: Array,
143
148
  _roBizplaceId: String,
144
- _roBizplaceName: String
149
+ _roBizplaceName: String,
150
+ ganProcessingSetting: String,
151
+ _bufferLocationId: Object,
152
+ _arrivalNotices: Array
145
153
  }
146
154
  }
147
155
 
@@ -348,6 +356,48 @@ class BulkOperation extends localize(i18next)(PageView) {
348
356
  } else this._showToast({ level: 'error', message: i18next.t('text.please_attach_the_file') })
349
357
  }
350
358
 
359
+ async _assignBufferLocation() {
360
+ try {
361
+ this._validateBufferLocation()
362
+
363
+ let result = await CustomAlert({
364
+ title: i18next.t('title.are_you_sure'),
365
+ text: i18next.t('text.assign_warehouse'),
366
+ confirmButton: { text: i18next.t('button.confirm') },
367
+ cancelButton: { text: i18next.t('button.cancel') }
368
+ })
369
+
370
+ if (!result.value) return
371
+
372
+ const response = await client.mutate({
373
+ mutation: gql`
374
+ mutation generateArrivalNoticeWorksheet($arrivalNoticeNos: [String!], $bufferLocation: ObjectRef!) {
375
+ generateArrivalNoticeWorksheet(arrivalNoticeNos: $arrivalNoticeNos, bufferLocation: $bufferLocation) {
376
+ unloadingWorksheet {
377
+ name
378
+ }
379
+ }
380
+ }
381
+ `,
382
+ variables: {
383
+ arrivalNoticeNos: this._arrivalNotices,
384
+ bufferLocation: { id: this._bufferLocationId }
385
+ }
386
+ })
387
+
388
+ if (!response.errors) {
389
+ navigate(`inbound_worksheets`)
390
+ this._showToast({ message: i18next.t('text.warehouse_is_assigned') })
391
+ }
392
+ } catch (e) {
393
+ this._showToast(e)
394
+ }
395
+ }
396
+
397
+ _validateBufferLocation() {
398
+ if (!this._bufferLocationId) throw new Error(i18next.t('text.warehouse_is_not_assigned'))
399
+ }
400
+
351
401
  _validateArrivalNotice(records) {
352
402
  /* validate excel that user uploaded */
353
403
  openPopup(
@@ -386,7 +436,13 @@ class BulkOperation extends localize(i18next)(PageView) {
386
436
  .padStart(2, 0)}`
387
437
  }
388
438
  })}
439
+ .ganProcessing=${this.ganProcessingSetting}
389
440
  .bizplaceId=${this._ganBizplaceId}
441
+ @gan-processing-setting="${async e => {
442
+ this._arrivalNotices = e.detail
443
+ await sleep(10)
444
+ this._openBufferSelector()
445
+ }}"
390
446
  ></validate-gan-popup>
391
447
  `,
392
448
  {
@@ -455,15 +511,18 @@ class BulkOperation extends localize(i18next)(PageView) {
455
511
  openPopup(
456
512
  html`
457
513
  <popup-partner-bizplaces-selector
458
- @selected="${e => {
459
- let { id, name } = e.detail
514
+ @selected="${async e => {
515
+ let { id, name, domain } = e.detail
460
516
  if (source == 'GAN') {
461
517
  this._ganBizplaceId = id
462
518
  this._ganBizplaceName = name
519
+ this._ganPartnerDomainId = domain.id
463
520
  } else if (source == 'RO') {
464
521
  this._roBizplaceId = id
465
522
  this._roBizplaceName = name
466
523
  }
524
+ this.ganProcessingSetting =
525
+ (await fetchSettingRule('gan-order-processing', this._ganPartnerDomainId)) || '-1'
467
526
  }}"
468
527
  ></popup-partner-bizplaces-selector>
469
528
  `,
@@ -475,6 +534,24 @@ class BulkOperation extends localize(i18next)(PageView) {
475
534
  )
476
535
  }
477
536
 
537
+ _openBufferSelector() {
538
+ openPopup(
539
+ html`
540
+ <buffer-location-selector
541
+ @selected="${async e => {
542
+ this._bufferLocationId = `${e.detail.id}`
543
+ await this._assignBufferLocation()
544
+ }}"
545
+ ></buffer-location-selector>
546
+ `,
547
+ {
548
+ backdrop: true,
549
+ size: 'large',
550
+ title: i18next.t('title.select_warehouse')
551
+ }
552
+ )
553
+ }
554
+
478
555
  _getStdDateStr(date) {
479
556
  if (isNaN(date.getFullYear())) return ''
480
557
  else {
@@ -14,7 +14,8 @@ class ValidateGanPopup extends localize(i18next)(LitElement) {
14
14
  return {
15
15
  _ganConfig: Object,
16
16
  bizplaceId: String,
17
- records: Array
17
+ records: Array,
18
+ ganProcessing: String
18
19
  }
19
20
  }
20
21
 
@@ -313,6 +314,34 @@ class ValidateGanPopup extends localize(i18next)(LitElement) {
313
314
  try {
314
315
  this._validateArrivalNotices()
315
316
 
317
+ if (rawArrivalNotices) {
318
+ rawArrivalNotices = rawArrivalNotices.map(raw => {
319
+ return {
320
+ refNo: raw.refNo,
321
+ refNo2: raw.refNo2,
322
+ refNo3: raw.refNo3,
323
+ etaDate: raw.etaDate,
324
+ truckNo: raw.truckNo,
325
+ ownTransport: !!raw.truckNo || false,
326
+ looseItem: !!raw.looseItem || false,
327
+ importCargo: !!raw.importCargo || false,
328
+ container: (!!raw.containerNo && !!raw.containerSize) || false,
329
+ containerNo: raw.containerNo,
330
+ containerSize: raw.containerSize,
331
+ sku: raw.sku,
332
+ batchId: raw.batchId,
333
+ batchIdRef: raw.batchIdRef,
334
+ packingType: raw.packingType,
335
+ packingSize: raw.packingSize,
336
+ uom: raw.uom,
337
+ packQty: raw.packQty,
338
+ palletQty: raw.palletQty,
339
+ unitPrice: raw.unitPrice,
340
+ manufactureDate: new Date(parseInt(raw.manufactureDate))
341
+ }
342
+ })
343
+ }
344
+
316
345
  const response = await client.mutate({
317
346
  mutation: gql`
318
347
  mutation bulkGenerateArrivalNotices($rawArrivalNotices: [NewArrivalNotice!], $bizplaceId: String!) {
@@ -324,38 +353,18 @@ class ValidateGanPopup extends localize(i18next)(LitElement) {
324
353
  }
325
354
  `,
326
355
  variables: {
327
- rawArrivalNotices: rawArrivalNotices.map(raw => {
328
- return {
329
- refNo: raw.refNo,
330
- refNo2: raw.refNo2,
331
- refNo3: raw.refNo3,
332
- etaDate: raw.etaDate,
333
- truckNo: raw.truckNo,
334
- ownTransport: !!raw.truckNo || false,
335
- looseItem: !!raw.looseItem || false,
336
- importCargo: !!raw.importCargo || false,
337
- container: (!!raw.containerNo && !!raw.containerSize) || false,
338
- containerNo: raw.containerNo,
339
- containerSize: raw.containerSize,
340
- sku: raw.sku,
341
- batchId: raw.batchId,
342
- batchIdRef: raw.batchIdRef,
343
- packingType: raw.packingType,
344
- packingSize: raw.packingSize,
345
- uom: raw.uom,
346
- packQty: raw.packQty,
347
- palletQty: raw.palletQty,
348
- unitPrice: raw.unitPrice,
349
- manufactureDate: new Date(parseInt(raw.manufactureDate))
350
- }
351
- }),
356
+ rawArrivalNotices,
352
357
  bizplaceId
353
358
  }
354
359
  })
355
360
 
356
361
  if (!response.errors) {
357
362
  this._showToast({ message: i18next.t('text.arrival_notices_created') })
358
- history.back()
363
+
364
+ if (this.ganProcessing == '1') {
365
+ let arrivalNoticeNos = response.data.bulkGenerateArrivalNotices.items.map(itm => itm.name)
366
+ this.dispatchEvent(new CustomEvent('gan-processing-setting', { detail: arrivalNoticeNos }))
367
+ }
359
368
  } else {
360
369
  let invalidDataError = response.errors.find(err => err.extensions.exception.errorCode == 'ivd1')
361
370
  if (invalidDataError) {
@@ -366,6 +375,7 @@ class ValidateGanPopup extends localize(i18next)(LitElement) {
366
375
  } catch (e) {
367
376
  this._showToast(e)
368
377
  } finally {
378
+ history.back()
369
379
  this.dataGrist.hideSpinner()
370
380
  await sleep(1)
371
381
  }
@@ -69,7 +69,8 @@ export const ORDER_STATUS = {
69
69
 
70
70
  export const MANIFEST_STATUS = {
71
71
  OPEN: { name: 'open', value: 'OPEN' },
72
- CLOSED: { name: 'closed', value: 'CLOSED' }
72
+ CLOSED: { name: 'closed', value: 'CLOSED' },
73
+ IN_QUEUE: { name: 'in_queue', value: 'IN_QUEUE' }
73
74
  }
74
75
 
75
76
  export const DISPATCHMENT_STATUS = {
@@ -6,9 +6,10 @@ import { css, html } from 'lit-element'
6
6
 
7
7
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
8
8
  import { i18next, localize } from '@things-factory/i18n-base'
9
- import { client, navigate, PageView } from '@things-factory/shell'
9
+ import { client, navigate, PageView, CustomAlert } from '@things-factory/shell'
10
10
  import { CommonButtonStyles } from '@things-factory/styles'
11
11
  import { isMobileDevice } from '@things-factory/utils'
12
+ import { ORDER_STATUS } from '../constants'
12
13
 
13
14
  class CreateLoadingManifest extends localize(i18next)(PageView) {
14
15
  static get styles() {
@@ -180,6 +181,20 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
180
181
  label: true,
181
182
  header: i18next.t('field.transporter'),
182
183
  width: 200
184
+ },
185
+ {
186
+ type: 'string',
187
+ name: 'bizplaceName',
188
+ label: true,
189
+ header: i18next.t('field.company'),
190
+ width: 200
191
+ },
192
+ {
193
+ type: 'string',
194
+ name: 'status',
195
+ label: true,
196
+ header: i18next.t('field.status'),
197
+ width: 200
183
198
  }
184
199
  ]
185
200
  }
@@ -189,40 +204,50 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
189
204
  try {
190
205
  this._validateTrackingNo()
191
206
 
192
- const filters = [
193
- { name: 'trackingNo', operator: 'eq', value: this.trackingNoInput.value.trim() },
194
- { name: 'manifest_id', operator: 'is_null', value: '' },
195
- { name: 'releaseGoodOnly', operator: '', value: '' },
196
- { name: 'status', operator: 'in', value: ['PACKING', 'DONE'] }
197
- ]
198
207
  const response = await client.query({
199
208
  query: gql`
200
- query releaseGoods($filters: [Filter!], $sortings: [Sorting!]) {
201
- releaseGoods(filters: $filters, sortings: $sortings) {
202
- items {
209
+ query releaseGood($trackingNo: String) {
210
+ releaseGood(trackingNo: $trackingNo) {
211
+ id
212
+ name
213
+ trackingNo
214
+ refNo
215
+ transporter
216
+ bizplace {
203
217
  id
204
218
  name
205
- trackingNo
206
- refNo
207
- transporter
208
219
  }
220
+ status
209
221
  }
210
222
  }
211
223
  `,
212
- variables: { filters, sortings: [] }
224
+ variables: { trackingNo: this.trackingNoInput.value.trim() }
213
225
  })
214
-
215
226
  if (!response.errors) {
216
- const releaseGood = (response.data.releaseGoods.items || []).map(record => {
217
- return {
218
- ...record,
219
- orderNo: record?.refNo
220
- }
221
- })[0]
227
+ const releaseGood = response.data.releaseGood
222
228
 
223
229
  if (releaseGood && !this.shippingData.records.map(record => record.refNo).includes(releaseGood.refNo)) {
224
230
  let manifestItems = this.shippingData.records || []
225
- manifestItems.push({ ...releaseGood })
231
+
232
+ if (
233
+ releaseGood?.status === ORDER_STATUS.CANCELLED.value ||
234
+ releaseGood?.status === ORDER_STATUS.PENDING_CANCEL.value
235
+ ) {
236
+ let answer = await CustomAlert({
237
+ type: 'warning',
238
+ title: i18next.t('title.order(s)_is_at_pending_cancelled_or_cancelled'),
239
+ text: i18next.t('text.do_you_want_to_ignore'),
240
+ confirmButton: { text: i18next.t('button.ignore') },
241
+ cancelButton: { text: i18next.t('button.cancel') }
242
+ })
243
+
244
+ if (!answer?.value) {
245
+ this._clearTrackingNoInput()
246
+ return
247
+ }
248
+ }
249
+
250
+ manifestItems.push({ ...releaseGood, bizplaceName: releaseGood.bizplace.name, orderNo: releaseGood.refNo })
226
251
  this.shippingData = { records: manifestItems }
227
252
  } else {
228
253
  this._showToast({ message: i18next.t('text.tracking_no_already_exist_in_manifest_list') })
@@ -54,17 +54,20 @@ class DispatcherVerificationPopup extends localize(i18next)(LitElement) {
54
54
  }
55
55
 
56
56
  _updateManifestDispatchement() {
57
- this._validateDispatchmentUpdate()
58
- let dispatchment = this._serializeForm(this.dispatchmentForm)
59
- this.dispatchEvent(
60
- new CustomEvent('dispatch', {
61
- detail: {
62
- dispatcherName: dispatchment.dispatcherName,
63
- dispatcherIdentity: dispatchment.dispatcherIdentity
64
- }
65
- })
66
- )
67
- history.back()
57
+ if (this.dispatchmentForm.checkValidity()) {
58
+ let dispatchment = this._serializeForm(this.dispatchmentForm)
59
+ this.dispatchEvent(
60
+ new CustomEvent('dispatch', {
61
+ detail: {
62
+ dispatcherName: dispatchment.dispatcherName,
63
+ dispatcherIdentity: dispatchment.dispatcherIdentity
64
+ }
65
+ })
66
+ )
67
+ history.back()
68
+ } else {
69
+ this._showToast({ message: i18next.t('text.form_has_invalid_input') })
70
+ }
68
71
  }
69
72
 
70
73
  _serializeForm(form) {
@@ -78,8 +81,16 @@ class DispatcherVerificationPopup extends localize(i18next)(LitElement) {
78
81
  return obj
79
82
  }
80
83
 
81
- _validateDispatchmentUpdate() {
82
- this.dispatchmentForm.checkValidity()
84
+ _showToast({ type, message }) {
85
+ document.dispatchEvent(
86
+ new CustomEvent('notify', {
87
+ detail: {
88
+ type,
89
+ message,
90
+ option: { timer: 1000 }
91
+ }
92
+ })
93
+ )
83
94
  }
84
95
  }
85
96