@things-factory/operato-wms 4.3.521 → 4.3.522

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,9 +1,23 @@
1
1
  import gql from 'graphql-tag'
2
- import { css, html } from 'lit-element'
3
-
4
- import { i18next, localize } from '@things-factory/i18n-base'
5
- import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
6
- import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
2
+ import {
3
+ css,
4
+ html
5
+ } from 'lit-element'
6
+
7
+ import {
8
+ i18next,
9
+ localize
10
+ } from '@things-factory/i18n-base'
11
+ import {
12
+ client,
13
+ CustomAlert,
14
+ navigate,
15
+ PageView
16
+ } from '@things-factory/shell'
17
+ import {
18
+ CommonButtonStyles,
19
+ ScrollbarStyles
20
+ } from '@things-factory/styles'
7
21
  import { getPathInfo } from '@things-factory/utils'
8
22
 
9
23
  class CustomerReceivedNote extends localize(i18next)(PageView) {
@@ -80,6 +94,7 @@ class CustomerReceivedNote extends localize(i18next)(PageView) {
80
94
  var timezoneOffSet = new Date().getTimezoneOffset().toString()
81
95
 
82
96
  switch (domain) {
97
+ case 'el-ccl-selayang':
83
98
  case 'el-cold-chain-warehouse':
84
99
  this.shadowRoot.querySelector('#container').src = `/view_elccl_grn/${this._grnNo}`
85
100
  break
@@ -1,9 +1,22 @@
1
1
  import gql from 'graphql-tag'
2
- import { css, html } from 'lit-element'
2
+ import {
3
+ css,
4
+ html
5
+ } from 'lit-element'
3
6
 
4
- import { i18next, localize } from '@things-factory/i18n-base'
5
- import { client, navigate, PageView } from '@things-factory/shell'
6
- import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
7
+ import {
8
+ i18next,
9
+ localize
10
+ } from '@things-factory/i18n-base'
11
+ import {
12
+ client,
13
+ navigate,
14
+ PageView
15
+ } from '@things-factory/shell'
16
+ import {
17
+ CommonButtonStyles,
18
+ ScrollbarStyles
19
+ } from '@things-factory/styles'
7
20
  import { getPathInfo } from '@things-factory/utils'
8
21
 
9
22
  class ReceivedNoteDetail extends localize(i18next)(PageView) {
@@ -86,6 +99,7 @@ class ReceivedNoteDetail extends localize(i18next)(PageView) {
86
99
  var timezoneOffSet = new Date().getTimezoneOffset().toString()
87
100
 
88
101
  switch (domain) {
102
+ case 'el-ccl-selayang':
89
103
  case 'el-cold-chain-warehouse':
90
104
  this.shadowRoot.querySelector('#container').src = `/view_elccl_grn/${this._grnNo}`
91
105
  break
@@ -136,21 +136,32 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
136
136
  })
137
137
  }
138
138
 
139
- if (this.releaseGoodNo && this.source == 'POWRUP' && this.platform == 'operato' && this.completed) {
140
- }
139
+ if (this.releaseGoodNo && this.platform == 'operato' && this.completed) {
140
+ switch (this.source) {
141
+ case 'POWRUP':
142
+ actions.push({
143
+ title: i18next.t('button.print_airway_bill'),
144
+ action: this.printPowrupDocument.bind(this, 'awb'),
145
+ ...CommonButtonStyles.label
146
+ })
147
+
148
+ actions.push({
149
+ title: i18next.t('button.print_invoice'),
150
+ action: this.printPowrupDocument.bind(this, 'invoice'),
151
+ ...CommonButtonStyles.label
152
+ })
141
153
 
142
- if (this.releaseGoodNo && this.source == 'POWRUP' && this.platform == 'operato' && this.completed) {
143
- actions.push({
144
- title: i18next.t('button.print_airway_bill'),
145
- action: this.printPowrupDocument.bind(this, 'awb'),
146
- ...CommonButtonStyles.label
147
- })
154
+ break
148
155
 
149
- actions.push({
150
- title: i18next.t('button.print_invoice'),
151
- action: this.printPowrupDocument.bind(this, 'invoice'),
152
- ...CommonButtonStyles.label
153
- })
156
+ case 'WEBSPERT':
157
+ actions.push({
158
+ title: i18next.t('button.print_airway_bill'),
159
+ action: this.printWebspertDocument.bind(this, 'awb'),
160
+ ...CommonButtonStyles.label
161
+ })
162
+
163
+ break
164
+ }
154
165
  }
155
166
 
156
167
  if (
@@ -644,6 +655,10 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
644
655
  this.fetchPowrupOrderDocument(worksheetInfo.orderPackage.id)
645
656
  }
646
657
 
658
+ if (worksheetInfo.source == 'WEBSPERT') {
659
+ this.fetchWebspertOrderDocument(worksheetInfo.orderPackage.id)
660
+ }
661
+
647
662
  this.updateContext()
648
663
  }
649
664
  }
@@ -894,6 +909,82 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
894
909
  }
895
910
  }
896
911
 
912
+ async printWebspertDocument(type) {
913
+ try {
914
+ if (this._orderPackageInformation.orderPackage.id == undefined) {
915
+ throw new Error('Unable to find package id, please rescan your order.')
916
+ }
917
+
918
+ // Increment the attempt count
919
+ if (type === 'awb') {
920
+ this._awbAttempts++
921
+ }
922
+
923
+ let convertedPdfUrl = ''
924
+ if (type == 'invoice') {
925
+ let invoice = this.invoice
926
+ // fetch and set variable if invoice not found
927
+ if (!invoice || invoice.trim() == '') {
928
+ let document = await this.fetchWebspertOrderDocument(this._orderPackageInformation.orderPackage.id)
929
+ invoice = document.invoice
930
+ }
931
+ let url = new URL(window.location)
932
+ convertedPdfUrl = `${url.origin}/proxy?url=${invoice}`
933
+ } else if (type == 'awb') {
934
+ let airwayBill = this.airwayBill
935
+ // fetch and set variable if awb not found
936
+ if (!airwayBill || airwayBill.trim() == '') {
937
+ let document = await this.fetchWebspertOrderDocument(this._orderPackageInformation.orderPackage.id)
938
+ airwayBill = document.airwayBill
939
+ }
940
+ if (airwayBill.includes('partner.shopeemobile.com')) {
941
+ convertedPdfUrl = `/pdf/merge?urls=${airwayBill}`
942
+ } else {
943
+ let url = new URL(window.location)
944
+ convertedPdfUrl = `${url.origin}/proxy?url=${airwayBill}`
945
+ }
946
+ }
947
+
948
+ // print PDF document
949
+ this.callPrintDialog(convertedPdfUrl)
950
+ } catch (error) {
951
+ if (this._awbAttempts < 4) {
952
+ this.showToast({
953
+ message: 'Oops! The AWB is not ready yet. Please retry by clicking the Print Airway bill button.'
954
+ })
955
+ } else {
956
+ this.showToast({
957
+ message:
958
+ 'It appears that we are unable to retrieve the AWB from the platform. Please reach out to support for assistance.'
959
+ })
960
+ }
961
+ }
962
+ }
963
+
964
+ // get webspert document fetcher function
965
+ async fetchWebspertOrderDocument(id) {
966
+ const response = await client.mutate({
967
+ mutation: gql`
968
+ mutation fetchWebspertDocument($orderPackageId: String!) {
969
+ fetchWebspertDocument(orderPackageId: $orderPackageId) {
970
+ airwayBill
971
+ invoice
972
+ }
973
+ }
974
+ `,
975
+ variables: { orderPackageId: id }
976
+ })
977
+ if (!response.errors) {
978
+ this.invoice = document.invoice
979
+ this.airwayBill = document.airwayBill
980
+
981
+ return {
982
+ invoice: response.data.fetchWebspertDocument.invoice,
983
+ airwayBill: response.data.fetchWebspertDocument.airwayBill
984
+ }
985
+ }
986
+ }
987
+
897
988
  async printInvoice() {
898
989
  var orderDocInfo = await this.getOrderDocument(this.refNo, 'invoice')
899
990
 
@@ -1419,8 +1510,16 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
1419
1510
  await this.printSellercraftDocument('awb')
1420
1511
  }
1421
1512
 
1422
- if (this.releaseGoodNo && this.source == 'POWRUP' && this.airwayBill && this.completed) {
1423
- await this.printPowrupDocument('awb')
1513
+ if (this.releaseGoodNo && this.airwayBill && this.completed) {
1514
+ switch (this.source) {
1515
+ case 'POWRUP':
1516
+ await this.printPowrupDocument('awb')
1517
+ break
1518
+
1519
+ case 'WEBSPERT':
1520
+ await this.printWebspertDocument('awb')
1521
+ break
1522
+ }
1424
1523
  }
1425
1524
 
1426
1525
  if (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.521",
3
+ "version": "4.3.522",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -108,7 +108,7 @@
108
108
  "@things-factory/transport-base": "^4.3.518",
109
109
  "@things-factory/tutorial-ui": "^4.3.518",
110
110
  "@things-factory/warehouse-base": "^4.3.520",
111
- "@things-factory/worksheet-base": "^4.3.521"
111
+ "@things-factory/worksheet-base": "^4.3.522"
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": "98c2ee77ee54a28e6cbf6bb3667ce3d4a46f43dc"
120
+ "gitHead": "1b3343be7d8eb58baa0f60779ede1955828de9d1"
121
121
  }