@things-factory/operato-wms 4.3.67 → 4.3.68

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.
@@ -89,30 +89,30 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
89
89
  var actions = []
90
90
  if (this.releaseGoodNo && this.platform != 'operato' && this.completed && this.trackingNo) {
91
91
  if (this.platform === PLATFORM.LAZADA.value) {
92
+ actions.push({
93
+ title: i18next.t('button.print_airway_bill'),
94
+ action: this.printAirwayBill.bind(this),
95
+ ...CommonButtonStyles.label
96
+ })
97
+
92
98
  actions.push({
93
99
  title: i18next.t('button.print_invoice'),
94
100
  action: this.printInvoice.bind(this),
95
101
  ...CommonButtonStyles.label
96
102
  })
97
103
  }
98
-
99
- actions.push({
100
- title: i18next.t('button.print_airway_bill'),
101
- action: this.printAirwayBill.bind(this),
102
- ...CommonButtonStyles.label
103
- })
104
104
  }
105
105
 
106
- if (this.releaseGoodNo && this.platform == 'operato' && this.airwayBill && this.completed) {
106
+ if (this.releaseGoodNo && this.platform == 'operato' && this.completed) {
107
107
  actions.push({
108
108
  title: i18next.t('button.print_airway_bill'),
109
- action: this.printSellercraftAirwayBill.bind(this),
109
+ action: this.printSellercraftDocument.bind(this, 'awb'),
110
110
  ...CommonButtonStyles.label
111
111
  })
112
112
 
113
113
  actions.push({
114
114
  title: i18next.t('button.print_invoice'),
115
- action: this.printSellercraftInvoice.bind(this),
115
+ action: this.printSellercraftDocument.bind(this, 'invoice'),
116
116
  ...CommonButtonStyles.label
117
117
  })
118
118
  }
@@ -567,23 +567,66 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
567
567
  return otherInfo.deliveryType
568
568
  }
569
569
 
570
- printSellercraftInvoice() {
571
- let url = new URL(window.location)
570
+ async printSellercraftDocument(type) {
571
+ try {
572
+ if (this.releaseGoodId == undefined) {
573
+ throw new Error('Unable to find order id, please rescan your order.')
574
+ }
572
575
 
573
- var convertedPdfUrl = `${url.origin}/proxy?url=${this.invoice}`
574
- this._callPrintDialog(convertedPdfUrl)
575
- }
576
+ // get sellercraft document fetcher function
577
+ let fetchOrder = async id => {
578
+ const response = await client.mutate({
579
+ mutation: gql`
580
+ mutation fetchSellercraftDocument($releaseGoodId: String!) {
581
+ fetchSellercraftDocument(releaseGoodId: $releaseGoodId) {
582
+ airwayBill
583
+ invoice
584
+ }
585
+ }
586
+ `,
587
+ variables: { releaseGoodId: id }
588
+ })
589
+ if (!response.errors) {
590
+ this.invoice = document.invoice
591
+ this.airwayBill = document.airwayBill
576
592
 
577
- printSellercraftAirwayBill() {
578
- let convertedPdfUrl = ''
579
- if (this.airwayBill.includes('partner.shopeemobile.com')) {
580
- convertedPdfUrl = `/pdf/merge?urls=${this.airwayBill}`
581
- } else {
582
- let url = new URL(window.location)
583
- convertedPdfUrl = `${url.origin}/proxy?url=${this.airwayBill}`
584
- }
593
+ return {
594
+ invoice: response.data.fetchSellercraftDocument.invoice,
595
+ airwayBill: response.data.fetchSellercraftDocument.airwayBill
596
+ }
597
+ }
598
+ }
585
599
 
586
- this._callPrintDialog(convertedPdfUrl)
600
+ let convertedPdfUrl = ''
601
+ if (type == 'invoice') {
602
+ let invoice = this.invoice
603
+ // fetch and set variable if invoice not found
604
+ if (!invoice || String.trim(invoice) == '') {
605
+ let document = await fetchOrder(this.releaseGoodId)
606
+ invoice = document.invoice
607
+ }
608
+ let url = new URL(window.location)
609
+ convertedPdfUrl = `${url.origin}/proxy?url=${invoice}`
610
+ } else if (type == 'awb') {
611
+ let airwayBill = this.airwayBill
612
+ // fetch and set variable if awb not found
613
+ if (!airwayBill || String.trim(airwayBill) == '') {
614
+ let document = await fetchOrder(this.releaseGoodId)
615
+ airwayBill = document.airwayBill
616
+ }
617
+ if (airwayBill.includes('partner.shopeemobile.com')) {
618
+ convertedPdfUrl = `/pdf/merge?urls=${airwayBill}`
619
+ } else {
620
+ let url = new URL(window.location)
621
+ convertedPdfUrl = `${url.origin}/proxy?url=${airwayBill}`
622
+ }
623
+ }
624
+
625
+ // print PDF document
626
+ this._callPrintDialog(convertedPdfUrl)
627
+ } catch (error) {
628
+ this._showToast({ message: 'Waiting for AWB from marketplace. Please retry in awhile' })
629
+ }
587
630
  }
588
631
 
589
632
  async printInvoice() {
@@ -615,7 +658,6 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
615
658
  var mergedURL = orderDocUrls.toString().replace(/,/g, '&')
616
659
  var convertedPdfUrl = `/pdf/merge?${mergedURL}`
617
660
  this._callPrintDialog(convertedPdfUrl)
618
-
619
661
  } else if (this.platform == 'lazada') {
620
662
  var decodedHTML = atob(orderDocInfo[0].file)
621
663
  this._callPrintDialog(decodedHTML)
@@ -725,7 +767,7 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
725
767
  async productBarcodePacking() {
726
768
  if (this._scanning) return this._showToast({ message: i18next.t('text.previous_scan_is_executing') })
727
769
  this._scanning = true
728
- return await client.mutate({
770
+ let response = await client.mutate({
729
771
  mutation: gql`
730
772
  mutation scanProductPacking($worksheetDetailName: String!, $productBarcode: String!, $serialNumber: String) {
731
773
  scanProductPacking(
@@ -742,6 +784,8 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
742
784
  this._isRequireSerialNumberScanningOutbound && this._isBatchPicking ? this.serialInput.value.trim() : null
743
785
  }
744
786
  })
787
+
788
+ return response
745
789
  }
746
790
 
747
791
  async commonPacking() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.67",
3
+ "version": "4.3.68",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -109,7 +109,7 @@
109
109
  "@things-factory/transport-base": "^4.3.66",
110
110
  "@things-factory/tutorial-ui": "^4.3.66",
111
111
  "@things-factory/warehouse-base": "^4.3.67",
112
- "@things-factory/worksheet-base": "^4.3.67"
112
+ "@things-factory/worksheet-base": "^4.3.68"
113
113
  },
114
114
  "devDependencies": {
115
115
  "@things-factory/builder": "^4.3.66",
@@ -118,5 +118,5 @@
118
118
  "cypress-localstorage-commands": "^1.6.1",
119
119
  "eslint-plugin-cypress": "^2.12.1"
120
120
  },
121
- "gitHead": "df1131ef0d2af26859970dfbbdf77430f58f7435"
121
+ "gitHead": "1cb2635ab3d0a6b4f7db765ac1987a79baf9d5c3"
122
122
  }