@things-factory/operato-wms 4.3.428 → 4.3.430

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.
@@ -970,6 +970,11 @@ class UnloadProduct extends connect(store)(localize(i18next)(PageView)) {
970
970
  _resetInput() {
971
971
  if (this._selectedOrderProduct?.isRequiredCheckExpiry) this.expDateInput.value = null
972
972
 
973
+ if (this._isRequiredCheckExpiry) {
974
+ this.expDateInput.value = null
975
+ this._focusOnExpiryDateInput()
976
+ }
977
+
973
978
  if (this._enableCartonLabel) {
974
979
  if (this._isRequireSerialNumberScanningInbound) {
975
980
  if (this.cartonInput.value == '') {
@@ -7,28 +7,14 @@ import '../inventory/serial-number-list-popup'
7
7
  import '../components/select-product-popup'
8
8
 
9
9
  import gql from 'graphql-tag'
10
- import {
11
- css,
12
- html
13
- } from 'lit-element'
10
+ import { css, html } from 'lit-element'
14
11
  import { connect } from 'pwa-helpers/connect-mixin'
15
12
 
16
13
  import { DirectPrinter } from '@things-factory/barcode-base'
17
- import {
18
- i18next,
19
- localize
20
- } from '@things-factory/i18n-base'
14
+ import { i18next, localize } from '@things-factory/i18n-base'
21
15
  import { openPopup } from '@things-factory/layout-base'
22
- import {
23
- client,
24
- CustomAlert,
25
- PageView,
26
- store
27
- } from '@things-factory/shell'
28
- import {
29
- CommonButtonStyles,
30
- ScrollbarStyles
31
- } from '@things-factory/styles'
16
+ import { client, CustomAlert, PageView, store } from '@things-factory/shell'
17
+ import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
32
18
  import { isMobileDevice } from '@things-factory/utils'
33
19
 
34
20
  import { fetchSettingRule } from '../../fetch-setting-value'
@@ -1354,11 +1340,11 @@ class InventoryAdjustment extends connect(store)(localize(i18next)(PageView)) {
1354
1340
 
1355
1341
  data = data.map(item => {
1356
1342
  if (item?.expirationDate !== null && item?.expirationDate !== '') {
1357
- item.expirationDate = new Date(item.expirationDate).getTime()
1343
+ item.expirationDate = this.toUtcTimestamp(item.expirationDate)
1358
1344
  }
1359
1345
 
1360
1346
  if (item?.manufactureDate !== null && item?.manufactureDate !== '') {
1361
- item.manufactureDate = new Date(item.manufactureDate).getTime()
1347
+ item.manufactureDate = this.toUtcTimestamp(item.manufactureDate)
1362
1348
  }
1363
1349
 
1364
1350
  return {
@@ -1740,6 +1726,12 @@ class InventoryAdjustment extends connect(store)(localize(i18next)(PageView)) {
1740
1726
  throw new Error(i18next.t('text.adjustment_note_is_required_kindly_fill_in_the_adjustment_note_to_continue'))
1741
1727
  }
1742
1728
  }
1729
+
1730
+ toUtcTimestamp(dateInput) {
1731
+ const date = new Date(dateInput)
1732
+ const utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0))
1733
+ return utcDate.getTime()
1734
+ }
1743
1735
  }
1744
1736
 
1745
1737
  window.customElements.define('inventory-adjustment', InventoryAdjustment)
@@ -239,13 +239,13 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
239
239
  gutterName: 'button',
240
240
  icon: 'close',
241
241
  handlers: {
242
- click: (columns, data, column, record, rowIndex) => {
242
+ click: async (columns, data, column, record, rowIndex) => {
243
243
  if (this.shippingData.records.length > 0 && record.name) {
244
244
  const newData = data.records.filter((_, idx) => idx !== rowIndex)
245
- this.shippingData = { ...this.shippingData, records: newData }
246
245
  this._removePackages.push(record.name)
246
+ await this._updateManifestDetails()
247
+ this.shippingData = { ...this.shippingData, records: newData }
247
248
  this.scannedNo -= 1
248
- this._updateManifestDetails()
249
249
  this.shippingGrist.dirtyData.records = newData
250
250
  }
251
251
  }
@@ -409,6 +409,8 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
409
409
  return
410
410
  }
411
411
 
412
+ const trackingNoAdded = await this._addTrackingNo()
413
+
412
414
  manifestItems.push({
413
415
  ...orderPackage,
414
416
  bizplaceName: orderPackage.bizplace.name,
@@ -416,10 +418,10 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
416
418
  orderNo: orderPackage.releaseGood.refNo
417
419
  })
418
420
  this.shippingData = { records: manifestItems }
419
- if (this.trackingNoInput.value) {
421
+
422
+ if (trackingNoAdded) {
420
423
  this.scannedNo += 1
421
424
  }
422
- this._addTrackingNo()
423
425
 
424
426
  this._playSound()
425
427
  } else {
@@ -459,12 +461,16 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
459
461
  if (!response.errors) {
460
462
  this.trackingNoInput.value = ''
461
463
  this._focusOnTrackingNoInput()
464
+ return true
462
465
  } else {
463
466
  let errorMessage = response.errors[0].message
467
+
464
468
  if (errorMessage.includes('amp;')) {
465
469
  response.errors[0].message = errorMessage.replace('amp;', '')
466
470
  this._showToast({ message: response.errors[0].message })
467
471
  }
472
+ if (errorMessage.includes('manifest has been dispatch')) this._playSound('error')
473
+ throw new Error(i18next.t('error.this_manifest_has_been_dispatch'))
468
474
  }
469
475
  }
470
476
 
@@ -548,7 +554,7 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
548
554
  }
549
555
 
550
556
  async _updateManifestDetails() {
551
- if ((!this._selectedStatus || this._selectedStatus == this._status) && this._removePackages?.length == 0) {
557
+ if (this._removePackages?.length == 0) {
552
558
  return
553
559
  }
554
560
 
@@ -579,11 +585,18 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
579
585
  }
580
586
  })
581
587
 
588
+ let errorMessage = response?.errors?.[0]?.message ? response.errors[0].message : ''
582
589
  if (!response.errors) {
583
590
  this._showToast({ message: i18next.t('text.tracking_no_deleted') })
584
591
  }
592
+
593
+ if (errorMessage?.includes('manifest has been dispatch')) {
594
+ this._playSound('error')
595
+ throw new Error(i18next.t('error.this_manifest_has_been_dispatch'))
596
+ }
585
597
  } catch (e) {
586
598
  this._showToast(e)
599
+ throw e
587
600
  }
588
601
  }
589
602
 
@@ -658,19 +671,23 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
658
671
  variables: { patches: records, manifestId: this.selectedManifest.id }
659
672
  })
660
673
 
661
- let updatedRecords = response.data.submitTrackingNos.map(itm => {
662
- return {
663
- ...itm,
664
- bizplaceName: itm.bizplace.name,
665
- refNo: itm.releaseGood.refNo
674
+ if (!response.errors) {
675
+ let updatedRecords = response.data.submitTrackingNos.map(itm => {
676
+ return {
677
+ ...itm,
678
+ bizplaceName: itm.bizplace.name,
679
+ refNo: itm.releaseGood.refNo
680
+ }
681
+ })
682
+
683
+ this.shippingData = {
684
+ records: [...this.shippingData.records, ...updatedRecords]
666
685
  }
667
- })
668
686
 
669
- this.shippingData = {
670
- records: [...this.shippingData.records, ...updatedRecords]
687
+ this.scannedNo = this.shippingData.records.length
688
+ } else {
689
+ throw new Error(i18next.t('error.this_manifest_has_been_dispatch'))
671
690
  }
672
-
673
- this.scannedNo = this.shippingData.records.length
674
691
  }
675
692
 
676
693
  history.back()
@@ -681,6 +698,7 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
681
698
  } catch (e) {
682
699
  this._showToast(e)
683
700
  history.back()
701
+ throw e
684
702
  }
685
703
  }
686
704
 
@@ -3,31 +3,17 @@ import '@things-factory/grist-ui'
3
3
  import './dispatcher-verification-popup'
4
4
 
5
5
  import gql from 'graphql-tag'
6
- import {
7
- css,
8
- html
9
- } from 'lit-element'
6
+ import { css, html } from 'lit-element'
10
7
 
11
8
  import { GhostPrint } from '@operato/ghost-print'
12
9
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
13
- import {
14
- i18next,
15
- localize
16
- } from '@things-factory/i18n-base'
10
+ import { i18next, localize } from '@things-factory/i18n-base'
17
11
  import { openPopup } from '@things-factory/layout-base'
18
- import {
19
- client,
20
- CustomAlert,
21
- navigate,
22
- PageView
23
- } from '@things-factory/shell'
12
+ import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
24
13
  import { CommonButtonStyles } from '@things-factory/styles'
25
14
  import { isMobileDevice } from '@things-factory/utils'
26
15
 
27
- import {
28
- MANIFEST_STATUS,
29
- ORDER_STATUS
30
- } from '../constants'
16
+ import { MANIFEST_STATUS, ORDER_STATUS } from '../constants'
31
17
 
32
18
  class LoadingManifestDetail extends localize(i18next)(PageView) {
33
19
  static get styles() {
@@ -97,6 +83,12 @@ class LoadingManifestDetail extends localize(i18next)(PageView) {
97
83
  padding-bottom: 0px;
98
84
  }
99
85
 
86
+ .refresh-btn {
87
+ font-size: 26px !important;
88
+ float: right !important;
89
+ margin-right: 10px !important;
90
+ }
91
+
100
92
  [hidden] {
101
93
  display: none;
102
94
  }
@@ -239,9 +231,13 @@ class LoadingManifestDetail extends localize(i18next)(PageView) {
239
231
  <div class="grist">
240
232
  <h2>
241
233
  <mwc-icon>list_alt</mwc-icon>${i18next.t('title.manifest_items')}
242
- ${this._showReset ? html`<mwc-icon @click=${e => this.dataGrist.fetch()}>sync</mwc-icon>` : ''}
234
+ ${
235
+ this._showReset
236
+ ? html`<mwc-icon class="refresh-btn" @click=${e => this.dataGrist.fetch()}>sync</mwc-icon>`
237
+ : ''
238
+ }
243
239
  </h2>
244
-
240
+
245
241
  <data-grist
246
242
  .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
247
243
  .config=${this.shippingGristConfig}
@@ -493,6 +489,7 @@ class LoadingManifestDetail extends localize(i18next)(PageView) {
493
489
 
494
490
  async _updateManifestDetails() {
495
491
  if ((!this._selectedStatus || this._selectedStatus == this._status) && this._removePackages?.length == 0) {
492
+ this._showToast({ message: i18next.t('text.manifest_has_been_updated') })
496
493
  return
497
494
  }
498
495
  const response = await client.mutate({
@@ -1229,10 +1229,10 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
1229
1229
  width: 150
1230
1230
  },
1231
1231
  {
1232
- type: 'integer',
1232
+ type: 'float',
1233
1233
  name: 'newUomValue',
1234
1234
  header: i18next.t('field.uom_value_sku', { sku: 'NEW SKU' }),
1235
- record: { editable: true },
1235
+ record: { editable: !this._strictProductSelection },
1236
1236
  width: 150
1237
1237
  },
1238
1238
  {
@@ -1518,7 +1518,7 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
1518
1518
  name: 'releaseUomValue',
1519
1519
  header: i18next.t('field.release_uom_value'),
1520
1520
  imex: { header: i18next.t('field.release_uom_value'), key: 'releaseUomValue', width: 25, type: 'float' },
1521
- record: { editable: true, options: { min: 0 } },
1521
+ record: { editable: !this._strictProductSelection, options: { min: 0 } },
1522
1522
  width: 140
1523
1523
  }
1524
1524
  ]
@@ -1682,7 +1682,7 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
1682
1682
  type: 'float',
1683
1683
  name: 'releaseUomValue',
1684
1684
  header: i18next.t('field.release_uom_value'),
1685
- record: { editable: true, options: { min: 0 } },
1685
+ record: { editable: !this._strictProductSelection, options: { min: 0 } },
1686
1686
  width: 100
1687
1687
  }
1688
1688
  ]
@@ -2056,23 +2056,28 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2056
2056
  // changeRecord.vasQty = changeRecord.qty
2057
2057
  changeRecord.outputQty = initialRecord.outputQty ? initialRecord.outputQty : null
2058
2058
  //
2059
- } else if (changedColumn === 'outputQty' && !this._strictProductSelection) {
2059
+ } else if (changedColumn === 'outputQty') {
2060
2060
  if (changeRecord.outputQty <= 0 || isNaN(changeRecord.outputQty)) {
2061
2061
  throw new Error(i18next.t('text.invalid_quantity_input'))
2062
- } else if (initialRecord.outputQty == null) {
2063
- const totalUomValue = changeRecord.outputQty * (changeRecord.newUomValue / changeRecord.qty)
2064
- changeRecord.newUomValue = totalUomValue
2065
2062
  } else {
2066
- const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / initialRecord.outputQty)
2067
- changeRecord.newUomValue = totalUomValue
2063
+ const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / changeRecord.qty)
2064
+ changeRecord.newUomValue = totalUomValue.toFixed(2)
2068
2065
  }
2069
2066
  if (isNaN(changeRecord.newUomValue)) {
2070
2067
  changeRecord.newUomValue = null
2071
2068
  }
2072
- } else if (changedColumn === 'newUomValue') {
2069
+ } else if (changedColumn === 'newUomValue' && !this._strictProductSelection) {
2073
2070
  if (changeRecord.newUomValue <= 0 || isNaN(changeRecord.newUomValue)) {
2074
2071
  throw new Error(i18next.t('text.invalid_quantity_input'))
2075
2072
  }
2073
+ const decimalPlaces = (changeRecord.newUomValue.toString().split('.')[1] || '').length
2074
+
2075
+ if (decimalPlaces > 2) {
2076
+ throw new Error(i18next.t('text.cannot_add_more_than_2_decimal_places'))
2077
+ }
2078
+
2079
+ const totalOutputQty = changeRecord.newUomValue / initialRecord.newOrgUomValue
2080
+ changeRecord.outputQty = Math.trunc(totalOutputQty) //return only the whole number
2076
2081
  } else if (changedColumn === 'vasQty') {
2077
2082
  if (changeRecord.vasQty <= 0 || isNaN(changeRecord.vasQty)) {
2078
2083
  throw new Error(i18next.t('text.invalid_quantity_input'))
@@ -2419,7 +2424,7 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2419
2424
  newProductDetail: ov.newProductDetailId,
2420
2425
  newPackingType: ov.newPackingType,
2421
2426
  newUom: ov.newUom,
2422
- newUomValue: ov.newUomValue,
2427
+ newUomValue: parseFloat(ov.newUomValue),
2423
2428
  outputQty: ov.outputQty ? ov.outputQty : ov.qty,
2424
2429
  remark: ov.remark,
2425
2430
  orderVasItemsPatch: this.vasGrist.dirtyData.records.reduce((acc, cur) => {
@@ -2563,9 +2568,11 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2563
2568
  if ((record.newPackingType || record.newUomValue || record.newUom) && !record.newSKU)
2564
2569
  throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.new_sku') }))
2565
2570
  if (!record.vasQty) throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.vas_qty') }))
2566
- // enable empty outputQty
2567
- // if (!record.outputQty && record.sku)
2568
- // throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.output_qty') }))
2571
+
2572
+ if (record.outputQty === 0) throw new Error(i18next.t('text.output_qty_must_be_more_than_0'))
2573
+ if (!record.outputQty)
2574
+ throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.output_qty') }))
2575
+
2569
2576
  if (!record.vas) throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.vas') }))
2570
2577
  // allowing repacking to same SKU
2571
2578
  // if (record.productSKU == record.newSKU)
@@ -2720,9 +2727,9 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2720
2727
 
2721
2728
  this.vasGrist.dirtyData.records.map((record, index) => {
2722
2729
  if (index === rowIndex && record.newSKU) {
2723
- if (record.outputQty) {
2724
- record.newUomValue = record.outputQty * record.newUomValue
2725
- } else if (record.qty) {
2730
+ if (record.qty) {
2731
+ record.outputQty = null //clear outputQty if selecting new Sku
2732
+ record.newOrgUomValue = record.newUomValue
2726
2733
  record.newUomValue = record.qty * record.newUomValue
2727
2734
  } else {
2728
2735
  record.newUomValue = null
@@ -5,35 +5,20 @@ import './serial-number-popup'
5
5
  import './order-remark-popup'
6
6
 
7
7
  import gql from 'graphql-tag'
8
- import {
9
- css,
10
- html
11
- } from 'lit-element'
8
+ import { css, html } from 'lit-element'
12
9
  import { connect } from 'pwa-helpers/connect-mixin.js'
13
10
 
14
11
  import { GhostPrint } from '@operato/ghost-print'
15
12
  import { sleep } from '@operato/utils'
16
13
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
17
- import {
18
- i18next,
19
- localize
20
- } from '@things-factory/i18n-base'
14
+ import { i18next, localize } from '@things-factory/i18n-base'
21
15
  import { openPopup } from '@things-factory/layout-base'
22
- import {
23
- client,
24
- CustomAlert,
25
- PageView,
26
- store
27
- } from '@things-factory/shell'
16
+ import { client, CustomAlert, PageView, store } from '@things-factory/shell'
28
17
  import { CommonButtonStyles } from '@things-factory/styles'
29
18
  import { isMobileDevice } from '@things-factory/utils'
30
19
 
31
20
  import { fetchSettingRule } from '../../fetch-setting-value'
32
- import {
33
- ORDER_SOURCES,
34
- PLATFORM,
35
- WORKSHEET_STATUS
36
- } from '../constants'
21
+ import { ORDER_SOURCES, PLATFORM, WORKSHEET_STATUS } from '../constants'
37
22
 
38
23
  class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
39
24
  static get properties() {
@@ -65,7 +50,8 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
65
50
  _scanning: Boolean,
66
51
  _isRequireSerialNumberScanningOutbound: Boolean,
67
52
  _isBatchPicking: Boolean,
68
- _isLmdOption: Boolean
53
+ _isLmdOption: Boolean,
54
+ _awbAttempts: Number
69
55
  }
70
56
  }
71
57
 
@@ -136,13 +122,11 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
136
122
  }
137
123
 
138
124
  if (this.releaseGoodNo && this.source == 'SELLERCRAFT' && this.platform == 'operato' && this.completed) {
139
- if (this.airwayBill) {
140
- actions.push({
141
- title: i18next.t('button.print_airway_bill'),
142
- action: this.printSellercraftDocument.bind(this, 'awb'),
143
- ...CommonButtonStyles.label
144
- })
145
- }
125
+ actions.push({
126
+ title: i18next.t('button.print_airway_bill'),
127
+ action: this.printSellercraftDocument.bind(this, 'awb'),
128
+ ...CommonButtonStyles.label
129
+ })
146
130
 
147
131
  actions.push({
148
132
  title: i18next.t('button.print_invoice'),
@@ -155,13 +139,11 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
155
139
  }
156
140
 
157
141
  if (this.releaseGoodNo && this.source == 'POWRUP' && this.platform == 'operato' && this.completed) {
158
- if (this.airwayBill) {
159
- actions.push({
160
- title: i18next.t('button.print_airway_bill'),
161
- action: this.printPowrupDocument.bind(this, 'awb'),
162
- ...CommonButtonStyles.label
163
- })
164
- }
142
+ actions.push({
143
+ title: i18next.t('button.print_airway_bill'),
144
+ action: this.printPowrupDocument.bind(this, 'awb'),
145
+ ...CommonButtonStyles.label
146
+ })
165
147
 
166
148
  actions.push({
167
149
  title: i18next.t('button.print_invoice'),
@@ -203,13 +185,11 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
203
185
  this.platform == 'operato' &&
204
186
  this.completed
205
187
  ) {
206
- if (this.airwayBill) {
207
- actions.push({
208
- title: i18next.t('button.print_airway_bill'),
209
- action: this.printB2cDocument.bind(this, 'awb'),
210
- ...CommonButtonStyles.label
211
- })
212
- }
188
+ actions.push({
189
+ title: i18next.t('button.print_airway_bill'),
190
+ action: this.printB2cDocument.bind(this, 'awb'),
191
+ ...CommonButtonStyles.label
192
+ })
213
193
 
214
194
  if (this.invoice) {
215
195
  actions.push({
@@ -376,6 +356,7 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
376
356
  this._isRequireSerialNumberScanningOutbound = false
377
357
  this._isBatchPicking = false
378
358
  this._isLmdOption = false
359
+ this._awbAttempts = 0
379
360
  }
380
361
 
381
362
  updated(changedProps) {
@@ -705,6 +686,11 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
705
686
  throw new Error('Unable to find order id, please rescan your order.')
706
687
  }
707
688
 
689
+ // Increment the attempt count
690
+ if (type === 'awb') {
691
+ this._awbAttempts++
692
+ }
693
+
708
694
  // get sellercraft document fetcher function
709
695
  let fetchOrder = async id => {
710
696
  const response = await client.mutate({
@@ -757,36 +743,65 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
757
743
  // print PDF document
758
744
  this.callPrintDialog(convertedPdfUrl)
759
745
  } catch (error) {
760
- this.showToast({ message: 'Waiting for AWB from marketplace. Please retry in a while.' })
746
+ if (this._awbAttempts < 4) {
747
+ this.showToast({
748
+ message: 'Oops! The AWB is not ready yet. Please retry by clicking the Print Airway bill button.'
749
+ })
750
+ } else {
751
+ this.showToast({
752
+ message:
753
+ 'It appears that we are unable to retrieve the AWB from the platform. Please reach out to support for assistance.'
754
+ })
755
+ }
761
756
  }
762
757
  }
763
758
 
764
759
  async printB2cDocument(type) {
765
- let convertedPdfUrl = ''
760
+ try {
761
+ let convertedPdfUrl = ''
766
762
 
767
- if (type == 'invoice') {
768
- let invoice = this.invoice
763
+ // Increment the attempt count for AWB
764
+ if (type === 'awb') {
765
+ if (!this._awbAttempts) this._awbAttempts = 0
766
+ this._awbAttempts++
767
+ }
769
768
 
770
- if (this.isValidHttpUrl(invoice)) {
771
- let url = new URL(window.location)
772
- convertedPdfUrl = `${url.origin}/proxy?url=${invoice}`
773
- } else {
774
- convertedPdfUrl = `${location.origin}/attachment/${invoice}`
769
+ if (type == 'invoice') {
770
+ let invoice = this.invoice
771
+
772
+ if (this.isValidHttpUrl(invoice)) {
773
+ let url = new URL(window.location)
774
+ convertedPdfUrl = `${url.origin}/proxy?url=${invoice}`
775
+ } else {
776
+ convertedPdfUrl = `${location.origin}/attachment/${invoice}`
777
+ }
778
+ } else if (type == 'awb') {
779
+ let airwayBill = this.airwayBill
780
+
781
+ if (airwayBill.includes('partner.shopeemobile.com')) {
782
+ convertedPdfUrl = `/pdf/merge?urls=${airwayBill}`
783
+ } else if (this.isValidHttpUrl(airwayBill)) {
784
+ let url = new URL(window.location)
785
+ convertedPdfUrl = `${url.origin}/proxy?url=${airwayBill}`
786
+ } else {
787
+ convertedPdfUrl = `${location.origin}/attachment/${airwayBill}`
788
+ }
775
789
  }
776
- } else if (type == 'awb') {
777
- let airwayBill = this.airwayBill
778
790
 
779
- if (airwayBill.includes('partner.shopeemobile.com')) {
780
- convertedPdfUrl = `/pdf/merge?urls=${airwayBill}`
781
- } else if (this.isValidHttpUrl(airwayBill)) {
782
- let url = new URL(window.location)
783
- convertedPdfUrl = `${url.origin}/proxy?url=${airwayBill}`
791
+ this.callPrintDialog(convertedPdfUrl)
792
+ } catch (error) {
793
+ // Error handling based on AWB attempts
794
+ if (this._awbAttempts < 4) {
795
+ this.showToast({
796
+ message: 'Oops! The AWB is not ready yet. Please retry by clicking the Print Airway bill button.'
797
+ })
784
798
  } else {
785
- convertedPdfUrl = `${location.origin}/attachment/${airwayBill}`
799
+ this.showToast({
800
+ message:
801
+ 'It appears that we are unable to retrieve the AWB from the platform. Please reach out to support for assistance.'
802
+ })
786
803
  }
787
804
  }
788
-
789
- this.callPrintDialog(convertedPdfUrl)
790
805
  }
791
806
 
792
807
  async printPowrupDocument(type) {
@@ -795,6 +810,11 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
795
810
  throw new Error('Unable to find order id, please rescan your order.')
796
811
  }
797
812
 
813
+ // Increment the attempt count
814
+ if (type === 'awb') {
815
+ this._awbAttempts++
816
+ }
817
+
798
818
  // get powrup document fetcher function
799
819
  let fetchOrder = async id => {
800
820
  const response = await client.mutate({
@@ -847,7 +867,16 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
847
867
  // print PDF document
848
868
  this.callPrintDialog(convertedPdfUrl)
849
869
  } catch (error) {
850
- this.showToast({ message: 'Waiting for AWB from marketplace. Please retry in a while.' })
870
+ if (this._awbAttempts < 4) {
871
+ this.showToast({
872
+ message: 'Oops! The AWB is not ready yet. Please retry by clicking the Print Airway bill button.'
873
+ })
874
+ } else {
875
+ this.showToast({
876
+ message:
877
+ 'It appears that we are unable to retrieve the AWB from the platform. Please reach out to support for assistance.'
878
+ })
879
+ }
851
880
  }
852
881
  }
853
882
 
@@ -891,28 +920,46 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
891
920
  }
892
921
 
893
922
  async printAirwayBill() {
894
- var orderDocInfo = await this.getOrderDocument(this.refNo, 'shippingLabel')
923
+ try {
924
+ // Initialize or increment the AWB attempts
925
+ if (!this._awbAttempts) this._awbAttempts = 0
926
+ this._awbAttempts++
895
927
 
896
- if (orderDocInfo?.length === 0) {
897
- this.showToast({ message: i18next.t('text.no_document_available') })
898
- } else {
899
- let content
900
- if (this.platform == 'shopee' && !orderDocInfo[0]?.isShopeeV2) {
901
- const orderDocUrls = orderDocInfo.map(item => item.airwayBill)
902
- for (var i = 0; i < orderDocUrls.length; i++) {
903
- orderDocUrls[i] = 'urls=' + orderDocUrls[i]
928
+ var orderDocInfo = await this.getOrderDocument(this.refNo, 'shippingLabel')
929
+
930
+ if (orderDocInfo?.length === 0) {
931
+ throw new Error('Document not available')
932
+ } else {
933
+ let content
934
+ if (this.platform == 'shopee' && !orderDocInfo[0]?.isShopeeV2) {
935
+ const orderDocUrls = orderDocInfo.map(item => item.airwayBill)
936
+ for (var i = 0; i < orderDocUrls.length; i++) {
937
+ orderDocUrls[i] = 'urls=' + orderDocUrls[i]
938
+ }
939
+ let mergedURL = orderDocUrls.toString().replace(/,/g, '&')
940
+ content = `/pdf/merge?${mergedURL}`
904
941
  }
905
- let mergedURL = orderDocUrls.toString().replace(/,/g, '&')
906
- content = `/pdf/merge?${mergedURL}`
942
+ // else if (this.platform == 'lazada') {
943
+ // content = atob(orderDocInfo[0].file)
944
+ // }
945
+ else {
946
+ let url = new URL(window.location)
947
+ content = `${url.origin}/proxy?url=${encodeURIComponent(orderDocInfo[0].airwayBill)}`
948
+ }
949
+ this.callPrintDialog(content)
907
950
  }
908
- // else if (this.platform == 'lazada') {
909
- // content = atob(orderDocInfo[0].file)
910
- // }
911
- else {
912
- let url = new URL(window.location)
913
- content = `${url.origin}/proxy?url=${encodeURIComponent(orderDocInfo[0].airwayBill)}`
951
+ } catch (error) {
952
+ // Error handling based on AWB attempts
953
+ if (this._awbAttempts < 4) {
954
+ this.showToast({
955
+ message: 'Oops! The AWB is not ready yet. Please retry by clicking the Print Airway bill button.'
956
+ })
957
+ } else {
958
+ this.showToast({
959
+ message:
960
+ 'It appears that we are unable to retrieve the AWB from the platform. Please reach out to support for assistance.'
961
+ })
914
962
  }
915
- this.callPrintDialog(content)
916
963
  }
917
964
  }
918
965
 
@@ -1115,14 +1162,14 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
1115
1162
  let ids = data.id.split(',').map(id => id.trim())
1116
1163
  let info = worksheetDetailInfos.find(wd => ids.includes(wd.id))
1117
1164
  if (info) {
1118
- if(info?.packedQty <= data.packedQty){
1165
+ if (info?.packedQty <= data.packedQty) {
1119
1166
  let newPackQty = data?.packedQty + 1
1120
1167
  return {
1121
1168
  ...data,
1122
1169
  packingProgress: `${newPackQty} / ${data.releaseQty}`,
1123
- packedQty : newPackQty,
1124
- status : newPackQty === data.releaseQty ? 'DONE' : 'PROCESSING',
1125
- completed : newPackQty === data.releaseQty
1170
+ packedQty: newPackQty,
1171
+ status: newPackQty === data.releaseQty ? 'DONE' : 'PROCESSING',
1172
+ completed: newPackQty === data.releaseQty
1126
1173
  }
1127
1174
  } else {
1128
1175
  }
@@ -1223,9 +1270,7 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
1223
1270
  if (foundOrderInventory) {
1224
1271
  this._selectedOrderInventory = foundOrderInventory
1225
1272
 
1226
- if (
1227
- this._selectedOrderInventory?.packedQty === this._selectedOrderInventory?.releaseQty
1228
- ) {
1273
+ if (this._selectedOrderInventory?.packedQty === this._selectedOrderInventory?.releaseQty) {
1229
1274
  this._selectedOrderInventory = null
1230
1275
  throw new Error(i18next.t('text.scanned_product_status_is_done'))
1231
1276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.428",
3
+ "version": "4.3.430",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -91,7 +91,7 @@
91
91
  "@things-factory/print-ui": "^4.3.381",
92
92
  "@things-factory/product-base": "^4.3.425",
93
93
  "@things-factory/resource-ui": "^4.3.425",
94
- "@things-factory/sales-ui": "^4.3.428",
94
+ "@things-factory/sales-ui": "^4.3.430",
95
95
  "@things-factory/scene-data-transform": "^4.3.381",
96
96
  "@things-factory/scene-excel": "^4.3.381",
97
97
  "@things-factory/scene-firebase": "^4.3.381",
@@ -107,8 +107,8 @@
107
107
  "@things-factory/system-ui": "^4.3.381",
108
108
  "@things-factory/transport-base": "^4.3.425",
109
109
  "@things-factory/tutorial-ui": "^4.3.425",
110
- "@things-factory/warehouse-base": "^4.3.425",
111
- "@things-factory/worksheet-base": "^4.3.428"
110
+ "@things-factory/warehouse-base": "^4.3.430",
111
+ "@things-factory/worksheet-base": "^4.3.430"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@things-factory/builder": "^4.3.381",
@@ -117,5 +117,5 @@
117
117
  "cypress-localstorage-commands": "^1.6.1",
118
118
  "eslint-plugin-cypress": "^2.12.1"
119
119
  },
120
- "gitHead": "c11545fe7af9514d2b8dc64f3506e1c7ab74c2c5"
120
+ "gitHead": "b62b950285aa5cb36af746fa9fe77b7476e4538c"
121
121
  }