@things-factory/operato-wms 4.3.238 → 4.3.241

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 (85) hide show
  1. package/client/pages/components/vas-templates/vas-pallet-add-popup.js +1 -0
  2. package/client/pages/components/vas-templates/vas-relabel.js +1 -0
  3. package/client/pages/components/vas-templates/vas-repack-relabel.js +1 -0
  4. package/client/pages/components/vas-templates/vas-repack.js +1 -0
  5. package/client/pages/components/vas-templates/vas-repalletizing.js +1 -0
  6. package/client/pages/components/vas-templates/vas-template.js +1 -0
  7. package/client/pages/components/vas-templates/vas-unpack.js +1 -0
  8. package/client/pages/constants/vas-target-type.js +1 -0
  9. package/client/pages/constants/worksheet.js +4 -0
  10. package/client/pages/inbound/adjust-pallet-qty.js +1 -1
  11. package/client/pages/inbound/inbound-worksheet.js +1 -0
  12. package/client/pages/inbound/palletizing-pallets-popup.js +1 -1
  13. package/client/pages/inbound/unload-product.js +1 -0
  14. package/client/pages/inbound/vas-selector.js +1 -0
  15. package/client/pages/inbound/worksheet-putaway.js +1 -0
  16. package/client/pages/inbound/worksheet-unloading.js +1 -0
  17. package/client/pages/order/arrival-notice/arrival-notice-detail.js +1 -0
  18. package/client/pages/order/arrival-notice/assign-buffer-location.js +1 -0
  19. package/client/pages/order/arrival-notice/check-arrived-notice.js +1 -0
  20. package/client/pages/order/arrival-notice/create-arrival-notice.js +1 -0
  21. package/client/pages/order/arrival-notice/duplicate-arrival-notice.js +1 -0
  22. package/client/pages/order/arrival-notice/receive-arrival-notice.js +1 -0
  23. package/client/pages/order/arrival-notice/rejected-arrival-notice.js +1 -0
  24. package/client/pages/order/release-order/create-release-order.js +713 -84
  25. package/client/pages/order/release-order/receive-release-order-request.js +1 -0
  26. package/client/pages/order/release-order/rejected-release-order.js +1 -0
  27. package/client/pages/order/release-order/release-order-detail.js +1020 -388
  28. package/client/pages/order/return-order/check-return-order.js +1 -0
  29. package/client/pages/order/return-order/rejected-return-order.js +2 -0
  30. package/client/pages/order/return-order/return-order-assign-buffer-location.js +1 -0
  31. package/client/pages/order/return-order/return-order-detail.js +1 -0
  32. package/client/pages/order/reverse-kitting-order/reverse-kitting-pallet-label-popup.js +1 -0
  33. package/client/pages/order/transfer-order/rejected-transfer-order.js +1 -0
  34. package/client/pages/order/vas-order/create-vas-order.js +1 -0
  35. package/client/pages/order/vas-order/popup/abastract-vas-create-form.js +1 -0
  36. package/client/pages/order/vas-order/popup/select-vas-popup.js +220 -0
  37. package/client/pages/order/vas-order/popup/vas-create-batch-product-type-form.js +1 -0
  38. package/client/pages/order/vas-order/popup/vas-create-batch-type-form.js +1 -0
  39. package/client/pages/order/vas-order/popup/vas-create-etc-type-form.js +1 -0
  40. package/client/pages/order/vas-order/popup/vas-create-popup.js +1 -0
  41. package/client/pages/order/vas-order/popup/vas-create-product-type-form.js +1 -0
  42. package/client/pages/order/vas-order/popup/vas-target-product-popup.js +644 -0
  43. package/client/pages/order/vas-order/receive-vas-order.js +1 -0
  44. package/client/pages/order/vas-order/vas-order-detail.js +1 -0
  45. package/client/pages/order/vas-order/vas-order-list.js +1 -0
  46. package/client/pages/order/vas-order/vas-order-requests.js +1 -0
  47. package/client/pages/outbound/loading-product.js +109 -14
  48. package/client/pages/outbound/picking-product.js +59 -1
  49. package/client/pages/outbound/vas-list-popup.js +367 -0
  50. package/client/pages/outbound/worksheet-loading.js +13 -8
  51. package/client/pages/outbound/worksheet-picking.js +4 -0
  52. package/client/pages/report/vas-report.js +534 -0
  53. package/client/pages/vas/abstract-execute-vas.js +2 -1
  54. package/client/pages/vas/execute-pure-vas.js +1 -0
  55. package/client/pages/vas/execute-ref-vas.js +1 -0
  56. package/client/pages/vas/execute-vas.js +2 -2
  57. package/client/pages/vas/related-vas-list.js +1 -0
  58. package/client/pages/vas/vas-execution-page.js +469 -0
  59. package/client/pages/vas/vas-pallet-label-popup.js +1 -0
  60. package/client/pages/vas/vas-worksheet-list.js +1 -0
  61. package/client/pages/vas/worksheet-ref-vas.js +97 -36
  62. package/client/pages/vas/worksheet-vas.js +1 -0
  63. package/client/route.js +9 -0
  64. package/config.development.js +16 -16
  65. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  66. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  67. package/dist-server/graphql/resolvers/reports/vas-report.js +118 -0
  68. package/dist-server/graphql/resolvers/reports/vas-report.js.map +1 -0
  69. package/dist-server/graphql/types/reports/index.js +6 -1
  70. package/dist-server/graphql/types/reports/index.js.map +1 -1
  71. package/dist-server/graphql/types/reports/vas-report-list.js +14 -0
  72. package/dist-server/graphql/types/reports/vas-report-list.js.map +1 -0
  73. package/dist-server/graphql/types/reports/vas-report.js +18 -0
  74. package/dist-server/graphql/types/reports/vas-report.js.map +1 -0
  75. package/package.json +7 -7
  76. package/server/graphql/resolvers/reports/index.ts +3 -1
  77. package/server/graphql/resolvers/reports/vas-report.ts +135 -0
  78. package/server/graphql/types/reports/index.ts +7 -1
  79. package/server/graphql/types/reports/vas-report-list.ts +8 -0
  80. package/server/graphql/types/reports/vas-report.ts +12 -0
  81. package/things-factory.config.js +11 -0
  82. package/translations/en.json +30 -5
  83. package/translations/ko.json +26 -1
  84. package/translations/ms.json +26 -1
  85. package/translations/zh.json +26 -1
@@ -7,31 +7,22 @@ import '../../components/popup-note'
7
7
  import '../release-order/tracking-information-popup'
8
8
  import '@things-factory/component-ui'
9
9
  import '@things-factory/import-ui'
10
+ import '../../components/select-product-popup'
11
+ import '../../order/vas-order/popup/vas-target-product-popup'
12
+ import '../../order/vas-order/popup/select-vas-popup'
10
13
 
11
14
  import gql from 'graphql-tag'
12
- import {
13
- css,
14
- html
15
- } from 'lit-element'
15
+ import { css, html } from 'lit-element'
16
16
  import { connect } from 'pwa-helpers/connect-mixin'
17
17
 
18
18
  import { getCodeByName } from '@things-factory/code-base'
19
19
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
20
20
  import { getRenderer } from '@things-factory/grist-ui'
21
- import {
22
- i18next,
23
- localize
24
- } from '@things-factory/i18n-base'
21
+ import { i18next, localize } from '@things-factory/i18n-base'
25
22
  import { openPopup } from '@things-factory/layout-base'
26
- import {
27
- client,
28
- CustomAlert,
29
- navigate,
30
- PageView,
31
- store
32
- } from '@things-factory/shell'
23
+ import { client, CustomAlert, navigate, PageView, store } from '@things-factory/shell'
33
24
  import { CommonButtonStyles } from '@things-factory/styles'
34
- import { isMobileDevice } from '@things-factory/utils'
25
+ import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
35
26
 
36
27
  import { fetchSettingRule } from '../../../fetch-setting-value'
37
28
  import {
@@ -39,7 +30,6 @@ import {
39
30
  PICKING_STANDARD,
40
31
  VAS_BATCH_AND_PRODUCT_TYPE,
41
32
  VAS_BATCH_NO_TYPE,
42
- VAS_ETC_TYPE,
43
33
  VAS_PRODUCT_TYPE
44
34
  } from '../../constants'
45
35
 
@@ -50,7 +40,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
50
40
  _userRoles: Array,
51
41
  _releaseOrderNo: String,
52
42
  _roInfo: Object,
53
- _template: Object,
43
+ // _template: Object,
54
44
  _ownTransport: Boolean,
55
45
  _crossDocking: Boolean,
56
46
  _ganNo: String,
@@ -75,7 +65,6 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
75
65
  _shippingOrder: Object,
76
66
  _containerArrivalDate: Date,
77
67
  _containerLeavingDate: Date,
78
- _vasExpanded: Boolean,
79
68
  _beforeRemark: String,
80
69
  isUserBelongsDomain: Boolean,
81
70
  _isInBatchPicking: Boolean,
@@ -117,6 +106,8 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
117
106
  _showShippingInfo: Boolean,
118
107
  _disableBillingAddress: Boolean,
119
108
  _showExportInfo: Boolean,
109
+ _showVasInfo: Boolean,
110
+ _showVasSummary: Boolean,
120
111
  currentTab: Object
121
112
  }
122
113
  }
@@ -181,12 +172,17 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
181
172
  padding-top: var(--grist-title-with-grid-padding);
182
173
  }
183
174
 
184
- .vas[collapsable] {
185
- height: 40%;
175
+ .vas {
176
+ height: 100%;
186
177
  }
187
- .vas[collapsable][collapsed] {
188
- display: none;
178
+ .vas-button-container {
179
+ padding: var(--button-container-padding);
180
+ margin: var(--button-container-margin);
181
+ text-align: right;
182
+ background-color: var(--button-container-background);
183
+ height: var(--button-container-height);button-container
189
184
  }
185
+
190
186
  data-grist#vas-grist {
191
187
  padding-top: 0px;
192
188
  height: 100%;
@@ -276,17 +272,30 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
276
272
  ]
277
273
  }
278
274
 
275
+ get _editVasStatus() {
276
+ return [
277
+ ORDER_STATUS.PENDING.value,
278
+ ORDER_STATUS.PENDING_RECEIVE.value,
279
+ ORDER_STATUS.PENDING_WORKSHEET.value,
280
+ ORDER_STATUS.READY_TO_PICK.value
281
+ ]
282
+ }
283
+ //vas -- edit this. make vas editable if status != PICKING
279
284
  render() {
280
285
  const RELEASE_ORDER_TABS = {
281
286
  RELEASE_ORDER_INFO: i18next.t('label.order'),
282
287
  SHIPPING_INFO: i18next.t('label.shipment'),
283
- EXPORT_INFO: i18next.t('label.export')
288
+ EXPORT_INFO: i18next.t('label.export'),
289
+ VAS_INFO: i18next.t('label.vas'),
290
+ VAS_SUMMARY: i18next.t('label.vas_summary')
284
291
  }
285
292
 
286
293
  const orderSet = {
287
294
  [RELEASE_ORDER_TABS.RELEASE_ORDER_INFO]: {},
288
295
  [RELEASE_ORDER_TABS.SHIPPING_INFO]: {},
289
- [RELEASE_ORDER_TABS.EXPORT_INFO]: {}
296
+ [RELEASE_ORDER_TABS.EXPORT_INFO]: {},
297
+ [RELEASE_ORDER_TABS.VAS_INFO]: {},
298
+ [RELEASE_ORDER_TABS.VAS_SUMMARY]: {}
290
299
  }
291
300
 
292
301
  const disabledKey = {
@@ -294,21 +303,20 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
294
303
  }
295
304
 
296
305
  return html`
297
- <div class="quick-find-content-container" >
306
+ <div class="quick-find-content-container">
298
307
  <quick-find-content
299
- id="order-items-list"
300
- name="quickFindContent"
301
- .disabledKey="${disabledKey}"
302
- .data="${orderSet}"
303
- @tabChanged="${e => {
304
- this._tabChange(e.detail.currentTabKey)
305
- }}"
308
+ id="order-items-list"
309
+ name="quickFindContent"
310
+ .disabledKey="${disabledKey}"
311
+ .data="${orderSet}"
312
+ @tabChanged="${e => {
313
+ this._tabChange(e.detail.currentTabKey)
314
+ }}"
306
315
  ></quick-find-content>
307
316
  </div>
308
317
 
309
318
  <div ?hidden="${this._showReleasedOrderInfo}">
310
319
  <div class="form-container">
311
-
312
320
  <form name="releaseOrder" class="multi-column-form">
313
321
  <fieldset>
314
322
  <legend>${i18next.t('title.release_order_no')}: ${this._releaseOrderNo}</legend>
@@ -399,29 +407,30 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
399
407
  />
400
408
  <label for="exportOption">${i18next.t('label.export')}</label>
401
409
 
410
+ <input id="recall" type="checkbox" name="recall" ?checked="${this._recallOption}" disabled />
411
+ <label for="recall">${i18next.t('label.recall')}</label>
412
+
402
413
  <input
403
- id="recall"
404
- type="checkbox"
405
- name="recall"
406
- ?checked="${this._recallOption}"
407
- disabled
408
- />
409
- <label for="recall">${i18next.t('label.recall')}</label>
410
-
411
- ${
412
- this._crossDocking
413
- ? html`
414
- <input
415
- id="crossDocking"
416
- type="checkbox"
417
- name="crossDocking"
418
- ?checked="${this._crossDocking}"
419
- disabled
420
- />
421
- <label for="crossDocking">${i18next.t('label.cross_docking')}</label>
422
- `
423
- : ''
424
- }
414
+ id="recall"
415
+ type="checkbox"
416
+ name="vas"
417
+ ?checked="${this.vasData?.records?.length > 0 ? true : false}"
418
+ disabled
419
+ />
420
+ <label for="vas">${i18next.t('label.vas')}</label>
421
+
422
+ ${this._crossDocking
423
+ ? html`
424
+ <input
425
+ id="crossDocking"
426
+ type="checkbox"
427
+ name="crossDocking"
428
+ ?checked="${this._crossDocking}"
429
+ disabled
430
+ />
431
+ <label for="crossDocking">${i18next.t('label.cross_docking')}</label>
432
+ `
433
+ : ''}
425
434
  </div>
426
435
 
427
436
  <label>${i18next.t('label.company')}</label>
@@ -443,40 +452,44 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
443
452
  <input name="collectionOrderNo" ?hidden="${!this._ownTransport}" ?readonly="${!this?._editable}" />
444
453
 
445
454
  <label ?hidden="${this.roType === 'b2b'}">${i18next.t('label.order_remark')}</label>
446
- <textarea name="remark" ?hidden="${this.roType === 'b2b'}" rows="5" ?readonly="${!this
447
- ?._editable}"></textarea>
455
+ <textarea
456
+ name="remark"
457
+ ?hidden="${this.roType === 'b2b'}"
458
+ rows="5"
459
+ ?readonly="${!this?._editable}"
460
+ ></textarea>
448
461
 
449
462
  <label ?hidden="${this.roType === 'b2b'}">${i18next.t('label.tracking_no')}</label>
450
- <textarea name="trackingNos" ?hidden="${this.roType === 'b2b'}" rows="5" ?readonly="${!this
451
- ?._editable}"></textarea>
452
-
453
- ${
454
- this._crossDocking
455
- ? html`
456
- <label for="ganNo">${i18next.t('label.arrival_notice')}</label>
457
- <input disabled name="ganNo" .value="${this._ganNo}" />
458
- `
459
- : ''
460
- }
461
- ${
462
- this._attachments?.length > 0
463
- ? html`
464
- <label>${i18next.t('label.attachment')}</label>
465
- <ul attachment-wrap>
466
- ${(this._attachments || []).map(
467
- attachment =>
468
- html`
469
- <li>
470
- <a href="${location.origin}/attachment/${attachment.path}" download
471
- ><mwc-icon>attach_file</mwc-icon> ${attachment.name}</a
472
- >
473
- </li>
474
- `
475
- )}
476
- </ul>
477
- `
478
- : ''
479
- }
463
+ <textarea
464
+ name="trackingNos"
465
+ ?hidden="${this.roType === 'b2b'}"
466
+ rows="5"
467
+ ?readonly="${!this?._editable}"
468
+ ></textarea>
469
+
470
+ ${this._crossDocking
471
+ ? html`
472
+ <label for="ganNo">${i18next.t('label.arrival_notice')}</label>
473
+ <input disabled name="ganNo" .value="${this._ganNo}" />
474
+ `
475
+ : ''}
476
+ ${this._attachments?.length > 0
477
+ ? html`
478
+ <label>${i18next.t('label.attachment')}</label>
479
+ <ul attachment-wrap>
480
+ ${(this._attachments || []).map(
481
+ attachment =>
482
+ html`
483
+ <li>
484
+ <a href="${location.origin}/attachment/${attachment.path}" download
485
+ ><mwc-icon>attach_file</mwc-icon> ${attachment.name}</a
486
+ >
487
+ </li>
488
+ `
489
+ )}
490
+ </ul>
491
+ `
492
+ : ''}
480
493
  </fieldset>
481
494
  </form>
482
495
 
@@ -484,162 +497,155 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
484
497
  </div>
485
498
  </div>
486
499
 
487
-
488
- <form name="shippingInfo" ?hidden="${this._showShippingInfo}" class="multi-column-form" autocomplete="off">
489
-
500
+ <form name="shippingInfo" ?hidden="${this._showShippingInfo}" class="multi-column-form" autocomplete="off">
490
501
  <legend>${i18next.t('title.shipping_information')}</legend>
491
502
 
492
-
493
- <label>${i18next.t('label.company')}</label>
494
- <input name="attentionCompany" .value="${this._releaseOrder.attentionCompany}" />
495
-
496
- <label>${i18next.t('label.attention_to')}</label>
497
- <input name="attentionTo" .value="${this._releaseOrder.attentionTo}" />
498
-
499
-
500
- <button type="button" @click="${this._openContactPointSelector.bind(this)}">import</button>
501
-
502
-
503
- <!-- delivery -->
504
-
505
- <label class="section-header">${i18next.t('label.delivery_address')}</label>
506
- <label>${i18next.t('label.country')}</label>
507
- <select
508
- name="country"
509
- @change=${e => {
510
- this._validateCountry(e)
511
- }}
512
- >
513
- ${this._deliveryAllCountry?.map(
514
- (country, key) =>
515
- html`<option value=${country.description} ?selected=${country.description === this._selectedCountry}>
516
- ${country.name}
517
- </option>`
518
- )}
519
- </select>
520
-
521
- <label>${i18next.t('label.zip_postal_code')}</label>
522
- ${
523
- this._selectedCountry !== 'MY'
524
- ? html` <input name="postalCode" .value="" /> `
525
- : html`<select
526
- name="postalCode"
527
- @change=${e => {
528
- this._getStateAndCityByPostCode(e.target.value, e.target.name)
529
- }}
530
- value=${this?._selectedPostCode || ''}
531
- >
532
- <option value=""></option>
533
- ${this._deliveryPostCode.map(
534
- (country, key) =>
535
- html`<option
536
- ?selected=${(this._selectedPostCode.length > 0
537
- ? this._selectedPostCode
538
- : this._releaseOrder.postalCode) == country.postalCode}
539
- value=${country.postalCode}
540
- >
541
- ${country.postalCode}
542
- </option>`
543
- )}
544
- </select>`
545
- }
503
+ <label>${i18next.t('label.company')}</label>
504
+ <input name="attentionCompany" .value="${this._releaseOrder.attentionCompany}" />
505
+
506
+ <label>${i18next.t('label.attention_to')}</label>
507
+ <input name="attentionTo" .value="${this._releaseOrder.attentionTo}" />
508
+
509
+ <button type="button" @click="${this._openContactPointSelector.bind(this)}">import</button>
510
+
511
+ <!-- delivery -->
512
+
513
+ <label class="section-header">${i18next.t('label.delivery_address')}</label>
514
+ <label>${i18next.t('label.country')}</label>
515
+ <select
516
+ name="country"
517
+ @change=${e => {
518
+ this._validateCountry(e)
519
+ }}
520
+ >
521
+ ${this._deliveryAllCountry?.map(
522
+ (country, key) =>
523
+ html`<option value=${country.description} ?selected=${country.description === this._selectedCountry}>
524
+ ${country.name}
525
+ </option>`
526
+ )}
527
+ </select>
528
+
529
+ <label>${i18next.t('label.zip_postal_code')}</label>
530
+ ${this._selectedCountry !== 'MY'
531
+ ? html` <input name="postalCode" .value="" /> `
532
+ : html`<select
533
+ name="postalCode"
534
+ @change=${e => {
535
+ this._getStateAndCityByPostCode(e.target.value, e.target.name)
536
+ }}
537
+ value=${this?._selectedPostCode || ''}
538
+ >
539
+ <option value=""></option>
540
+ ${this._deliveryPostCode.map(
541
+ (country, key) =>
542
+ html`<option
543
+ ?selected=${(this._selectedPostCode.length > 0
544
+ ? this._selectedPostCode
545
+ : this._releaseOrder.postalCode) == country.postalCode}
546
+ value=${country.postalCode}
547
+ >
548
+ ${country.postalCode}
549
+ </option>`
550
+ )}
551
+ </select>`}
546
552
 
547
- <label>${i18next.t('label.state')}</label>
548
- <input name="state" .value="${this._releaseOrder.state}" />
553
+ <label>${i18next.t('label.state')}</label>
554
+ <input name="state" .value="${this._releaseOrder.state}" />
549
555
 
550
- <label>${i18next.t('label.city')}</label>
551
- <input name="city" .value="${this._releaseOrder.city}" />
556
+ <label>${i18next.t('label.city')}</label>
557
+ <input name="city" .value="${this._releaseOrder.city}" />
552
558
 
553
- <label>${i18next.t('label.delivery_address')}</label>
554
- <textarea name="deliveryAddress1" .value="${this._releaseOrder.deliveryAddress1}"></textarea>
559
+ <label>${i18next.t('label.delivery_address')}</label>
560
+ <textarea name="deliveryAddress1" .value="${this._releaseOrder.deliveryAddress1}"></textarea>
555
561
 
556
- <label>${i18next.t('label.contact')}</label>
557
- <input name="phone1" value="${this._releaseOrder.phone1}" />
562
+ <label>${i18next.t('label.contact')}</label>
563
+ <input name="phone1" value="${this._releaseOrder.phone1}" />
558
564
 
559
- <!-- billing -->
565
+ <!-- billing -->
560
566
  <label class="section-header">${i18next.t('label.billing_address')}</label>
561
- <label>${i18next.t('label.country')}</label>
562
-
563
- <select
564
- name="billingCountry"
565
- ?disabled=${this._disableBillingAddress}
566
- @change=${e => {
567
- this._validateBillingCountry(e)
568
- }}
569
- >
570
- ${this._deliveryAllCountry.map(
571
- (country, key) =>
572
- html`<option
573
- value=${country.description}
574
- ?selected=${country.description === this._selectedBillingCountry}
575
- >
576
- ${country.name}
577
- </option>`
578
- )}
579
- </select>
580
-
581
-
582
- <label>${i18next.t('label.zip_postal_code')}</label>
583
-
584
-
585
- ${
586
- this._selectedBillingCountry !== 'MY'
587
- ? html`
588
- <input
589
- ?disabled=${this._disableBillingAddress}
590
- name="billingPostalCode"
591
- .value=${this._releaseOrder.billingPostalCode || this._releaseOrder.postalCode}
592
- />
593
- `
594
- : html`<select
595
- ?disabled=${this._disableBillingAddress}
596
- name="billingPostalCode"
597
- @change=${e => {
598
- this._getStateAndCityByPostCode(e.target.value, e.target.name)
599
- }}
600
- value=${this._releaseOrder.billingPostalCode || this._releaseOrder.postalCode}
567
+ <label>${i18next.t('label.country')}</label>
568
+
569
+ <select
570
+ name="billingCountry"
571
+ ?disabled=${this._disableBillingAddress}
572
+ @change=${e => {
573
+ this._validateBillingCountry(e)
574
+ }}
575
+ >
576
+ ${this._deliveryAllCountry.map(
577
+ (country, key) =>
578
+ html`<option
579
+ value=${country.description}
580
+ ?selected=${country.description === this._selectedBillingCountry}
581
+ >
582
+ ${country.name}
583
+ </option>`
584
+ )}
585
+ </select>
586
+
587
+ <label>${i18next.t('label.zip_postal_code')}</label>
588
+
589
+ ${this._selectedBillingCountry !== 'MY'
590
+ ? html`
591
+ <input
592
+ ?disabled=${this._disableBillingAddress}
593
+ name="billingPostalCode"
594
+ .value=${this._releaseOrder.billingPostalCode || this._releaseOrder.postalCode}
595
+ />
596
+ `
597
+ : html`<select
598
+ ?disabled=${this._disableBillingAddress}
599
+ name="billingPostalCode"
600
+ @change=${e => {
601
+ this._getStateAndCityByPostCode(e.target.value, e.target.name)
602
+ }}
603
+ value=${this._releaseOrder.billingPostalCode || this._releaseOrder.postalCode}
604
+ >
605
+ <option value=""></option>
606
+
607
+ ${this._billingPostCode.map(
608
+ (country, key) =>
609
+ html`<option
610
+ ?selected=${(this._releaseOrder.billingPostalCode || this._releaseOrder.postalCode) ==
611
+ country.postalCode}
612
+ value=${country.postalCode}
601
613
  >
602
- <option value=""></option>
603
-
604
- ${this._billingPostCode.map(
605
- (country, key) =>
606
- html`<option
607
- ?selected=${(this._releaseOrder.billingPostalCode || this._releaseOrder.postalCode) ==
608
- country.postalCode}
609
- value=${country.postalCode}
610
- >
611
- ${country.postalCode}
612
- </option>`
613
- )}
614
- </select>`
615
- }
616
-
617
- <label>${i18next.t('label.state')}</label>
618
- <input ?disabled=${this._disableBillingAddress} name="billingState" .value="${
619
- this._releaseOrder.billingState
620
- }" />
621
-
622
- <label>${i18next.t('label.city')}</label>
623
- <input ?disabled=${this._disableBillingAddress} name="billingCity" .value="${
624
- this._releaseOrder.billingCity
625
- }" />
626
-
627
- <label>${i18next.t('label.billing_address')}</label>
628
- <textarea ?disabled=${this._disableBillingAddress} name="billingAddress" .value="${
629
- this._releaseOrder.billingAddress || ''
630
- }"></textarea>
631
-
632
- <input type="checkbox" id="matchDeliveryAddress" name="matchDeliveryAddressInput" ?checked=${
633
- this._releaseOrder.postalCode == this._releaseOrder.billingPostalCode &&
634
- this._releaseOrder.billingAddress == this._releaseOrder.deliveryAddress1
635
- } @click=${e => {
636
- e.currentTarget.checked ? (this._disableBillingAddress = true) : (this._disableBillingAddress = false)
637
- e.currentTarget.checked ? this.matchDeliveryAddress() : ''
638
- this.matchDeliveryAddressInput.value = this.matchDeliveryAddressInput.value === 'on' ? 'off' : 'on'
639
- }} />
640
- <label for="matchDeliveryAddress">${i18next.t('label.match_delivery_address')}</label>
641
-
642
-
614
+ ${country.postalCode}
615
+ </option>`
616
+ )}
617
+ </select>`}
618
+
619
+ <label>${i18next.t('label.state')}</label>
620
+ <input
621
+ ?disabled=${this._disableBillingAddress}
622
+ name="billingState"
623
+ .value="${this._releaseOrder.billingState}"
624
+ />
625
+
626
+ <label>${i18next.t('label.city')}</label>
627
+ <input ?disabled=${this._disableBillingAddress} name="billingCity" .value="${this._releaseOrder.billingCity}" />
628
+
629
+ <label>${i18next.t('label.billing_address')}</label>
630
+ <textarea
631
+ ?disabled=${this._disableBillingAddress}
632
+ name="billingAddress"
633
+ .value="${this._releaseOrder.billingAddress || ''}"
634
+ ></textarea>
635
+
636
+ <input
637
+ type="checkbox"
638
+ id="matchDeliveryAddress"
639
+ name="matchDeliveryAddressInput"
640
+ ?checked=${this._releaseOrder.postalCode == this._releaseOrder.billingPostalCode &&
641
+ this._releaseOrder.billingAddress == this._releaseOrder.deliveryAddress1}
642
+ @click=${e => {
643
+ e.currentTarget.checked ? (this._disableBillingAddress = true) : (this._disableBillingAddress = false)
644
+ e.currentTarget.checked ? this.matchDeliveryAddress() : ''
645
+ this.matchDeliveryAddressInput.value = this.matchDeliveryAddressInput.value === 'on' ? 'off' : 'on'
646
+ }}
647
+ />
648
+ <label for="matchDeliveryAddress">${i18next.t('label.match_delivery_address')}</label>
643
649
  </form>
644
650
 
645
651
  <form name="exportInfo" ?hidden="${this._showExportInfo}" class="multi-column-form" autocomplete="off">
@@ -650,75 +656,73 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
650
656
  ?checked="${this._containerClosureDate !== '' || this._remindContainerDepature == true ? true : false}"
651
657
  />
652
658
  <label style="width:500px" class="label-remind-container-departure" for="remindContainerDeparture">${i18next.t(
653
- 'label.remind_container_departure'
654
- )}</label>
659
+ 'label.remind_container_departure'
660
+ )}</label>
655
661
  </div> -->
656
662
 
657
663
  <label>${i18next.t('label.container_size')}</label>
658
- <select name="containerSize" required>
659
- <option value="">--${i18next.t('label.please_select_a_container_size')}--</option>
660
- ${(this.containerSizes || []).map(
661
- containerSize =>
662
- html`
663
- <option
664
- value="${containerSize && containerSize.name}"
665
- ?selected="${containerSize.name === this._shippingOrder?.containerSize ? true : false}"
666
- >
667
- ${containerSize && containerSize.name}
668
- </option>
669
- `
670
- )}
671
- </select>
672
-
673
- <label>${i18next.t('label.container_no')}</label>
674
- <input name="containerNo" required />
675
-
676
-
677
- <label>${i18next.t('label.container_arrival_date')}</label>
678
- <input
679
- name="containerArrivalDate"
680
- type="date"
681
- .value="${this._containerArrivalDate}"
682
- @change="${e => {
683
- this._containerClosureDateInput.setAttribute('min', e.currentTarget.value)
684
- }}"
685
- required
686
- />
687
-
688
- <label>${i18next.t('label.container_departure_date')}</label>
689
- <input
690
- name="containerLeavingDate"
691
- type="date"
692
- .value="${this._containerArrivalDate}"
693
- @change="${e => {
694
- this._containerArrivalDateInput.setAttribute('max', e.currentTarget.value)
695
- }}"
696
- required
697
- />
664
+ <select name="containerSize" required>
665
+ <option value="">--${i18next.t('label.please_select_a_container_size')}--</option>
666
+ ${(this.containerSizes || []).map(
667
+ containerSize =>
668
+ html`
669
+ <option
670
+ value="${containerSize && containerSize.name}"
671
+ ?selected="${containerSize.name === this._shippingOrder?.containerSize ? true : false}"
672
+ >
673
+ ${containerSize && containerSize.name}
674
+ </option>
675
+ `
676
+ )}
677
+ </select>
678
+
679
+ <label>${i18next.t('label.container_no')}</label>
680
+ <input name="containerNo" required />
681
+
682
+ <label>${i18next.t('label.container_arrival_date')}</label>
683
+ <input
684
+ name="containerArrivalDate"
685
+ type="date"
686
+ .value="${this._containerArrivalDate}"
687
+ @change="${e => {
688
+ this._containerClosureDateInput.setAttribute('min', e.currentTarget.value)
689
+ }}"
690
+ required
691
+ />
692
+
693
+ <label>${i18next.t('label.container_departure_date')}</label>
694
+ <input
695
+ name="containerLeavingDate"
696
+ type="date"
697
+ .value="${this._containerArrivalDate}"
698
+ @change="${e => {
699
+ this._containerArrivalDateInput.setAttribute('max', e.currentTarget.value)
700
+ }}"
701
+ required
702
+ />
703
+
704
+ <label>${i18next.t('label.container_closure_date')}</label>
705
+ <input
706
+ name="containerClosureDate"
707
+ type="date"
708
+ .value="${this._containerClosureDate}"
709
+ @change="${e => {
710
+ this._containerClosureDate = e.currentTarget.value
711
+ this._containerArrivalDateInput.setAttribute('max', e.currentTarget.value)
712
+ }}"
713
+ required
714
+ />
698
715
 
699
-
700
- <label>${i18next.t('label.container_closure_date')}</label>
701
- <input
702
- name="containerClosureDate"
703
- type="date"
704
- .value="${this._containerClosureDate}"
705
- @change="${e => {
706
- this._containerClosureDate = e.currentTarget.value
707
- this._containerArrivalDateInput.setAttribute('max', e.currentTarget.value)
708
- }}"
709
- required
710
- />
711
-
712
- <label>${i18next.t('label.ship_name')}</label>
713
- <input name="shipName" required/>
714
-
715
- <label>${i18next.t('label.export_remark')}</label>
716
- <input name="exportRemark" required />
716
+ <label>${i18next.t('label.ship_name')}</label>
717
+ <input name="shipName" required />
717
718
 
719
+ <label>${i18next.t('label.export_remark')}</label>
720
+ <input name="exportRemark" required />
718
721
  </form>
719
722
 
720
- <div class="container">
723
+ <div class="container" ?hidden=${!this._showVasInfo || !this._showVasSummary}>
721
724
  <div class="grist">
725
+ <!-- release product list-->
722
726
  <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.release_product_list')}</h2>
723
727
  <data-grist
724
728
  id="inventory-grist"
@@ -726,28 +730,42 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
726
730
  .config=${this.inventoryGristConfig}
727
731
  .data=${this.inventoryData}
728
732
  ></data-grist>
733
+ </div>
729
734
 
730
- <h2
731
- @click="${e => {
732
- this._vasExpanded = !this._vasExpanded
733
- }}"
734
- >
735
- <mwc-icon>list_alt</mwc-icon>${i18next.t('title.vas')}<mwc-icon
736
- >${this._vasExpanded ? 'expand_less' : 'expand_more'}</mwc-icon
737
- >
738
- </h2>
739
- <div class="vas" collapsable ?collapsed=${!this._vasExpanded}>
740
- <data-grist
741
- id="vas-grist"
742
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
743
- .config=${this.vasGristConfig}
744
- .data="${this.vasData}"
745
- ></data-grist>
746
- </div>
747
- </div>
735
+ <!-- <div class="guide-container">${this._template}</div> -->
736
+ </div>
737
+
738
+ <div class="container" ?hidden=${this._showVasInfo}>
739
+ <div class="grist">
740
+ <!-- vas -->
741
+ <h2 class="vas-title"><mwc-icon>list_alt</mwc-icon>${i18next.t('title.vas')}</h2>
742
+ <data-grist
743
+ id="vas-grist"
744
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
745
+ .config=${this.vasGristConfig}
746
+ .data="${this.vasData}"
747
+ @record-change="${this._onVasChangeHandler.bind(this)}"
748
+ ></data-grist>
749
+ <!-- disable editing of vas -->
750
+ <!-- <div class="vas-button-container">
751
+ ${this._editVasStatus.indexOf(this._status) >= 0
752
+ ? html`
753
+ <mwc-button
754
+ raised
755
+ @click="${this._updateVass.bind(this)}"
756
+ label="${i18next.t('button.update_vas')}"
757
+ }
758
+ ></mwc-button>
759
+ `
760
+ : ''}
761
+ </div> -->
748
762
  </div>
763
+ </div>
749
764
 
750
- <div class="guide-container">${this._template}</div>
765
+ <div class="container" ?hidden=${this._showVasSummary}>
766
+ <!-- <search-form id="search-form" .fields=${this._searchFields} @submit=${e =>
767
+ this.report.fetch()}></search-form> -->
768
+ <data-report .config=${this.vasSummaryConfig} .data=${this.vasData}></data-report>
751
769
  </div>
752
770
  `
753
771
  }
@@ -759,7 +777,6 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
759
777
  this._editable = false
760
778
  this._disableTransport = false
761
779
  this._shippingOrder = null
762
- this._vasExpanded = false
763
780
  this._showReleasedOrderInfo = false
764
781
  this._showShippingInfo = true
765
782
  this._attentionTo = ''
@@ -782,6 +799,8 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
782
799
  this.containerSizes = []
783
800
  this._containerClosureDate = ''
784
801
  this._showExportInfo = true
802
+ this._showVasInfo = true
803
+ this._showVasSummary = true
785
804
  }
786
805
 
787
806
  _openTrackingInformation() {
@@ -801,7 +820,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
801
820
  }
802
821
 
803
822
  get context() {
804
- this._vasExpanded = false ? this._userRoles.find(x => x.name?.toLowerCase() === 'office admin') : false
823
+ // this._vasExpanded = false ? this._userRoles.find(x => x.name?.toLowerCase() === 'office admin') : false
805
824
 
806
825
  var actions = [
807
826
  {
@@ -1124,103 +1143,171 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1124
1143
  ]
1125
1144
  }
1126
1145
 
1146
+ const enableVasEditing = false
1127
1147
  this.vasGristConfig = {
1128
- list: { fields: ['targetType', 'targetDisplay', 'packingType'] },
1148
+ list: {
1149
+ fields: [
1150
+ 'batchId',
1151
+ 'productSKU',
1152
+ 'qty',
1153
+ 'packingType',
1154
+ 'uom',
1155
+ 'uomValue',
1156
+ 'vas',
1157
+ 'vasQty',
1158
+ 'newSku',
1159
+ 'newPackingType',
1160
+ 'newUom',
1161
+ 'newUomValue',
1162
+ 'outputQty',
1163
+ 'remark'
1164
+ ]
1165
+ },
1129
1166
  pagination: { infinite: true },
1130
1167
  rows: {
1131
- appendable: false,
1132
1168
  handlers: {
1133
1169
  click: (columns, data, column, record, rowIndex) => {
1134
- if (record && record.vas && record.vas.operationGuideType === 'template') {
1135
- this._template = document.createElement(record.vas.operationGuide)
1136
- this._template.record = { ...record, operationGuide: JSON.parse(record.operationGuide) }
1137
- } else {
1138
- this._template = null
1170
+ this._selectedVasRecordIdx = rowIndex
1171
+ if (enableVasEditing && this._editVasStatus.indexOf(this._status) >= 0) {
1172
+ if (column.name === 'productSKU') {
1173
+ this._openTargetProductVasPopup(record)
1174
+ }
1175
+ if (column.name === 'newSku') {
1176
+ this._openBulkProductSelectionForVas(this._selectBy, rowIndex)
1177
+ }
1178
+ if (column.name === 'vas') {
1179
+ try {
1180
+ if (!record.qty) {
1181
+ throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.qty') }))
1182
+ } else {
1183
+ this._openSelectVasPopup(record, rowIndex)
1184
+ }
1185
+ } catch (e) {
1186
+ this._showToast(e)
1187
+ }
1188
+ }
1139
1189
  }
1140
1190
  }
1141
1191
  }
1142
1192
  },
1143
1193
  columns: [
1144
1194
  { type: 'gutter', gutterName: 'sequence' },
1195
+ {
1196
+ type: 'gutter',
1197
+ gutterName: 'button',
1198
+ icon: 'close',
1199
+ hidden: !enableVasEditing,
1200
+ handlers: {
1201
+ click: (columns, data, column, record, rowIndex) => {
1202
+ if (enableVasEditing && this._editVasStatus.indexOf(this._status) >= 0) {
1203
+ this.vasData = {
1204
+ ...this.vasData,
1205
+ records: data.records.filter((rec, idx) =>
1206
+ record?.id ? record.group !== rec.group : idx !== rowIndex
1207
+ )
1208
+ }
1209
+ }
1210
+ }
1211
+ }
1212
+ },
1145
1213
  {
1146
1214
  type: 'string',
1147
- name: 'set',
1148
- header: i18next.t('field.set'),
1215
+ name: 'batchId',
1216
+ header: i18next.t('field.batch_no'),
1149
1217
  width: 100
1150
1218
  },
1151
1219
  {
1152
1220
  type: 'string',
1153
- name: 'targetType',
1154
- header: i18next.t('field.target_type'),
1155
- width: 150
1221
+ name: 'productSKU',
1222
+ header: i18next.t('field.sku'),
1223
+ width: 200
1156
1224
  },
1157
1225
  {
1158
- type: 'string',
1159
- name: 'target',
1160
- header: i18next.t('field.target'),
1161
- record: {
1162
- renderer: (value, column, record, rowIndex, field) => {
1163
- if (record.targetType === VAS_BATCH_NO_TYPE) {
1164
- return getRenderer()(record.targetBatchId, column, record, rowIndex, field)
1165
- } else if (record.targetType === VAS_PRODUCT_TYPE) {
1166
- return getRenderer('object')(record.targetProduct, column, record, rowIndex, field)
1167
- } else if (record.targetType === VAS_BATCH_AND_PRODUCT_TYPE) {
1168
- return getRenderer()(
1169
- `${record.targetBatchId} / ${record.targetProduct.name}`,
1170
- column,
1171
- record,
1172
- rowIndex,
1173
- field
1174
- )
1175
- } else if (record.targetType === VAS_ETC_TYPE) {
1176
- return getRenderer()(record.otherTarget, column, record, rowIndex, field)
1177
- }
1178
- }
1179
- },
1180
-
1181
- width: 250
1226
+ type: 'integer',
1227
+ name: 'qty',
1228
+ header: i18next.t('field.qty'),
1229
+ record: { editable: enableVasEditing, options: { min: 0 } },
1230
+ width: 80
1182
1231
  },
1183
1232
  {
1184
1233
  type: 'string',
1185
1234
  name: 'packingType',
1186
- header: i18next.t('field.packing_type'),
1187
- width: 250
1235
+ header: i18next.t('field.packing_type_sku', { sku: 'SKU' }),
1236
+ width: 150
1188
1237
  },
1189
1238
  {
1190
- type: 'integer',
1191
- name: 'qty',
1192
- header: i18next.t('field.qty'),
1193
- width: 100
1239
+ type: 'string',
1240
+ name: 'uom',
1241
+ header: i18next.t('field.uom_sku', { sku: 'SKU' }),
1242
+ width: 80
1194
1243
  },
1195
1244
  {
1196
1245
  type: 'integer',
1197
1246
  name: 'uomValue',
1198
- header: i18next.t('field.uom_value'),
1199
- width: 100
1247
+ header: i18next.t('field.uom_value_sku', { sku: 'SKU' }),
1248
+ width: 150
1200
1249
  },
1201
1250
  {
1202
- type: 'object',
1251
+ type: 'integer',
1252
+ name: 'group',
1253
+ hidden: true
1254
+ },
1255
+ {
1256
+ type: 'string',
1257
+ name: 'orderVasItemId',
1258
+ hidden: true
1259
+ },
1260
+ {
1261
+ type: 'string',
1203
1262
  name: 'vas',
1204
1263
  header: i18next.t('field.vas'),
1264
+ record: {editable: enableVasEditing},
1205
1265
  width: 250
1206
1266
  },
1267
+ {
1268
+ type: 'integer',
1269
+ name: 'vasQty',
1270
+ header: i18next.t('field.vas_qty'),
1271
+ record: { editable: enableVasEditing, options: { min: 0 } },
1272
+ width: 80
1273
+ },
1207
1274
  {
1208
1275
  type: 'string',
1209
- name: 'status',
1210
- header: i18next.t('field.status'),
1276
+ name: 'newSku',
1277
+ header: i18next.t('field.new_sku'),
1278
+ width: 200
1279
+ },
1280
+ {
1281
+ type: 'string',
1282
+ name: 'newPackingType',
1283
+ header: i18next.t('field.packing_type_sku', { sku: 'N.SKU' }),
1211
1284
  width: 150
1212
1285
  },
1213
1286
  {
1214
1287
  type: 'string',
1215
- name: 'remark',
1216
- header: i18next.t('field.remark'),
1217
- width: 350
1288
+ name: 'newUom',
1289
+ header: i18next.t('field.uom_sku', { sku: 'N.SKU' }),
1290
+ width: 80
1291
+ },
1292
+ {
1293
+ type: 'integer',
1294
+ name: 'newUomValue',
1295
+ header: i18next.t('field.uom_value_sku', { sku: 'N.SKU' }),
1296
+ width: 80
1297
+ },
1298
+ {
1299
+ type: 'integer',
1300
+ name: 'outputQty',
1301
+ header: i18next.t('field.output_qty'),
1302
+ record: { editable: enableVasEditing, options: { min: 0 } },
1303
+ width: 80
1218
1304
  },
1219
1305
  {
1220
1306
  type: 'string',
1221
- name: 'description',
1222
- header: i18next.t('field.comment'),
1223
- width: 350
1307
+ name: 'remark',
1308
+ header: i18next.t('field.remark'),
1309
+ record: { editable: enableVasEditing },
1310
+ width: 150
1224
1311
  }
1225
1312
  ]
1226
1313
  }
@@ -1355,27 +1442,43 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1355
1442
  remark
1356
1443
  }
1357
1444
  orderVass {
1358
- vas {
1359
- name
1360
- operationGuide
1361
- operationGuideType
1445
+ id
1446
+ name
1447
+ orderVasItems {
1448
+ vas {
1449
+ id
1450
+ name
1451
+ }
1452
+ vasQty
1362
1453
  }
1363
- set
1364
- targetType
1365
1454
  targetBatchId
1366
- targetProduct {
1455
+ batchId
1456
+ product {
1367
1457
  id
1368
1458
  name
1369
1459
  description
1460
+ sku
1461
+ }
1462
+ newProduct {
1463
+ id
1464
+ name
1465
+ sku
1370
1466
  }
1467
+ newProductDetail {
1468
+ packingType
1469
+ uomValue
1470
+ uom
1471
+ }
1472
+ productDetail {
1473
+ uom
1474
+ }
1475
+ outputQty
1371
1476
  packingType
1372
1477
  qty
1373
1478
  uomValue
1374
- otherTarget
1375
1479
  description
1376
1480
  remark
1377
1481
  status
1378
- operationGuide
1379
1482
  }
1380
1483
  }
1381
1484
  }
@@ -1392,7 +1495,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1392
1495
  return {
1393
1496
  ...op,
1394
1497
  productSKU: op?.product?.sku || '',
1395
- productName:` ${op?.product?.name} (${op?.product?.description})` || '',
1498
+ productName: ` ${op?.product?.name} (${op?.product?.description})` || '',
1396
1499
  productBrand: op?.product?.brand || '',
1397
1500
  roundedUomValue: `${roundedUomValue} ${op.uom}`,
1398
1501
  releaseUomValueWithUom: op.releaseUomValue + ' ' + op.uom
@@ -1509,16 +1612,44 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1509
1612
  this.orderInventoryData = {
1510
1613
  records: orderInventories
1511
1614
  }
1615
+
1512
1616
  this.vasData = {
1513
- records: orderVass
1514
- .sort((a, b) => a.set - b.set)
1515
- .map(orderVas => {
1516
- return {
1517
- ...orderVas,
1518
- set: `Set ${orderVas.set}`
1617
+ records: orderVass.sort((a, b) => a.set - b.set).reduce((acc, orderVas, groupIdx) =>{
1618
+ const releaseQty = orderProducts.find(op => op.batchId === orderVas.batchId)?.releaseQty || 0
1619
+ acc.push({
1620
+ ...orderVas,
1621
+ productSKU: orderVas.product?.sku,
1622
+ uom: orderVas.productDetail?.uom,
1623
+ newSku: orderVas.newProduct?.sku,
1624
+ newPackingType: orderVas.newProductDetail?.packingType,
1625
+ newUomValue: orderVas.newProductDetail?.uomValue,
1626
+ newUom: orderVas.newProductDetail?.uom,
1627
+ releaseQty: releaseQty
1628
+ })
1629
+
1630
+ orderVas.orderVasItems.forEach((itm, idx)=>{
1631
+ if(idx== 0){
1632
+ acc[acc.length - 1] = {
1633
+ ...acc[acc.length - 1],
1634
+ orderVasItemId: itm.vas.id,
1635
+ group: groupIdx,
1636
+ vas: itm.vas.name,
1637
+ vasQty: itm.vasQty
1638
+ }
1639
+ }else{
1640
+ acc.push({
1641
+ orderVasItemId: itm.vas.id,
1642
+ group: groupIdx,
1643
+ vas: itm.vas.name,
1644
+ vasQty: itm.vasQty,
1645
+ })
1519
1646
  }
1520
1647
  })
1648
+
1649
+ return acc
1650
+ },[])
1521
1651
  }
1652
+
1522
1653
  }
1523
1654
  }
1524
1655
 
@@ -1764,6 +1895,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1764
1895
  this._downloadable = true
1765
1896
  this._beforeRemark = null
1766
1897
  this._attachments = []
1898
+
1767
1899
  this.inventoryData = { records: [] }
1768
1900
  this.orderInventoryData = { records: [] }
1769
1901
  this.vasData = { records: [] }
@@ -1939,6 +2071,350 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1939
2071
  )
1940
2072
  }
1941
2073
 
2074
+ _openTargetProductVasPopup(record) {
2075
+ try {
2076
+ // marked for refactor 15 Jun 2023 by @ChrisLim-git
2077
+ this.checkInventoryValidity()
2078
+ openPopup(
2079
+ html`
2080
+ <vas-target-product-popup
2081
+ .targetList="${this.inventoryGrist.dirtyData.records
2082
+ .map(record => {
2083
+ const unitUomValue = record.releaseUomValue / record.releaseQty
2084
+ let packQty = record.releaseQty
2085
+
2086
+ if (this.vasData.records?.length) {
2087
+ const existVasData = this.vasData.records.filter(vasRecord => {
2088
+ const isSamePackingType = !!(record.packingType === vasRecord.packingType)
2089
+ switch (vasRecord.targetType) {
2090
+ case VAS_BATCH_AND_PRODUCT_TYPE:
2091
+ return (
2092
+ record.batchId === vasRecord.target.batchId &&
2093
+ record.product.id === vasRecord.target.productId &&
2094
+ isSamePackingType
2095
+ )
2096
+ case VAS_BATCH_NO_TYPE:
2097
+ return record.batchId === vasRecord.target && isSamePackingType
2098
+ case VAS_PRODUCT_TYPE:
2099
+ return record.product.id === vasRecord.target && isSamePackingType
2100
+ }
2101
+ })
2102
+
2103
+ if (existVasData?.length) {
2104
+ let assignedQty = 0
2105
+
2106
+ existVasData.forEach(dt => {
2107
+ assignedQty += dt.qty
2108
+ })
2109
+
2110
+ packQty -= assignedQty
2111
+ }
2112
+ }
2113
+
2114
+ delete record.__dirty__
2115
+ delete record.__dirtyfields__
2116
+ return {
2117
+ ...record,
2118
+ packQty,
2119
+ unitUomValue,
2120
+ totalUomValue: record.releaseUomValue * packQty
2121
+ }
2122
+ })
2123
+ .filter(record => record.packQty > 0)}"
2124
+ .vasList="${this.vasData.records}"
2125
+ .record="${record}"
2126
+ @selected="${selected => {
2127
+ let group = this.vasGrist.data.records[this.vasGrist.data.records.length -1].group
2128
+
2129
+ const newRecords = selected.detail.map(d => {
2130
+ return {
2131
+ ...d,
2132
+ id: null,
2133
+ sku: d.productSKU,
2134
+ maxQty: d.releaseQty,
2135
+ uomValue: d.releaseUomValue / d.releaseQty,
2136
+ group: ++group
2137
+ }
2138
+ })
2139
+
2140
+ if (this.vasGrist.dirtyData.records.length !== this._selectedVasRecordIdx) {
2141
+ // update existing vasData records
2142
+ this.vasGrist.dirtyData.records.splice(this._selectedVasRecordIdx, 1, ...newRecords)
2143
+
2144
+ this.vasData = {
2145
+ ...this.vasData,
2146
+ records: [...this.vasGrist.dirtyData.records]
2147
+ }
2148
+ } else {
2149
+ this.vasData = {
2150
+ ...this.vasData,
2151
+ records: [...this.vasGrist.dirtyData.records, ...newRecords]
2152
+ }
2153
+ }
2154
+
2155
+ // this.vasData = { ...this.vasData, records: this.sortByNameField(this.vasData.records, 'sku') }
2156
+ // console.log(this.vasData)
2157
+ }}"
2158
+ ></vas-target-product-popupp>
2159
+ `,
2160
+ {
2161
+ backdrop: true,
2162
+ size: 'large',
2163
+ title: i18next.t('title.vas_order')
2164
+ }
2165
+ )
2166
+ } catch (e) {
2167
+ this._showToast(e)
2168
+ }
2169
+ }
2170
+
2171
+ _openBulkProductSelectionForVas(type, rowIndex) {
2172
+ openPopup(
2173
+ html`
2174
+ <select-product-popup
2175
+ .bizplaceId="${this.partnerBizplaceId}"
2176
+ @selected="${e => {
2177
+ try {
2178
+ if (!e.detail) {
2179
+ throw new Error(i18next.t('text.invalid_selection_more_than_one_product'))
2180
+ }
2181
+
2182
+ let newRecords = {
2183
+ newSku: e.detail.product.sku,
2184
+ newPackingType: e.detail.packingType,
2185
+ newUom: e.detail.uom,
2186
+ newProductId: e.detail.product.id,
2187
+ newUomValue: e.detail.uomValue,
2188
+ newProductDetailId: e.detail.productDetailId
2189
+ }
2190
+
2191
+ this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
2192
+ ...this.vasGrist.dirtyData.records[rowIndex],
2193
+ ...newRecords
2194
+ })
2195
+
2196
+ this.vasGrist.dirtyData.records.map(record => {
2197
+ record.newSku
2198
+ ? record.qty
2199
+ ? (record.newUomValue = record.qty * record.newUomValue)
2200
+ : record.newUomValue
2201
+ : (record.newUomValue = null)
2202
+ })
2203
+
2204
+ this.vasData = {
2205
+ ...this.vasData,
2206
+ records: [...this.vasGrist.dirtyData.records]
2207
+ }
2208
+ } catch (error) {
2209
+ this._showToast(error)
2210
+ }
2211
+ }}"
2212
+ ></select-product-popup>
2213
+ `,
2214
+ {
2215
+ backdrop: true,
2216
+ size: 'large',
2217
+ title: i18next.t('title.select_item')
2218
+ }
2219
+ )
2220
+ }
2221
+
2222
+ _openSelectVasPopup(record, rowIndex) {
2223
+ try {
2224
+ openPopup(
2225
+ html`
2226
+ <select-vas-popup
2227
+ @selected="${e => {
2228
+ let newRecords = e.detail
2229
+
2230
+ let currentData = this.vasData.filter(vd => vd.group == record.group)
2231
+ // for (let i = 0; i < e.detail.length; i++) {
2232
+ // newRecords.push({ ...record, vas: e.detail[i] })
2233
+ // }
2234
+ // if (newRecords.length == 1) {
2235
+ // // update existing inventory data records
2236
+ // this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
2237
+ // ...this.vasGrist.dirtyData.records[rowIndex],
2238
+ // ...newRecords[0]
2239
+ // })
2240
+ // this.vasData = {
2241
+ // ...this.vasData,
2242
+ // records: [...this.vasGrist.dirtyData.records]
2243
+ // }
2244
+ // } else {
2245
+ // // update existing inventory data records
2246
+ // this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
2247
+ // ...this.vasGrist.dirtyData.records[rowIndex],
2248
+ // ...newRecords[0]
2249
+ // })
2250
+ // this.vasData = {
2251
+ // ...this.vasData,
2252
+ // records: [...this.vasGrist.dirtyData.records]
2253
+ // }
2254
+ // // add new data
2255
+ // newRecords = newRecords.slice(1).map(nrecord => {
2256
+ // return {
2257
+ // vasGristId: record.vasGristId,
2258
+ // vasQty: nrecord.vasQty,
2259
+ // vas: nrecord.vas
2260
+ // }
2261
+ // })
2262
+ // this.vasData = {
2263
+ // ...this.vasData,
2264
+ // records: [...this.vasGrist.dirtyData.records, ...newRecords]
2265
+ // }
2266
+ // }
2267
+ // this.vasData = {
2268
+ // ...this.vasData,
2269
+ // records: this.sortByNameField(this.vasData.records, 'vasGristId')
2270
+ // }
2271
+ }}"
2272
+ ></select-vas-popup>
2273
+ `,
2274
+ {
2275
+ backdrop: true,
2276
+ size: 'large',
2277
+ title: i18next.t('title.vas')
2278
+ }
2279
+ )
2280
+ } catch (e) {
2281
+ this._showToast(e)
2282
+ }
2283
+ }
2284
+
2285
+
2286
+ get vasSummaryConfig() {
2287
+ return {
2288
+ rows: {
2289
+ selectable: false,
2290
+ groups: [
2291
+ { column: 'productSKU' },
2292
+ { column: 'batchId' },
2293
+ { column: 'releaseQty' },
2294
+ { column: 'packingType' },
2295
+ { column: 'uom' },
2296
+ { column: 'releaseUomValue' }
2297
+ ],
2298
+ totals: []
2299
+ },
2300
+ columns: [
2301
+ {
2302
+ type: 'string',
2303
+ name: 'productSKU',
2304
+ header: i18next.t('field.sku'),
2305
+ sortable: false,
2306
+ imex: { header: i18next.t('field.sku'), key: 'productSKU', width: 75, type: 'string' },
2307
+ width: 200
2308
+ },
2309
+ {
2310
+ type: 'string',
2311
+ name: 'batchId',
2312
+ header: i18next.t('field.batch_no'),
2313
+ sortable: false,
2314
+ imex: { header: i18next.t('field.batch_no'), key: 'batchId', width: 75, type: 'string' },
2315
+ width: 200
2316
+ },
2317
+ {
2318
+ type: 'integer',
2319
+ name: 'releaseQty',
2320
+ header: i18next.t('field.release_qty'),
2321
+ sortable: false,
2322
+ imex: { header: i18next.t('field.release_qty'), key: 'releaseQty', width: 75, type: 'integer' },
2323
+ width: 150
2324
+ },
2325
+ {
2326
+ type: 'string',
2327
+ name: 'packingType',
2328
+ header: i18next.t('field.packing_type'),
2329
+ sortable: false,
2330
+ imex: { header: i18next.t('field.product_type'), key: 'packingType', width: 25, type: 'string' },
2331
+ width: 150
2332
+ },
2333
+ {
2334
+ type: 'string',
2335
+ name: 'uom',
2336
+ header: i18next.t('field.uom'),
2337
+ imex: { header: i18next.t('field.uom'), key: 'uom', width: 25, type: 'string' },
2338
+ width: 150
2339
+ },
2340
+ {
2341
+ type: 'number',
2342
+ name: 'releaseUomValue',
2343
+ header: i18next.t('field.release_uom_value'),
2344
+ sortable: false,
2345
+ imex: { header: i18next.t('field.release_uom_value'), key: 'releaseUomValue', width: 25, type: 'string' },
2346
+ width: 150
2347
+ },
2348
+ {
2349
+ type: 'object',
2350
+ name: 'vas',
2351
+ header: i18next.t('field.vas'),
2352
+ sortable: false,
2353
+ imex: { header: i18next.t('field.vas'), key: 'vas', width: 25, type: 'string' },
2354
+ width: 150
2355
+ },
2356
+ {
2357
+ type: 'integer',
2358
+ name: 'vasQty',
2359
+ header: i18next.t('field.vas_qty'),
2360
+ sortable: false,
2361
+ imex: { header: i18next.t('field.vas_qty'), key: 'vasQty', width: 25, type: 'integer' },
2362
+ width: 150
2363
+ },
2364
+ {
2365
+ type: 'string',
2366
+ name: 'newSKU',
2367
+ header: i18next.t('field.new_sku'),
2368
+ sortable: false,
2369
+ imex: { header: i18next.t('field.new_sku'), key: 'newSKU', width: 25, type: 'string' },
2370
+ width: 150
2371
+ },
2372
+ {
2373
+ type: 'string',
2374
+ name: 'newPackingType',
2375
+ header: i18next.t('field.packing_type_sku', { sku: 'NEW SKU' }),
2376
+ sortable: false,
2377
+ imex: {
2378
+ header: i18next.t('field.packing_type_sku', { sku: 'NEW SKU' }),
2379
+ key: 'newPackingType',
2380
+ width: 25,
2381
+ type: 'string'
2382
+ },
2383
+ width: 150
2384
+ },
2385
+ {
2386
+ type: 'integer',
2387
+ name: 'outputQty',
2388
+ header: i18next.t('field.output_qty'),
2389
+ sortable: false,
2390
+ imex: { header: i18next.t('field.output_qty'), key: 'outputQty', width: 25, type: 'integer' },
2391
+ width: 150
2392
+ },
2393
+ {
2394
+ type: 'string',
2395
+ name: 'newUom',
2396
+ header: i18next.t('field.uom_sku', { sku: 'NEW SKU' }),
2397
+ sortable: false,
2398
+ imex: { header: i18next.t('field.uom_sku', { sku: 'NEW SKU' }), key: 'newUom', width: 25, type: 'string' },
2399
+ width: 150
2400
+ },
2401
+ {
2402
+ type: 'string',
2403
+ name: 'newUomValue',
2404
+ header: i18next.t('field.uom_value_sku', { sku: 'NEW SKU' }),
2405
+ sortable: false,
2406
+ imex: {
2407
+ header: i18next.t('field.uom_value_sku', { sku: 'NEW SKU' }),
2408
+ key: 'newUom',
2409
+ width: 25,
2410
+ type: 'string'
2411
+ },
2412
+ width: 150
2413
+ }
2414
+ ]
2415
+ }
2416
+ }
2417
+
1942
2418
  _showToast({ type, message }) {
1943
2419
  document.dispatchEvent(
1944
2420
  new CustomEvent('notify', {
@@ -1970,6 +2446,63 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1970
2446
  return []
1971
2447
  }
1972
2448
 
2449
+ _onVasChangeHandler(event) {
2450
+ // this._updateVasTargets()
2451
+ const initialRecord = event.detail.before
2452
+ const changeRecord = event.detail.after
2453
+ const changedColumn = event.detail.column.name
2454
+
2455
+ try {
2456
+ if (changedColumn === 'qty') {
2457
+ if (changeRecord.qty === undefined) throw new Error(i18next.t('text.there_is_no_selected_items'))
2458
+ // total up the qty
2459
+ if (
2460
+ this.vasData.records
2461
+ .filter(vas => vas.sku === changeRecord.sku && vas.batchId == changeRecord.batchId && vas.qty)
2462
+ .map(a => a.qty)
2463
+ .reduce((a, b) => a + b, 0) > initialRecord.maxQty
2464
+ ) {
2465
+ throw new Error(i18next.t('text.qty_exceed_release_qty'))
2466
+ }
2467
+ if (changeRecord.qty > initialRecord.maxQty) {
2468
+ throw new Error(i18next.t('text.qty_exceed_release_qty'))
2469
+ } else if (changeRecord.qty <= 0) {
2470
+ throw new Error(i18next.t('text.invalid_quantity_input'))
2471
+ } else {
2472
+ let uomValue = initialRecord.releaseUomValue / initialRecord.releaseQty
2473
+ let newUomValue = initialRecord.newUomValue
2474
+ ? initialRecord.qty
2475
+ ? initialRecord.newUomValue / initialRecord.qty
2476
+ : initialRecord.newUomValue
2477
+ : null
2478
+ changeRecord.uomValue = uomValue * changeRecord.qty
2479
+ changeRecord.newUomValue ? (changeRecord.newUomValue = changeRecord.qty * newUomValue) : null
2480
+ changeRecord.vasQty = changeRecord.qty
2481
+ changeRecord.outputQty = changeRecord.qty
2482
+ }
2483
+ } else if (changedColumn === 'outputQty' || changedColumn === 'vasQty' || changedColumn === 'newUomValue') {
2484
+ if (changeRecord.outputQty === undefined || changeRecord.vasQty === undefined)
2485
+ throw new Error(i18next.t('text.there_is_no_selected_items'))
2486
+ if (
2487
+ changeRecord.outputQty <= 0 ||
2488
+ changeRecord.vasQty <= 0 ||
2489
+ (initialRecord.newProductId && initialRecord.productId && changeRecord.newUomValue <= 0)
2490
+ ) {
2491
+ throw new Error(i18next.t('text.invalid_quantity_input'))
2492
+ }
2493
+ }
2494
+ // this._updateVasTargets()
2495
+ } catch (e) {
2496
+ const beforeValue = event.detail.before && event.detail.before[event.detail.column.name]
2497
+ if (beforeValue) {
2498
+ event.detail.after[event.detail.column.name] = beforeValue
2499
+ } else {
2500
+ delete event.detail.after[event.detail.column.name]
2501
+ }
2502
+ this._showToast(e)
2503
+ }
2504
+ }
2505
+
1973
2506
  async _updateReleaseGoodDetails() {
1974
2507
  try {
1975
2508
  this._validateTransport()
@@ -2090,6 +2623,63 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2090
2623
  }
2091
2624
  }
2092
2625
 
2626
+ _updateVass() {
2627
+ try {
2628
+ let patches = this.vasGrist.data.records
2629
+
2630
+ debugger
2631
+
2632
+ // const result = await CustomAlert({
2633
+ // title: i18next.t('title.are_you_sure'),
2634
+ // text: i18next.t('text.update_vas_order'),
2635
+ // confirmButton: { text: i18next.t('button.submit') },
2636
+ // cancelButton: { text: i18next.t('button.cancel') }
2637
+ // })
2638
+
2639
+ // if (!result.value) return
2640
+
2641
+ // if (patches.length === 0) {
2642
+ // throw new Error(i18next.t('text.nothing_changed'))
2643
+ // }
2644
+
2645
+ // patches = patches.map(patch => {
2646
+ // return {
2647
+ // id: patch.id,
2648
+ // name: patch.name,
2649
+ // product: { id: patch.product.id },
2650
+ // qty: patch.qty,
2651
+ // uomValue: patch.totalUomValue,
2652
+ // // vas: { id: patch.orderVasItems.reduce((vasList = [], ovi) => [...vasList.push(ovi.vas.id)]) }
2653
+ // vas: { id: patch.orderVasItems.map(ovi => ovi.vas.id) },
2654
+ // vasQty: patch.orderVasItems.map(ovi => ovi.vasQty),
2655
+ // newProduct: patch.newProduct?.id,
2656
+ // outputQty: patch.outputQty,
2657
+ // remark: patch.remark,
2658
+ // cuFlag: 'M'
2659
+ // }
2660
+ // })
2661
+
2662
+ // const response = await client.mutate({
2663
+ // mutation: gql`
2664
+ // mutation updateMultipleOrderVas($patches: [OrderVasPatch!]!) {
2665
+ // updateMultipleOrderVas(patches: $patches) {
2666
+ // id
2667
+ // name
2668
+ // }
2669
+ // }
2670
+ // `,
2671
+ // variables: { patches }
2672
+ // })
2673
+
2674
+ // if (!response.errors) {
2675
+ // this._showToast({ message: i18next.t('text.vas_order_updated') })
2676
+ // await this._fetchReleaseOrder()
2677
+ // }
2678
+ } catch (e) {
2679
+ this._showToast(e)
2680
+ }
2681
+ }
2682
+
2093
2683
  _openContactPointSelector() {
2094
2684
  openPopup(
2095
2685
  html`
@@ -2279,23 +2869,49 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2279
2869
  return inputDate
2280
2870
  }
2281
2871
 
2872
+ checkInventoryValidity() {
2873
+ const inventories = this.inventoryGrist?.dirtyData?.records
2874
+ if (!inventories?.length) throw new Error(i18next.t('text.there_is_no_inventory'))
2875
+
2876
+ if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PALLET && inventories.some(record => !record?.inventory?.id))
2877
+ throw new Error(i18next.t('text.invalid_inventory'))
2878
+
2879
+ if (inventories.some(record => !record.releaseQty)) throw new Error(i18next.t('text.invalid_release_qty'))
2880
+ }
2881
+
2282
2882
  _getStdDate() {
2283
2883
  let date = new Date()
2284
2884
  date.setDate(date.getDate())
2285
2885
  return date.toISOString().split('T')[0]
2286
2886
  }
2287
2887
 
2288
- async _tabChange(key) {
2888
+ _tabChange(key) {
2289
2889
  if (key == 'order') {
2290
2890
  this._showReleasedOrderInfo = false
2291
2891
  this._showShippingInfo = true
2292
2892
  this._showExportInfo = true
2893
+ this._showVasInfo = true
2894
+ this._showVasSummary = true
2293
2895
  } else if (key == 'shipment') {
2294
2896
  this._showReleasedOrderInfo = true
2295
2897
  this._showShippingInfo = false
2296
2898
  this._showExportInfo = true
2899
+ this._showVasInfo = true
2900
+ this._showVasSummary = true
2901
+ } else if (key == 'vas') {
2902
+ this._showReleasedOrderInfo = true
2903
+ this._showShippingInfo = true
2904
+ this._showExportInfo = true
2905
+ this._showVasInfo = false
2906
+ this._showVasSummary = true
2907
+ } else if (key == 'vas summary') {
2908
+ this._showReleasedOrderInfo = true
2909
+ this._showShippingInfo = true
2910
+ this._showExportInfo = true
2911
+ this._showVasInfo = true
2912
+ this._showVasSummary = false
2297
2913
  } else {
2298
- this.containerSizes = await getCodeByName('CONTAINER_SIZES')
2914
+ // this.containerSizes = await getCodeByName('CONTAINER_SIZES')
2299
2915
 
2300
2916
  this._showReleasedOrderInfo = true
2301
2917
  this._showShippingInfo = true
@@ -2337,6 +2953,22 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2337
2953
  this._selectedBillingCountry = e.target.value
2338
2954
  }
2339
2955
  }
2956
+
2957
+ sortByNameField(items, nameField, nameField2) {
2958
+ if (nameField2) {
2959
+ items?.sort((a, b) => {
2960
+ if (a[nameField] == b[nameField]) {
2961
+ return a[nameField2] > b[nameField2] ? 1 : a[nameField2] < b[nameField2] ? -1 : 0
2962
+ } else {
2963
+ return a[nameField] > b[nameField] ? 1 : a[nameField] < b[nameField] ? -1 : 0
2964
+ }
2965
+ })
2966
+ } else {
2967
+ items?.sort((a, b) => (a[nameField] > b[nameField] ? 1 : a[nameField] < b[nameField] ? -1 : 0))
2968
+ }
2969
+
2970
+ return items
2971
+ }
2340
2972
  }
2341
2973
 
2342
2974
  window.customElements.define('release-order-detail', ReleaseOrderDetail)