@things-factory/operato-wms 5.0.13 → 6.0.0-alpha.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 (206) hide show
  1. package/client/pages/bulk-operation/bulk-operation.js +96 -8
  2. package/client/pages/bulk-operation/validate-gan-popup.js +37 -27
  3. package/client/pages/bulk-operation/validate-ro-popup.js +40 -0
  4. package/client/pages/components/select-inventory-popup.js +633 -0
  5. package/client/pages/constants/order.js +2 -1
  6. package/client/pages/inbound/pallet-label-popup.js +2 -0
  7. package/client/pages/inbound/select-product-batch.js +7 -1
  8. package/client/pages/inbound/undo-unload-popup.js +37 -21
  9. package/client/pages/inbound/unload-product.js +147 -59
  10. package/client/pages/inbound/worksheet-putaway.js +1 -1
  11. package/client/pages/inbound/worksheet-unloading.js +11 -7
  12. package/client/pages/inventory/inventory-adjustment.js +261 -238
  13. package/client/pages/inventory/inventory-by-product-detail.js +99 -92
  14. package/client/pages/inventory/inventory-by-product.js +170 -68
  15. package/client/pages/inventory/onhand-inventory.js +10 -12
  16. package/client/pages/inventory/serial-number-list-popup.js +36 -5
  17. package/client/pages/inventory-check/inspecting-product.js +1 -1
  18. package/client/pages/manifest/create-loading-manifest.js +47 -22
  19. package/client/pages/manifest/dispatcher-verification-popup.js +24 -13
  20. package/client/pages/manifest/loading-manifest-detail.js +311 -46
  21. package/client/pages/manifest/loading-manifest-list.js +86 -13
  22. package/client/pages/order/arrival-notice/arrival-notice-detail.js +305 -52
  23. package/client/pages/order/arrival-notice/arrival-notice-list.js +20 -1
  24. package/client/pages/order/arrival-notice/create-arrival-notice.js +2 -2
  25. package/client/pages/order/goods-received-note/received-note-detail.js +187 -15
  26. package/client/pages/order/release-order/b2b/b2b-order-list.js +76 -80
  27. package/client/pages/order/release-order/b2c/b2c-order-requests.js +148 -123
  28. package/client/pages/order/release-order/batch-picking-popup.js +11 -0
  29. package/client/pages/order/release-order/create-release-order.js +762 -250
  30. package/client/pages/order/release-order/release-extra-product-popup.js +10 -3
  31. package/client/pages/order/release-order/release-order-detail.js +897 -215
  32. package/client/pages/order/transport-order/delivery-note-popup.js +1050 -107
  33. package/client/pages/order/transport-order/print-delivery-note.js +214 -33
  34. package/client/pages/order/transport-order/upload-delivery-note.js +6 -4
  35. package/client/pages/order/transport-order/view-delivery-note.js +0 -1
  36. package/client/pages/outbound/generate-worksheet-popup.js +374 -0
  37. package/client/pages/outbound/inventory-reassign-popup.js +1097 -0
  38. package/client/pages/outbound/loading-product.js +88 -78
  39. package/client/pages/outbound/merged-outbound-worksheet.js +1 -1
  40. package/client/pages/outbound/packing-product.js +193 -82
  41. package/client/pages/outbound/packing-worksheet-list.js +10 -9
  42. package/client/pages/outbound/picking-product.js +979 -905
  43. package/client/pages/outbound/route-label-popup.js +283 -191
  44. package/client/pages/outbound/serial-number-popup.js +1 -0
  45. package/client/pages/outbound/sorting-product.js +12 -12
  46. package/client/pages/outbound/worksheet-batch-picking.js +39 -5
  47. package/client/pages/outbound/worksheet-packing.js +17 -4
  48. package/client/pages/outbound/worksheet-picking.js +45 -6
  49. package/client/pages/report/inbound-serial-number-report.js +86 -9
  50. package/client/pages/report/inventory-report.js +10 -0
  51. package/client/pages/report/inventory-summary-report.js +28 -19
  52. package/client/pages/report/outbound-order-details-report.js +204 -43
  53. package/client/pages/report/outbound-serial-number-report.js +87 -9
  54. package/client/pages/report/release-inventory-report.js +503 -0
  55. package/client/route.js +5 -0
  56. package/client/util/index.js +2 -0
  57. package/client/util/page-settings.js +43 -0
  58. package/client/util/toast.js +10 -0
  59. package/dist-server/graphql/resolvers/board-setting/board-settings.js +3 -3
  60. package/dist-server/graphql/resolvers/board-setting/board-settings.js.map +1 -1
  61. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.js +2 -2
  62. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.js.map +1 -1
  63. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.js +1 -1
  64. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.js.map +1 -1
  65. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.js +2 -2
  66. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.js.map +1 -1
  67. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js +9 -10
  68. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js.map +1 -1
  69. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js +2 -2
  70. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js.map +1 -1
  71. package/dist-server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.js +6 -4
  72. package/dist-server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.js.map +1 -1
  73. package/dist-server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.js +6 -4
  74. package/dist-server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.js.map +1 -1
  75. package/dist-server/graphql/resolvers/dashboard/arrival-notices-by-status.js +21 -10
  76. package/dist-server/graphql/resolvers/dashboard/arrival-notices-by-status.js.map +1 -1
  77. package/dist-server/graphql/resolvers/dashboard/collection-orders-by-status.js +1 -2
  78. package/dist-server/graphql/resolvers/dashboard/collection-orders-by-status.js.map +1 -1
  79. package/dist-server/graphql/resolvers/dashboard/delivery-orders-by-status.js +1 -2
  80. package/dist-server/graphql/resolvers/dashboard/delivery-orders-by-status.js.map +1 -1
  81. package/dist-server/graphql/resolvers/dashboard/index.js +2 -1
  82. package/dist-server/graphql/resolvers/dashboard/index.js.map +1 -1
  83. package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js +17 -1
  84. package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js.map +1 -1
  85. package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js +113 -75
  86. package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js.map +1 -1
  87. package/dist-server/graphql/resolvers/dashboard/release-goods-by-status.js +21 -10
  88. package/dist-server/graphql/resolvers/dashboard/release-goods-by-status.js.map +1 -1
  89. package/dist-server/graphql/resolvers/dashboard/unit-inbounded-outbounded.js +56 -0
  90. package/dist-server/graphql/resolvers/dashboard/unit-inbounded-outbounded.js.map +1 -0
  91. package/dist-server/graphql/resolvers/index.js +5 -4
  92. package/dist-server/graphql/resolvers/index.js.map +1 -1
  93. package/dist-server/graphql/resolvers/inventory-comparison/inventory-comparison-list.js.map +1 -1
  94. package/dist-server/graphql/resolvers/opa-menu/opa-menus.js +8 -7
  95. package/dist-server/graphql/resolvers/opa-menu/opa-menus.js.map +1 -1
  96. package/dist-server/graphql/resolvers/{extra → other}/add-release-good-products.js +59 -8
  97. package/dist-server/graphql/resolvers/other/add-release-good-products.js.map +1 -0
  98. package/dist-server/graphql/resolvers/{extra → other}/index.js +3 -1
  99. package/dist-server/graphql/resolvers/other/index.js.map +1 -0
  100. package/dist-server/graphql/resolvers/other/page-settings.js +87 -0
  101. package/dist-server/graphql/resolvers/other/page-settings.js.map +1 -0
  102. package/dist-server/graphql/resolvers/reports/costing-report.js +4 -4
  103. package/dist-server/graphql/resolvers/reports/costing-report.js.map +1 -1
  104. package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js +3 -3
  105. package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js.map +1 -1
  106. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js +36 -7
  107. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js.map +1 -1
  108. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  109. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  110. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +69 -30
  111. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
  112. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js +36 -11
  113. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js.map +1 -1
  114. package/dist-server/graphql/resolvers/reports/product-label-report.js +3 -3
  115. package/dist-server/graphql/resolvers/reports/product-label-report.js.map +1 -1
  116. package/dist-server/graphql/resolvers/reports/release-inventory-report.js +180 -0
  117. package/dist-server/graphql/resolvers/reports/release-inventory-report.js.map +1 -0
  118. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js +2 -2
  119. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js.map +1 -1
  120. package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js +1 -1
  121. package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js.map +1 -1
  122. package/dist-server/graphql/types/dashboard/index.js +1 -0
  123. package/dist-server/graphql/types/dashboard/index.js.map +1 -1
  124. package/dist-server/graphql/types/index.js +7 -2
  125. package/dist-server/graphql/types/index.js.map +1 -1
  126. package/dist-server/graphql/types/other/index.js +19 -0
  127. package/dist-server/graphql/types/other/index.js.map +1 -0
  128. package/dist-server/graphql/types/other/page-setting.js +34 -0
  129. package/dist-server/graphql/types/other/page-setting.js.map +1 -0
  130. package/dist-server/graphql/types/reports/index.js +6 -1
  131. package/dist-server/graphql/types/reports/index.js.map +1 -1
  132. package/dist-server/graphql/types/reports/outbound-order-details-report.js +17 -1
  133. package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
  134. package/dist-server/graphql/types/reports/release-inventory-report-list.js +12 -0
  135. package/dist-server/graphql/types/reports/release-inventory-report-list.js.map +1 -0
  136. package/dist-server/graphql/types/reports/release-inventory-report.js +27 -0
  137. package/dist-server/graphql/types/reports/release-inventory-report.js.map +1 -0
  138. package/dist-server/migrations/1568858861188-SeedSetting.js +5 -6
  139. package/dist-server/migrations/1568858861188-SeedSetting.js.map +1 -1
  140. package/dist-server/migrations/1623308919899-SeedLocationRecommendSetting.js +1 -1
  141. package/dist-server/migrations/1623308919899-SeedLocationRecommendSetting.js.map +1 -1
  142. package/dist-server/migrations/1623381200659-SeedStoringRule.js +1 -1
  143. package/dist-server/migrations/1623381200659-SeedStoringRule.js.map +1 -1
  144. package/dist-server/tsconfig.tsbuildinfo +1 -1
  145. package/dist-server/utils/report-query-util.js +5 -2
  146. package/dist-server/utils/report-query-util.js.map +1 -1
  147. package/helps/release-note.ko.md +8 -20
  148. package/helps/release-note.md +8 -20
  149. package/helps/release-note.ms.md +8 -20
  150. package/helps/release-note.zh.md +8 -20
  151. package/package.json +42 -42
  152. package/server/graphql/resolvers/board-setting/board-settings.ts +4 -6
  153. package/server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.ts +4 -5
  154. package/server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.ts +9 -10
  155. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.ts +4 -5
  156. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +17 -19
  157. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +10 -8
  158. package/server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.ts +9 -9
  159. package/server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.ts +9 -9
  160. package/server/graphql/resolvers/dashboard/arrival-notices-by-status.ts +23 -14
  161. package/server/graphql/resolvers/dashboard/collection-orders-by-status.ts +4 -5
  162. package/server/graphql/resolvers/dashboard/delivery-orders-by-status.ts +4 -5
  163. package/server/graphql/resolvers/dashboard/index.ts +3 -1
  164. package/server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts +18 -6
  165. package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +114 -81
  166. package/server/graphql/resolvers/dashboard/release-goods-by-status.ts +23 -14
  167. package/server/graphql/resolvers/dashboard/unit-inbounded-outbounded.ts +61 -0
  168. package/server/graphql/resolvers/index.ts +5 -4
  169. package/server/graphql/resolvers/inventory-comparison/inventory-comparison-list.ts +11 -9
  170. package/server/graphql/resolvers/opa-menu/opa-menus.ts +7 -6
  171. package/server/graphql/resolvers/{extra → other}/add-release-good-products.ts +73 -12
  172. package/server/graphql/resolvers/other/index.ts +10 -0
  173. package/server/graphql/resolvers/other/page-settings.ts +105 -0
  174. package/server/graphql/resolvers/reports/costing-report.ts +8 -10
  175. package/server/graphql/resolvers/reports/inbound-order-details-report.ts +7 -9
  176. package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +41 -13
  177. package/server/graphql/resolvers/reports/index.ts +3 -1
  178. package/server/graphql/resolvers/reports/outbound-order-details-report.ts +76 -38
  179. package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +42 -18
  180. package/server/graphql/resolvers/reports/product-label-report.ts +4 -6
  181. package/server/graphql/resolvers/reports/release-inventory-report.ts +201 -0
  182. package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +3 -5
  183. package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +10 -10
  184. package/server/graphql/types/dashboard/index.ts +1 -0
  185. package/server/graphql/types/index.ts +8 -2
  186. package/server/graphql/types/other/index.ts +19 -0
  187. package/server/graphql/types/other/page-setting.ts +33 -0
  188. package/server/graphql/types/reports/index.ts +6 -1
  189. package/server/graphql/types/reports/outbound-order-details-report.ts +17 -1
  190. package/server/graphql/types/reports/release-inventory-report-list.ts +8 -0
  191. package/server/graphql/types/reports/release-inventory-report.ts +23 -0
  192. package/server/migrations/1568858861188-SeedSetting.ts +4 -4
  193. package/server/migrations/1623308919899-SeedLocationRecommendSetting.ts +3 -2
  194. package/server/migrations/1623381200659-SeedStoringRule.ts +3 -2
  195. package/server/utils/report-query-util.ts +5 -2
  196. package/things-factory.config.js +4 -0
  197. package/translations/en.json +148 -27
  198. package/translations/ko.json +185 -105
  199. package/translations/ms.json +183 -98
  200. package/translations/zh.json +197 -112
  201. package/dist-server/graphql/resolvers/extra/add-release-good-products.js.map +0 -1
  202. package/dist-server/graphql/resolvers/extra/index.js.map +0 -1
  203. package/dist-server/graphql/types/extra/index.js +0 -11
  204. package/dist-server/graphql/types/extra/index.js.map +0 -1
  205. package/server/graphql/resolvers/extra/index.ts +0 -5
  206. package/server/graphql/types/extra/index.ts +0 -7
@@ -1,5 +1,11 @@
1
1
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
2
2
  import '@things-factory/grist-ui'
3
+ import '@things-factory/import-ui'
4
+ import '@things-factory/component-ui'
5
+ import '@things-factory/biz-ui'
6
+ import { sleep } from '@operato/utils'
7
+ import '../../outbound/transport-vehicles-popup'
8
+
3
9
  import { i18next, localize } from '@things-factory/i18n-base'
4
10
  import { openPopup } from '@things-factory/layout-base'
5
11
  import { client } from '@things-factory/shell'
@@ -30,15 +36,83 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
30
36
  selectedCP: String,
31
37
  status: String,
32
38
  orderInfo: Object,
33
- contactPointInput: String
39
+ contactPointInput: String,
40
+ roNo: String,
41
+ refNo: String,
42
+ coNo: String,
43
+ totalPalletQty: String,
44
+ _transportType: Array,
45
+ _statusOwnTransport: Boolean,
46
+ /* Shipping Form Field */
47
+ _contactPointId: String,
48
+ _contactPointName: String,
49
+ _companyName: String,
50
+ _deliveryCountry: String,
51
+ _deliveryPostCode: Array,
52
+ _deliveryState: String,
53
+ _deliveryCity: String,
54
+ _deliveryContact: String,
55
+ _selectedPostCode: String,
56
+ _billingCountry: String,
57
+ _billingPostCode: Array,
58
+ _billingState: String,
59
+ _billingCity: String,
60
+ _billingContact: String,
61
+ _selectedBillingPostCode: String,
62
+ _selectedOwnTransport: Boolean,
63
+ _valueOfTransportType: String,
64
+ _showCoNumber: Boolean,
65
+ _exportOption: Boolean,
66
+ _selectedDeliveryCountry: String,
67
+ _deliveryAllCountry: Array,
68
+ _billingAllCountry: Array,
69
+ _determineOwnCollection: String,
70
+
71
+ // Export Form Field
72
+
73
+ _containerArrivalDate: Date,
74
+ _containerLeavingDate: Date,
75
+ _containerNo: String,
76
+ _shipName: String,
77
+
78
+ // Refractor
79
+ _deliveryOrder: Object,
80
+ _selectedCountry: String,
81
+ _selectedBillingCountry: String,
82
+
83
+ /* Tab Toggle*/
84
+ _showReleasedOrderInfo: Boolean,
85
+ _showShippingInfo: Boolean,
86
+ _disableBillingAddress: Boolean
34
87
  }
35
88
  }
36
89
 
37
90
  constructor() {
38
91
  super()
92
+ this._deliveryAllCountry = []
39
93
  this._otherDestination = false
40
94
  this._isDisabled = true
95
+ this._showReleasedOrderInfo = false
96
+ this._showShippingInfo = true
97
+ this._exportOption = false
98
+ this._companyName = ''
99
+ this._deliveryCountry = 'Malaysia'
100
+ this._deliveryPostCode = []
101
+ this._deliveryState = ''
102
+ this._deliveryCity = ''
103
+ this._deliveryContact = ''
104
+ this._billingCountry = 'Malaysia'
105
+ this._billingPostCode = []
106
+ this._billingState = ''
107
+ this._billingCity = ''
108
+ this._billingContact = ''
109
+ this._selectedPostCode = ''
110
+ this._selectedBillingPostCode = ''
111
+ this._selectedTransportType = ''
41
112
  this.status = ''
113
+ this._transportType = ['Own Transport', 'Warehouse Transport']
114
+ this._switchDeliveryCountryInput = false
115
+ this._switchBillingCountryInput = false
42
116
  }
43
117
 
44
118
  static get styles() {
@@ -58,6 +132,15 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
58
132
  min-height: 20vh;
59
133
  }
60
134
 
135
+ [title] {
136
+ margin-top: -10px;
137
+ margin-bottom: -10px;
138
+ }
139
+
140
+ [export] {
141
+ margin-top: -10px;
142
+ }
143
+
61
144
  .grist {
62
145
  display: flex;
63
146
  flex-direction: column;
@@ -90,6 +173,33 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
90
173
  background-color: var(--button-container-background);
91
174
  height: var(--button-container-height);
92
175
  }
176
+
177
+ .content-container {
178
+ overflow-y: auto;
179
+ }
180
+
181
+ [hidden] {
182
+ display: none;
183
+ }
184
+
185
+ .section-header {
186
+ grid-column: span 36 / auto !important;
187
+ text-align: left !important;
188
+ margin-top: 10px !important;
189
+ font-weight: 600 !important;
190
+ }
191
+ .quick-find-content-container {
192
+ margin: 0 15px;
193
+ }
194
+
195
+ @media screen and (max-width: 480px) {
196
+ .section-header {
197
+ grid-column: span 12 / auto !important;
198
+ }
199
+ .quick-find-content-container {
200
+ margin: 0;
201
+ }
202
+ }
93
203
  `
94
204
  ]
95
205
  }
@@ -99,10 +209,21 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
99
209
  this._truckNo = this.orderInfo.truckNo || ''
100
210
  const deliverTo = this.orderInfo.deliverTo || {}
101
211
  this.selectedCP = deliverTo.id || null
102
- this.contactPointInput.value =
103
- deliverTo.contactName && deliverTo.address ? `${deliverTo.contactName}, ${deliverTo.address}` : ''
212
+ // this.contactPointInput.value = deliverTo.contactName && deliverTo.address ? `${deliverTo.contactName}, ${deliverTo.address}` : ''
213
+ await this.fetchCountry()
214
+ await this._getAllPostCode()
104
215
 
105
216
  await this.fetchDeliveryInfo(this.manualDo)
217
+ const roResponse = await this._fetchReleaseOrder(this.roNo)
218
+ const doRepsonse = await this._fetchDeliveryOrder(this.doNo)
219
+
220
+ this.totalPalletQty = doRepsonse.data.deliveryOrder.palletQty
221
+
222
+ roResponse !== undefined
223
+ ? roResponse.ownTransport == true
224
+ ? (this._showCoNumber = true)
225
+ : (this._showCoNumber = false)
226
+ : ''
106
227
 
107
228
  this._isDisabled = await fetchSettingRule('disable-reusable-pallet')
108
229
 
@@ -167,122 +288,352 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
167
288
  }
168
289
 
169
290
  render() {
291
+ const RELEASE_ORDER_TABS = {
292
+ SHIPPING_INFO: i18next.t('label.shipment'),
293
+ RELEASE_ORDER_INFO: i18next.t('label.order')
294
+ }
295
+
296
+ const orderSet = {
297
+ [RELEASE_ORDER_TABS.RELEASE_ORDER_INFO]: {},
298
+ [RELEASE_ORDER_TABS.SHIPPING_INFO]: {}
299
+ }
300
+
170
301
  return html`
171
- <form id="input-form" name="doForm" class="multi-column-form">
172
- <fieldset>
173
- <legend>${i18next.t('title.delivery_information')} - ${this.doNo}</legend>
174
- <label>${i18next.t('label.delivery_date')}</label>
175
- <input
176
- name="deliveryDate"
177
- type="date"
178
- min=${this.status === ORDER_STATUS.READY_TO_DISPATCH.value
179
- ? `${this._getStdDate()}`
180
- : `${this.orderInfo.createdDate}`}
181
- value="${this.orderInfo.deliveryDate}"
182
- required
183
- />
302
+ <div class="quick-find-content-container">
303
+ <quick-find-content
304
+ id="order-items-list"
305
+ name="quickFindContent"
306
+ .data="${orderSet}"
307
+ @tabChanged="${e => {
308
+ this._tabChange(e.detail.currentTabKey)
309
+ }}"
310
+ ></quick-find-content>
311
+ </div>
184
312
 
185
- <label>${i18next.t('label.driver_name')}</label>
186
- <input name="otherDriver" value="${this.orderInfo.otherDriver}" ?hidden="${!this._ownCollection}" />
187
- <input
188
- name="ownDriver"
189
- ?hidden="${this._ownCollection}"
190
- value="${this.orderInfo.driverName}"
191
- @click="${this._openDriverSelector.bind(this)}"
192
- readonly
193
- />
313
+ <div class="content-container">
314
+ <div ?hidden="${this._showReleasedOrderInfo}">
315
+ <form id="input-form" name="doForm" class="multi-column-form">
316
+ <legend>${i18next.t('title.delivery_information')} - ${this.doNo}</legend>
317
+ <label>${i18next.t('label.delivery_date')}</label>
318
+ <input
319
+ name="deliveryDate"
320
+ type="date"
321
+ min=${this.status === ORDER_STATUS.READY_TO_DISPATCH.value
322
+ ? `${this._getStdDate()}`
323
+ : `${this.orderInfo.createdDate}`}
324
+ value="${this.orderInfo.deliveryDate}"
325
+ required
326
+ />
194
327
 
195
- <label>${i18next.t('label.truck_no')}</label>
196
- <input name="otherTruck" ?hidden="${!this._ownCollection}" value="${this._truckNo}" />
197
- <input
198
- name="ownTruck"
199
- ?hidden="${this._ownCollection}"
200
- readonly
201
- @click="${this._openTruckSelector.bind(this)}"
202
- value="${this.orderInfo.truckNo || ''}"
203
- />
328
+ <label>${i18next.t('label.release_good_no')}</label>
329
+ <input name="releaseGoodNo" ?disabled="${true}" value="${this.roNo}" />
204
330
 
205
- <label ?hidden="${this._otherDestination}">${i18next.t('label.to')}</label>
206
- <input
207
- name="contactPoint"
208
- ?hidden="${this._otherDestination}"
209
- readonly
210
- @click="${this._openCPSelector.bind(this)}"
211
- />
331
+ <label>${i18next.t('label.ref_no')}</label>
332
+ <input name="refNo" ?disabled="${true}" value="${this.refNo}" />
212
333
 
213
- <input
214
- name="otherDestBoolean"
215
- type="checkbox"
216
- ?checked="${this._otherDestination}"
217
- @change="${e => (this._otherDestination = e.currentTarget.checked)}"
218
- />
219
- <label>${i18next.t('label.other_destination')}</label>
334
+ <label>${i18next.t('label.transport_type')}</label>
335
+ <select
336
+ name="transportType"
337
+ @change=${e => {
338
+ this._setTransportType(e.target.value, e.target.name)
339
+ }}
340
+ >
341
+ ${this._transportType.map(
342
+ (tp, key) => html`<option value=${tp} ?selected=${this._determineOwnCollection === tp}>${tp}</option>`
343
+ )}
344
+ </select>
220
345
 
221
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_name')}</label>
222
- <input name="contactName" ?hidden="${!this._otherDestination}" />
346
+ <label ?hidden="${this._showCoNumber}">${i18next.t('label.co_no')}</label>
347
+ <input name="coNo" ?hidden="${this._showCoNumber}" value="${this.coNo}" />
223
348
 
224
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_phone_no')}</label>
225
- <input
226
- name="contactPhone"
227
- ?hidden="${!this._otherDestination}"
228
- placeholder="(${i18next.t('text.optional')})"
229
- />
349
+ <label>${i18next.t('label.driver_name')}</label>
350
+ <input name="otherDriver" value="${this.orderInfo.otherDriver}" ?hidden="${!this._ownCollection}" />
351
+ <input
352
+ name="ownDriver"
353
+ ?hidden="${this._ownCollection}"
354
+ value="${this.orderInfo.driverName}"
355
+ @click="${this._openDriverSelector.bind(this)}"
356
+ readonly
357
+ />
358
+
359
+ <label>${i18next.t('label.vehicle_no')}</label>
360
+ <input name="otherTruck" ?hidden="${!this._ownCollection}" value="${this._truckNo}" />
361
+ <input
362
+ name="ownTruck"
363
+ readonly
364
+ ?hidden="${this._ownCollection}"
365
+ @click="${this._openBufferSelector.bind(this)}"
366
+ value="${this.orderInfo.truckNo || ''}"
367
+ />
368
+
369
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_name')}</label>
370
+ <input name="contactName" ?hidden="${!this._otherDestination}" />
371
+
372
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_phone_no')}</label>
373
+ <input
374
+ name="contactPhone"
375
+ ?hidden="${!this._otherDestination}"
376
+ placeholder="(${i18next.t('text.optional')})"
377
+ />
378
+
379
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_email')}</label>
380
+ <input
381
+ name="contactEmail"
382
+ ?hidden="${!this._otherDestination}"
383
+ placeholder="(${i18next.t('text.optional')})"
384
+ />
385
+
386
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.company_name')}</label>
387
+ <input
388
+ name="contactCompany"
389
+ ?hidden="${!this._otherDestination}"
390
+ placeholder="(${i18next.t('text.optional')})"
391
+ />
392
+
393
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_type')}</label>
394
+ <select name="contactType" ?hidden="${!this._otherDestination}">
395
+ <option value="">-- ${i18next.t('text.please_select_the_contact_type')} --</option>
396
+ <!-- Temporarily use hardcoded value -->
397
+ <option value="CUSTOMER">${i18next.t('text.customer')}</option>
398
+ <option value="SUPPLIER">${i18next.t('text.supplier')}</option>
399
+ </select>
400
+
401
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.delivery_address')}</label>
402
+ <textarea name="otherDestination" ?hidden="${!this._otherDestination}"></textarea>
403
+
404
+ <label ?hidden="${!this._otherDestination}">${i18next.t('label.billing_address')}</label>
405
+ <textarea name="billingAddress" ?hidden="${!this._otherDestination}"></textarea>
406
+
407
+ <label>${i18next.t('label.total_pallet_qty')}</label>
408
+ <input name="totalPalletQty" value="${this.totalPalletQty}" />
409
+
410
+ <label>${i18next.t('label.overall_remark')}</label>
411
+ <textarea name="remark" value="${this.orderInfo.remark}">${this.orderInfo.remark}</textarea>
412
+
413
+ <input
414
+ id="exportOption"
415
+ type="checkbox"
416
+ name="exportOption"
417
+ ?hidden=${this._determineOwnCollection == 'Warehouse Transport'}
418
+ ?checked="${this._exportOption}"
419
+ @change="${e => {
420
+ this._exportOption = e.currentTarget.checked
421
+ if (this._exportOption == true) {
422
+ this._exportOption = true
423
+ this._valueOfTransportType = 'Own Transport'
424
+ this._showCoNumber = false
425
+ }
426
+ if (this._exportOption == false) {
427
+ this._exportOption = false
428
+ this._showCoNumber = true
429
+ this._valueOfTransportType = 'Warehouse Transport'
430
+ }
431
+ }}"
432
+ />
433
+ <label for="exportOption" ?hidden=${this._determineOwnCollection == 'Warehouse Transport'}
434
+ >${i18next.t('label.export')}</label
435
+ >
436
+ </form>
437
+ </div>
438
+
439
+ <div class="so-form-container" export ?hidden=${!this._exportOption}>
440
+ <form name="shippingOrder" class="multi-column-form">
441
+ <fieldset>
442
+ <legend>${i18next.t('title.export_order')}</legend>
443
+ <label>${i18next.t('label.container_no')}</label>
444
+ <input name="containerNo" .value="${this._containerNo}" required />
445
+
446
+ <label>${i18next.t('label.container_arrival_date')}</label>
447
+ <input
448
+ name="containerArrivalDate"
449
+ type="date"
450
+ .value="${this._containerArrivalDate}"
451
+ @change="${e => {
452
+ this._containerLeavingDateInput.setAttribute('min', e.currentTarget.value)
453
+ }}"
454
+ required
455
+ />
456
+
457
+ <label>${i18next.t('label.container_leaving_date')}</label>
458
+ <input
459
+ name="containerLeavingDate"
460
+ type="date"
461
+ .value="${this._containerLeavingDate}"
462
+ @change="${e => {
463
+ this._containerArrivalDateInput.setAttribute('max', e.currentTarget.value)
464
+ }}"
465
+ required
466
+ />
467
+
468
+ <label>${i18next.t('label.ship_name')}</label>
469
+ <input name="shipName" .value="${this._shipName}" required />
470
+ </fieldset>
471
+ </form>
472
+ </div>
473
+
474
+ <form name="shippingInfo" class="multi-column-form" autocomplete="off" ?hidden="${this._showShippingInfo}">
475
+ <legend>${i18next.t('title.shipping_information')}</legend>
476
+
477
+ <label>${i18next.t('label.company')}</label>
478
+ <input name="attentionCompany" .value="${this._deliveryOrder?.attentionCompany}" />
230
479
 
231
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_email')}</label>
480
+ <label>${i18next.t('label.attention_to')}</label>
481
+ <input name="attentionTo" .value="${this._deliveryOrder?.attentionTo}" />
482
+
483
+ <button type="button" @click="${this._openContactPointSelector.bind(this)}">import</button>
484
+
485
+ <!-- delivery -->
486
+ <label class="section-header">${i18next.t('label.delivery_address')}</label>
487
+ <label>${i18next.t('label.country')}</label>
488
+
489
+ <select
490
+ name="country"
491
+ @change=${e => {
492
+ this._validateCountry(e)
493
+ }}
494
+ >
495
+ ${this._deliveryAllCountry?.map(
496
+ (country, key) =>
497
+ html`<option value=${country.name} ?selected=${country.name === this._selectedCountry}>
498
+ ${country.name}
499
+ </option>`
500
+ )}
501
+ </select>
502
+
503
+ <label>${i18next.t('label.zip_postal_code')}</label>
504
+ ${this._selectedCountry !== 'MALAYSIA'
505
+ ? html` <input name="postalCode" .value="" /> `
506
+ : html`<select
507
+ name="postalCode"
508
+ @change=${e => {
509
+ this._getStateAndCityByPostCode(e.target.value, e.target.name)
510
+ }}
511
+ value=${this?._selectedPostCode || ''}
512
+ >
513
+ <option value=""></option>
514
+ ${this._deliveryPostCode.map(
515
+ (country, key) =>
516
+ html`<option
517
+ ?selected=${(this._selectedPostCode?.length > 0
518
+ ? this._selectedPostCode
519
+ : this._deliveryOrder.postalCode) == country.postalCode}
520
+ value=${country.postalCode}
521
+ >
522
+ ${country.postalCode}
523
+ </option>`
524
+ )}
525
+ </select>`}
526
+
527
+ <label>${i18next.t('label.state')}</label>
528
+ <input name="state" required .value="${this._deliveryOrder?.state}" />
529
+
530
+ <label>${i18next.t('label.city')}</label>
531
+ <input name="city" required .value="${this._deliveryOrder?.city}" />
532
+
533
+ <label>${i18next.t('label.delivery_address')}</label>
534
+ <textarea name="deliveryAddress1" required .value="${this._deliveryOrder?.deliveryAddress1}"></textarea>
535
+
536
+ <label>${i18next.t('label.contact')}</label>
537
+ <input name="phone1" required .value="${this._deliveryOrder?.phone1}" />
538
+
539
+ <!-- billing -->
540
+ <label class="section-header">${i18next.t('label.billing_address')}</label>
541
+ <label>${i18next.t('label.country')}</label>
542
+ <select
543
+ name="billingCountry"
544
+ ?disabled=${this._disableBillingAddress}
545
+ @change=${e => {
546
+ this._validateBillingCountry(e)
547
+ }}
548
+ >
549
+ ${this._deliveryAllCountry.map(
550
+ (country, key) =>
551
+ html`<option value=${country.name} ?selected=${country.name === this._selectedBillingCountry}>
552
+ ${country.name}
553
+ </option>`
554
+ )}
555
+ </select>
556
+
557
+ <label>${i18next.t('label.zip_postal_code')}</label>
558
+
559
+ ${this._selectedBillingCountry !== 'MALAYSIA'
560
+ ? html`
561
+ <input
562
+ ?disabled=${this._disableBillingAddress}
563
+ name="billingPostalCode"
564
+ .value=${this._deliveryOrder?.billingPostalCode}
565
+ />
566
+ `
567
+ : html`<select
568
+ ?disabled=${this._disableBillingAddress}
569
+ name="billingPostalCode"
570
+ @change=${e => {
571
+ this._getStateAndCityByPostCode(e.target.value, e.target.name)
572
+ }}
573
+ value=${this._deliveryOrder?.billingPostalCode}
574
+ >
575
+ <option value=""></option>
576
+
577
+ ${this._billingPostCode.map(
578
+ (country, key) => html`<option
579
+ value=${country.postalCode}
580
+ ?selected=${this._deliveryOrder.billingPostalCode == country.postalCode}
581
+ >
582
+ ${country.postalCode}
583
+ </option>`
584
+ )}
585
+ </select>`}
586
+
587
+ <label>${i18next.t('label.state')}</label>
232
588
  <input
233
- name="contactEmail"
234
- ?hidden="${!this._otherDestination}"
235
- placeholder="(${i18next.t('text.optional')})"
589
+ ?disabled=${this._disableBillingAddress}
590
+ name="billingState"
591
+ required
592
+ .value="${this._deliveryOrder?.billingState}"
236
593
  />
237
594
 
238
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.company_name')}</label>
595
+ <label>${i18next.t('label.city')}</label>
239
596
  <input
240
- name="contactCompany"
241
- ?hidden="${!this._otherDestination}"
242
- placeholder="(${i18next.t('text.optional')})"
597
+ ?disabled=${this._disableBillingAddress}
598
+ name="billingCity"
599
+ required
600
+ .value="${this._deliveryOrder?.billingCity}"
243
601
  />
244
602
 
245
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.contact_type')}</label>
246
- <select name="contactType" ?hidden="${!this._otherDestination}">
247
- <option value="">-- ${i18next.t('text.please_select_the_contact_type')} --</option>
248
- <!-- Temporarily use hardcoded value -->
249
- <option value="CUSTOMER">${i18next.t('text.customer')}</option>
250
- <option value="SUPPLIER">${i18next.t('text.supplier')}</option>
251
- </select>
252
-
253
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.delivery_address')}</label>
254
- <textarea name="otherDestination" ?hidden="${!this._otherDestination}"></textarea>
603
+ <label>${i18next.t('label.billing_address')}</label>
604
+ <textarea
605
+ ?disabled=${this._disableBillingAddress}
606
+ name="billingAddress"
607
+ required
608
+ .value="${this._deliveryOrder?.billingAddress}"
609
+ ></textarea>
255
610
 
256
- <label ?hidden="${!this._otherDestination}">${i18next.t('label.billing_address')}</label>
257
- <textarea name="billingAddress" ?hidden="${!this._otherDestination}"></textarea>
611
+ <input
612
+ type="checkbox"
613
+ id="matchDeliveryAddress"
614
+ name="matchDeliveryAddressInputa"
615
+ ?checked=${this._deliveryOrder?.postalCode == this._deliveryOrder?.billingPostalCode &&
616
+ this._deliveryOrder?.billingAddress == this._deliveryOrder?.deliveryAddress1}
617
+ @click=${e => {
618
+ e.currentTarget.checked ? (this._disableBillingAddress = true) : (this._disableBillingAddress = false)
619
+ }}
620
+ />
621
+ <label for="matchDeliveryAddress">${i18next.t('label.match_delivery_address')}</label>
622
+ </form>
258
623
 
259
- <label>${i18next.t('label.overall_remark')}</label>
260
- <textarea name="remark" value="${this.orderInfo.remark}">${this.orderInfo.remark}</textarea>
624
+ <div class="container">
625
+ <div class="grist">
626
+ <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.edit_remark')}</h2>
261
627
 
262
- <label ?hidden="${this._isDisabled}">${i18next.t('label.reusable_pallet')}</label>
263
- <textarea
264
- name="reusablePallet"
265
- ?hidden="${this._isDisabled}"
266
- ?disabled="${this._isDisabled}"
267
- value="${this.orderInfo.reusablePallet}"
268
- placeholder="(${i18next.t('text.optional')})"
269
- >${this.orderInfo.reusablePallet}</textarea>
270
- </fieldset>
271
- </form>
272
-
273
- <div class="container">
274
- <div class="grist">
275
- <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.edit_remark')}</h2>
276
-
277
- <data-grist
278
- id="do-grist"
279
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
280
- .config=${this.doGristConfig}
281
- .data=${this.doData}
282
- ></data-grist>
628
+ <data-grist
629
+ id="do-grist"
630
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
631
+ .config=${this.doGristConfig}
632
+ .data=${this.doData}
633
+ ></data-grist>
634
+ </div>
283
635
  </div>
284
636
  </div>
285
-
286
637
  <div class="button-container">
287
638
  <mwc-button
288
639
  @click="${this._saveDeliveryInfo.bind(this)}"
@@ -295,10 +646,50 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
295
646
  `
296
647
  }
297
648
 
649
+ get getDeliveryOrderForm() {
650
+ return this.shadowRoot.querySelector('form[name=deliveryOrderInfo]')
651
+ }
652
+
653
+ get shippingInfoForm() {
654
+ return this.shadowRoot.querySelector('form[name=shippingInfo]')
655
+ }
656
+
657
+ get deliveryAddressForm() {
658
+ return this.shadowRoot.querySelector('form[name=deliveryAddressInfo]')
659
+ }
660
+
661
+ get billingAddressForm() {
662
+ return this.shadowRoot.querySelector('form[name=billingAddressInfo]')
663
+ }
664
+
665
+ get contactPointForm() {
666
+ return this.shadowRoot.querySelector('form[name=contactPointInfo]')
667
+ }
668
+
669
+ get _getBillingPostalCodeInput() {
670
+ return this.shadowRoot.querySelector('select[name=billingPostalCode]')
671
+ }
672
+
673
+ get shippingOrderForm() {
674
+ return this.shadowRoot.querySelector('form[name=shippingOrder]')
675
+ }
676
+
677
+ get _exportOptionInput() {
678
+ return this.shadowRoot.querySelector('input[name=exportOption]')
679
+ }
680
+
298
681
  get doForm() {
299
682
  return this.shadowRoot.querySelector('form[name=doForm]')
300
683
  }
301
684
 
685
+ get otherDriverInput() {
686
+ return this.shadowRoot.querySelector('input[name=otherDriver]')
687
+ }
688
+
689
+ get otherTruckInput() {
690
+ return this.shadowRoot.querySelector('input[name=otherTruck]')
691
+ }
692
+
302
693
  get contactPointInput() {
303
694
  return this.shadowRoot.querySelector('input[name=contactPoint]')
304
695
  }
@@ -307,6 +698,26 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
307
698
  return this.shadowRoot.querySelector('input[name=ownTruck]')
308
699
  }
309
700
 
701
+ get _otherTruckInput() {
702
+ return this.shadowRoot.querySelector('input[name=otherTruck]')
703
+ }
704
+
705
+ get _cityInput() {
706
+ return this.shadowRoot.querySelector('input[name=city]')
707
+ }
708
+
709
+ get _stateInput() {
710
+ return this.shadowRoot.querySelector('input[name=state]')
711
+ }
712
+
713
+ get _cityBillingInput() {
714
+ return this.shadowRoot.querySelector('input[name=billingCity]')
715
+ }
716
+
717
+ get _stateBillingInput() {
718
+ return this.shadowRoot.querySelector('input[name=billingState]')
719
+ }
720
+
310
721
  get _truckDriverInput() {
311
722
  return this.shadowRoot.querySelector('input[name=ownDriver]')
312
723
  }
@@ -346,6 +757,24 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
346
757
  return obj
347
758
  }
348
759
 
760
+ _setTransportType(e, v) {
761
+ if (e == 'Own Transport') {
762
+ this._showCoNumber = false
763
+ this._ownCollection = true
764
+ this._determineOwnCollection = 'Own Transport'
765
+ this._otherTruckInput.value = ''
766
+ this.otherDriverInput.value = ''
767
+ } else {
768
+ this._showCoNumber = true
769
+ this._exportOption = false
770
+ this._exportOptionInput.checked = false
771
+ this._ownCollection = false
772
+ this._determineOwnCollection = 'Warehouse Transport'
773
+ this._truckNoInput.value = ''
774
+ this._truckDriverInput.value = ''
775
+ }
776
+ }
777
+
349
778
  _openCPSelector() {
350
779
  openPopup(
351
780
  html`
@@ -382,6 +811,23 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
382
811
  )
383
812
  }
384
813
 
814
+ async _openBufferSelector() {
815
+ openPopup(
816
+ html`
817
+ <transport-vehicles-popup
818
+ @selected="${e => {
819
+ this._truckNoInput.value = e.detail.name
820
+ }}"
821
+ ></transport-vehicles-popup>
822
+ `,
823
+ {
824
+ backdrop: true,
825
+ size: 'large',
826
+ title: i18next.t('label.lorry_no')
827
+ }
828
+ )
829
+ }
830
+
385
831
  _openDriverSelector() {
386
832
  openPopup(
387
833
  html`
@@ -399,6 +845,101 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
399
845
  )
400
846
  }
401
847
 
848
+ _openContactPointSelector() {
849
+ openPopup(
850
+ html`
851
+ <contact-points-popup
852
+ @selected="${e => {
853
+ this._fillUpDeliveryInfo(e.detail)
854
+ }}"
855
+ ></contact-points-popup>
856
+ `,
857
+ {
858
+ backdrop: true,
859
+ size: 'large',
860
+ title: i18next.t('title.select_destination')
861
+ }
862
+ )
863
+ }
864
+
865
+ async _getAllPostCode() {
866
+ try {
867
+ const response = await client.query({
868
+ query: gql`
869
+ query geoAreasAllPostCode {
870
+ geoAreasAllPostCode {
871
+ items {
872
+ postalCode
873
+ }
874
+ total
875
+ }
876
+ }
877
+ `
878
+ })
879
+
880
+ if (!response.errors) {
881
+ const items = response.data.geoAreasAllPostCode.items
882
+ this._deliveryPostCode = items
883
+ this._billingPostCode = items
884
+ }
885
+ } catch (e) {
886
+ this._showToast(e)
887
+ }
888
+ }
889
+
890
+ async _getStateAndCityByPostCode(value, name) {
891
+ const postCode = value
892
+
893
+ // If user select the first empty postal code, the city and state will change to empty
894
+ if (postCode == '') {
895
+ if (name == 'postalCode') {
896
+ this._cityInput.value = ''
897
+ this._stateInput.value = ''
898
+ return
899
+ } else if (name == 'billingPostalCode') {
900
+ this._cityBillingInput.value = ''
901
+ this._stateBillingInput.value = ''
902
+ return
903
+ }
904
+ }
905
+
906
+ try {
907
+ const response = await client.query({
908
+ query: gql`
909
+ query geoAreasGetStateAndCityByPosCode($postCode: String!) {
910
+ geoAreasGetStateAndCityByPosCode(postCode: $postCode) {
911
+ stateName
912
+ cityName
913
+ }
914
+ }
915
+ `,
916
+ variables: {
917
+ postCode
918
+ }
919
+ })
920
+
921
+ if (!response.errors) {
922
+ const { stateName, cityName } = response.data.geoAreasGetStateAndCityByPosCode
923
+
924
+ switch (name) {
925
+ case 'postalCode':
926
+ this._cityInput.value = stateName
927
+ this._stateInput.value = cityName.toUpperCase()
928
+ break
929
+
930
+ case 'billingPostalCode':
931
+ this._cityBillingInput.value = stateName
932
+ this._stateBillingInput.value = cityName.toUpperCase()
933
+
934
+ default:
935
+ break
936
+ }
937
+ }
938
+ } catch (error) {
939
+ this._showToast(e)
940
+ }
941
+ }
942
+
402
943
  async _fetchTruckDriver() {
403
944
  const response = await client.query({
404
945
  query: gql`
@@ -452,6 +993,7 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
452
993
  }
453
994
 
454
995
  async fetchDeliveryInfo(isManualDO) {
996
+ let responseData = ''
455
997
  if (isManualDO) {
456
998
  const response = await client.query({
457
999
  query: gql`
@@ -462,6 +1004,7 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
462
1004
  releaseUomValue
463
1005
  status
464
1006
  remark
1007
+ palletQty
465
1008
  systemRemark
466
1009
  batchId
467
1010
  productId
@@ -481,7 +1024,9 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
481
1024
  this.doData = {
482
1025
  records: response.data.manualDeliveryOrderItems.items || []
483
1026
  }
1027
+ this.totalPalletQty = this.doData.palletQty
484
1028
  }
1029
+ responseData = response
485
1030
  } else {
486
1031
  const response = await client.query({
487
1032
  query: gql`
@@ -492,6 +1037,7 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
492
1037
  releaseUomValue
493
1038
  status
494
1039
  remark
1040
+ palletQty
495
1041
  systemRemark
496
1042
  batchId
497
1043
  productName
@@ -510,11 +1056,43 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
510
1056
  this.doData = {
511
1057
  records: response.data.deliveryOrderItems.items || []
512
1058
  }
1059
+
1060
+ this.totalPalletQty = this.doData.palletQty
513
1061
  }
1062
+ responseData = response
514
1063
  }
1064
+
1065
+ return responseData
515
1066
  }
516
1067
 
517
1068
  async _saveDeliveryInfo() {
1069
+ let shippingOrderInfo = {}
1070
+
1071
+ let contactPointInfo = this._serializeForm(this.shippingInfoForm)
1072
+
1073
+ let exportInfo = {}
1074
+ if (this.shippingOrderForm != null) {
1075
+ exportInfo = this._serializeForm(this.shippingOrderForm)
1076
+ } else {
1077
+ exportInfo = {}
1078
+ }
1079
+
1080
+ shippingOrderInfo = {
1081
+ ...contactPointInfo
1082
+ }
1083
+
1084
+ delete shippingOrderInfo['']
1085
+ delete shippingOrderInfo.matchDeliveryAddressInputa
1086
+
1087
+ // If match delivery address is ticked, all the billing address info will be the same with delivery address info
1088
+ if (this._disableBillingAddress) {
1089
+ shippingOrderInfo.billingAddress = contactPointInfo.deliveryAddress1
1090
+ shippingOrderInfo.billingPostalCode = contactPointInfo.postalCode
1091
+ shippingOrderInfo.billingCity = contactPointInfo.city
1092
+ shippingOrderInfo.billingState = contactPointInfo.state
1093
+ shippingOrderInfo.billingCountry = contactPointInfo.country
1094
+ }
1095
+
518
1096
  try {
519
1097
  let response = null
520
1098
  if (this.manualDo) {
@@ -537,8 +1115,18 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
537
1115
  } else {
538
1116
  response = await client.mutate({
539
1117
  mutation: gql`
540
- mutation dispatchDeliveryOrder($orderInfo: DeliveryOrderPatch, $orderItems: [OrderInventoryPatch!]) {
541
- dispatchDeliveryOrder(orderInfo: $orderInfo, orderItems: $orderItems) {
1118
+ mutation dispatchDeliveryOrder(
1119
+ $orderInfo: DeliveryOrderPatch
1120
+ $orderItems: [OrderInventoryPatch!]
1121
+ $shippingInfo: ShippingOrderInfoPatch
1122
+ $exportInfo: ExportInformationPatch
1123
+ ) {
1124
+ dispatchDeliveryOrder(
1125
+ orderInfo: $orderInfo
1126
+ orderItems: $orderItems
1127
+ shippingInfo: $shippingInfo
1128
+ exportInfo: $exportInfo
1129
+ ) {
542
1130
  id
543
1131
  name
544
1132
  description
@@ -548,7 +1136,9 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
548
1136
  `,
549
1137
  variables: {
550
1138
  orderInfo: { ...this._getDeliveryInfo() },
551
- orderItems: this._getOrderItems()
1139
+ orderItems: this._getOrderItems(),
1140
+ shippingInfo: shippingOrderInfo ? shippingOrderInfo : null,
1141
+ exportInfo: exportInfo ? exportInfo : null
552
1142
  }
553
1143
  })
554
1144
  }
@@ -567,6 +1157,235 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
567
1157
  }
568
1158
  }
569
1159
 
1160
+ async fetchCountry() {
1161
+ const response = await client.query({
1162
+ query: gql`
1163
+ query geoCountriesWithoutParam {
1164
+ geoCountriesWithoutParam {
1165
+ items {
1166
+ id
1167
+ name
1168
+ description
1169
+ }
1170
+ }
1171
+ }
1172
+ `
1173
+ })
1174
+
1175
+ if (!response.error) {
1176
+ this._billingAllCountry = response.data.geoCountriesWithoutParam.items
1177
+ this._deliveryAllCountry = response.data.geoCountriesWithoutParam.items
1178
+ }
1179
+ }
1180
+
1181
+ async _fetchReleaseOrder(roNo) {
1182
+ if (!roNo) return
1183
+ const response = await client.query({
1184
+ query: gql`
1185
+ query releaseGoodDetail($name: String!) {
1186
+ releaseGoodDetail(name: $name) {
1187
+ id
1188
+ name
1189
+ truckNo
1190
+ type
1191
+ attentionTo
1192
+ attentionCompany
1193
+ phone1
1194
+ deliveryAddress1
1195
+ billingAddress
1196
+ billingCity
1197
+ billingCountry
1198
+ billingPostalCode
1199
+ billingState
1200
+ city
1201
+ state
1202
+ postalCode
1203
+ country
1204
+ remark
1205
+ bizplace {
1206
+ id
1207
+ name
1208
+ }
1209
+ invStatus
1210
+ status
1211
+ refNo
1212
+ refNo2
1213
+ refNo3
1214
+ ownTransport
1215
+ crossDocking
1216
+ arrivalNotice {
1217
+ name
1218
+ }
1219
+ exportOption
1220
+ courierOption
1221
+ packingOption
1222
+ releaseDate
1223
+ collectionOrderNo
1224
+ attachment {
1225
+ id
1226
+ name
1227
+ refBy
1228
+ path
1229
+ mimetype
1230
+ }
1231
+ bizplace {
1232
+ id
1233
+ name
1234
+ description
1235
+ }
1236
+ inventoryInfos {
1237
+ id
1238
+ name
1239
+ batchId
1240
+ batchIdRef
1241
+ palletId
1242
+ product {
1243
+ id
1244
+ sku
1245
+ brand
1246
+ name
1247
+ description
1248
+ }
1249
+ productName
1250
+ packingType
1251
+ packingSize
1252
+ qty
1253
+ lockedQty
1254
+ lockedUomValue
1255
+ uomValue
1256
+ releaseQty
1257
+ releaseUomValue
1258
+ uom
1259
+ location {
1260
+ id
1261
+ name
1262
+ }
1263
+ status
1264
+ }
1265
+ shippingOrderInfo {
1266
+ id
1267
+ containerNo
1268
+ containerLeavingDate
1269
+ containerArrivalDate
1270
+ shipName
1271
+ }
1272
+ orderVass {
1273
+ vas {
1274
+ name
1275
+ operationGuide
1276
+ operationGuideType
1277
+ }
1278
+ set
1279
+ targetType
1280
+ targetBatchId
1281
+ targetProduct {
1282
+ id
1283
+ name
1284
+ description
1285
+ }
1286
+ packingType
1287
+ qty
1288
+ uomValue
1289
+ otherTarget
1290
+ description
1291
+ remark
1292
+ status
1293
+ operationGuide
1294
+ }
1295
+ }
1296
+ }
1297
+ `,
1298
+ variables: { name: roNo }
1299
+ })
1300
+
1301
+ if (!response.errors) {
1302
+ const releaseOrder = response.data.releaseGoodDetail
1303
+ // shipment info
1304
+ this._companyName = releaseOrder?.attentionCompany
1305
+ this._deliveryCity = releaseOrder?.city
1306
+ this._deliveryState = releaseOrder?.state
1307
+ this._deliveryCountry = releaseOrder?.country
1308
+ this._deliveryContact = releaseOrder?.phone1
1309
+ this._selectedBillingPostCode = releaseOrder?.billingPostalCode
1310
+ this._billingCity = releaseOrder?.billingCity
1311
+ this._billingState = releaseOrder?.billingState
1312
+ this._billingCountry = releaseOrder?.billingCountry
1313
+ this._selectedOwnTransport = releaseOrder?.ownTransport
1314
+ this.coNo = releaseOrder?.collectionOrderNo
1315
+ this._containerArrivalDate = releaseOrder?.shippingOrderInfo.containerArrivalDate
1316
+ this._containerLeavingDate = releaseOrder?.shippingOrderInfo.containerLeavingDate
1317
+ this._containerNo = releaseOrder?.shippingOrderInfo.containerNo
1318
+ this._shipName = releaseOrder?.shippingOrderInfo.shipName
1319
+ this._exportOption = releaseOrder?.exportOption
1320
+
1321
+ return releaseOrder
1322
+ }
1323
+ }
1324
+
1325
+ async _fetchDeliveryOrder(doNo) {
1326
+ if (!doNo) return
1327
+
1328
+ const response = await client.query({
1329
+ query: gql`
1330
+ query deliveryOrder($name: String!) {
1331
+ deliveryOrder(name: $name) {
1332
+ palletQty
1333
+ ownCollection
1334
+ attentionTo
1335
+ attentionCompany
1336
+ city
1337
+ state
1338
+ postalCode
1339
+ country
1340
+ phone1
1341
+ deliveryAddress1
1342
+ billingAddress
1343
+ billingCountry
1344
+ billingPostalCode
1345
+ billingState
1346
+ billingCity
1347
+ }
1348
+ }
1349
+ `,
1350
+ variables: { name: doNo }
1351
+ })
1352
+
1353
+ this._ownCollection = response.data.deliveryOrder.ownCollection
1354
+
1355
+ const deliveryOrder = response.data.deliveryOrder
1356
+
1357
+ this._deliveryOrder = {
1358
+ ...deliveryOrder
1359
+ }
1360
+
1361
+ this._fillupDAForm(deliveryOrder)
1362
+
1363
+ this._fillupBLForm(deliveryOrder)
1364
+
1365
+ this._fillupCPForm(deliveryOrder)
1366
+
1367
+ if (
1368
+ deliveryOrder?.postalCode === deliveryOrder?.billingPostalCode &&
1369
+ deliveryOrder?.billingAddress === deliveryOrder?.deliveryAddress1
1370
+ ) {
1371
+ this._disableBillingAddress = true
1372
+ } else {
1373
+ this._disableBillingAddress = false
1374
+ }
1375
+
1376
+ if (response.data.deliveryOrder.ownCollection) {
1377
+ this._determineOwnCollection = 'Own Transport'
1378
+ } else {
1379
+ this._determineOwnCollection = 'Warehouse Transport'
1380
+ }
1381
+
1382
+ return response
1383
+ }
1384
+
1385
+ initProperties() {
1386
+ this._transportType = ['Own Transport', 'Warehouse Transport']
1387
+ }
1388
+
570
1389
  _validateDeliveryInfo() {
571
1390
  let errorFields = []
572
1391
 
@@ -574,11 +1393,11 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
574
1393
  const transportFields = this._ownCollection
575
1394
  ? {
576
1395
  otherDriver: i18next.t('field.driver_name'),
577
- otherTruck: i18next.t('field.truck_no')
1396
+ otherTruck: i18next.t('field.vehicle_no')
578
1397
  }
579
1398
  : {
580
1399
  ownDriver: i18next.t('field.driver_name'),
581
- ownTruck: i18next.t('field.truck_no')
1400
+ ownTruck: i18next.t('field.vehicle_no')
582
1401
  }
583
1402
 
584
1403
  // destination field entries
@@ -612,7 +1431,25 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
612
1431
 
613
1432
  _getDeliveryInfo() {
614
1433
  if (this.shadowRoot.querySelector('form').checkValidity()) {
615
- this._validateDeliveryInfo()
1434
+ // this._validateDeliveryInfo()
1435
+
1436
+ if (this._ownCollection) {
1437
+ if (this.otherDriverInput.value == '') {
1438
+ throw new Error(i18next.t('text.driver_is_empty'))
1439
+ }
1440
+
1441
+ if (this.otherTruckInput.value == '') {
1442
+ throw new Error(i18next.t('text.vehicle_no_is_empty'))
1443
+ }
1444
+ } else {
1445
+ if (this._truckNoInput.value == '') {
1446
+ throw new Error(i18next.t('text.vehicle_no_is_empty'))
1447
+ }
1448
+
1449
+ if (this._truckDriverInput.value == '') {
1450
+ throw new Error(i18next.t('text.driver_is_empty'))
1451
+ }
1452
+ }
616
1453
 
617
1454
  const deliveryInfo = this._serializeForm(this.doForm)
618
1455
  delete deliveryInfo.otherDestBoolean
@@ -621,7 +1458,10 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
621
1458
  ...deliveryInfo,
622
1459
  name: this.doNo,
623
1460
  contactPoint: this._otherDestination ? null : this.selectedCP,
624
- otherTruck: this._ownCollection ? deliveryInfo.otherTruck.toUpperCase().replace(/\s+/g, '') : null
1461
+ otherTruck:
1462
+ this._ownCollection && deliveryInfo.otherTruck
1463
+ ? deliveryInfo.otherTruck.toUpperCase().replace(/\s+/g, '')
1464
+ : null
625
1465
  }
626
1466
  } else {
627
1467
  throw new Error(i18next.t('text.delivery_info_not_valid'))
@@ -646,6 +1486,109 @@ class DeliveryNotePopup extends localize(i18next)(LitElement) {
646
1486
  }
647
1487
  }
648
1488
 
1489
+ async _tabChange(key) {
1490
+ if (key == 'order') {
1491
+ this._showReleasedOrderInfo = false
1492
+ this._showShippingInfo = true
1493
+ this.initProperties()
1494
+ } else {
1495
+ await this._getAllPostCode()
1496
+ this._showReleasedOrderInfo = true
1497
+ this._showShippingInfo = false
1498
+ this._exportOption = false
1499
+ }
1500
+ }
1501
+
1502
+ _fillUpDeliveryInfo(data) {
1503
+ // remapping according release good table
1504
+ const remapData = {
1505
+ attentionCompany: data.companyName || '',
1506
+ attentionTo: data.name || '',
1507
+ city: data.city || '',
1508
+ state: data.state || '',
1509
+ postalCode: data.postCode || '',
1510
+ country: 'Malaysia',
1511
+ phone1: data.phone || '',
1512
+ deliveryAddress1: data.address ? data.address : '' + data.address2 ? data.address2 : '',
1513
+ billingAddress: data.billingAddress
1514
+ }
1515
+
1516
+ this._selectedPostCode = data.postCode
1517
+
1518
+ this._fillupForm(this.shippingInfoForm, remapData)
1519
+ }
1520
+
1521
+ _resetShippingInfoForm() {
1522
+ this.getContactPointForm.reset()
1523
+ }
1524
+
1525
+ _fillupForm(form, data) {
1526
+ if (form) {
1527
+ form.reset()
1528
+ for (let key in data) {
1529
+ Array.from(form.querySelectorAll('input, textarea', 'select')).forEach(field => {
1530
+ if (field.name === key && field.type === 'checkbox') {
1531
+ field.checked = data[key]
1532
+ } else if (field.name === key && field.type === 'datetime-local') {
1533
+ const datetime = Number(data[key])
1534
+ const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
1535
+ field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
1536
+ } else if (field.name === key) {
1537
+ if (data[key] instanceof Object) {
1538
+ const objectData = data[key]
1539
+ field.value = `${objectData.name} ${objectData.description ? `(${objectData.description})` : ''}`
1540
+ } else {
1541
+ field.value = data[key]
1542
+ }
1543
+ }
1544
+ })
1545
+ }
1546
+ }
1547
+ }
1548
+
1549
+ _validateCountry(e) {
1550
+ if (e.target.value != 'MALAYSIA') {
1551
+ this._selectedCountry = e.target.value
1552
+ } else {
1553
+ this._selectedCountry = e.target.value
1554
+ }
1555
+ }
1556
+
1557
+ _validateBillingCountry(e) {
1558
+ if (e.target.value != 'MALAYSIA') {
1559
+ this._selectedBillingCountry = e.target.value
1560
+ } else {
1561
+ this._selectedBillingCountry = e.target.value
1562
+ }
1563
+ }
1564
+
1565
+ _fillupDAForm(data) {
1566
+ this._fillupForm(this.deliveryAddressForm, data)
1567
+ this._selectedCountry = data.country || 'MALAYSIA'
1568
+ this._deliveryOrder.postalCode = data.postalCode
1569
+ }
1570
+
1571
+ _fillupBLForm(data) {
1572
+ this._fillupForm(this.billingAddressForm, data)
1573
+ this._selectedBillingCountry = data.billingCountry || 'MALAYSIA'
1574
+ this._deliveryOrder.billingPostalCode = data.billingPostalCode
1575
+ }
1576
+
1577
+ _fillupCPForm(data) {
1578
+ this._fillupForm(this.contactPointForm, data)
1579
+ }
1580
+
1581
+ _serializeFormRO(form) {
1582
+ let obj = {}
1583
+ Array.from(form.querySelectorAll('input, select')).forEach(field => {
1584
+ if (!field.hasAttribute('hidden') && field.value) {
1585
+ obj[field.name] = field.type === 'checkbox' ? field.checked : field.value
1586
+ }
1587
+ })
1588
+
1589
+ return obj
1590
+ }
1591
+
649
1592
  _showToast({ type, message }) {
650
1593
  document.dispatchEvent(
651
1594
  new CustomEvent('notify', {