@things-factory/operato-wms 4.3.633 → 4.3.635

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 (30) hide show
  1. package/client/pages/inbound/inbound-worksheet.js +5 -0
  2. package/client/pages/inventory/inventory-by-product.js +11 -0
  3. package/client/pages/inventory/onhand-inventory.js +51 -32
  4. package/client/pages/order/arrival-notice/arrival-notice-list.js +26 -3
  5. package/client/pages/order/draft-release-good/draft-release-good-list.js +26 -0
  6. package/client/pages/order/release-order/b2b/b2b-order-list.js +29 -1
  7. package/client/pages/order/release-order/b2b/b2b-order-requests.js +26 -0
  8. package/client/pages/order/release-order/b2c/b2c-order-requests.js +27 -0
  9. package/client/pages/order/return-order/create-return-order.js +2 -0
  10. package/client/pages/order/return-order/return-order-inventory-popup.js +23 -1
  11. package/client/pages/outbound/loading-product.js +0 -4
  12. package/client/pages/outbound/merged-outbound-worksheet.js +7 -0
  13. package/client/pages/outbound/single-outbound-worksheet.js +27 -6
  14. package/client/pages/outbound/zone-worksheet.js +7 -0
  15. package/client/util/apply-params-to-field.js +40 -0
  16. package/client/util/index.js +1 -0
  17. package/config.development.js +46 -121
  18. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  19. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  20. package/dist-server/graphql/resolvers/reports/pg-udf-query.js +68 -0
  21. package/dist-server/graphql/resolvers/reports/pg-udf-query.js.map +1 -0
  22. package/dist-server/graphql/types/reports/index.js +4 -1
  23. package/dist-server/graphql/types/reports/index.js.map +1 -1
  24. package/dist-server/graphql/types/reports/pg-udf-query-list.js +13 -0
  25. package/dist-server/graphql/types/reports/pg-udf-query-list.js.map +1 -0
  26. package/package.json +4 -4
  27. package/server/graphql/resolvers/reports/index.ts +3 -1
  28. package/server/graphql/resolvers/reports/pg-udf-query.ts +77 -0
  29. package/server/graphql/types/reports/index.ts +4 -1
  30. package/server/graphql/types/reports/pg-udf-query-list.ts +7 -0
@@ -12,6 +12,7 @@ import { isMobileDevice } from '@things-factory/utils'
12
12
 
13
13
  import { WORKSHEET_TYPE } from '../constants'
14
14
 
15
+ import { applyParamsToFields } from '../../util'
15
16
  class InboundWorksheet extends localize(i18next)(PageView) {
16
17
  static get styles() {
17
18
  return [
@@ -76,6 +77,10 @@ class InboundWorksheet extends localize(i18next)(PageView) {
76
77
 
77
78
  pageUpdated(changes, lifecycle) {
78
79
  if (this.active) {
80
+ let { params } = lifecycle
81
+ if (params && this._searchFields) {
82
+ applyParamsToFields(this._searchFields, params, this.searchForm)
83
+ }
79
84
  this.dataGrist.fetch()
80
85
  }
81
86
  }
@@ -12,6 +12,7 @@ import { openPopup } from '@things-factory/layout-base'
12
12
  import { client, PageView } from '@things-factory/shell'
13
13
  import { ScrollbarStyles } from '@things-factory/styles'
14
14
  import { isMobileDevice } from '@things-factory/utils'
15
+ import { applyParamsToFields } from '../../util'
15
16
 
16
17
  class InventoryByProduct extends localize(i18next)(PageView) {
17
18
  static get properties() {
@@ -153,6 +154,16 @@ class InventoryByProduct extends localize(i18next)(PageView) {
153
154
  if (this._availabletockCheckbox && !this._checkedBoxes.length)
154
155
  this._checkedBoxes = [this._availabletockCheckbox, { name: 'temp', checked: false }]
155
156
 
157
+ let { params } = lifecycle
158
+ if (params && this._searchFields) {
159
+ const updatedFields = applyParamsToFields(this._searchFields, params)
160
+ this._searchFields = updatedFields
161
+ const searchForm = this.searchForm
162
+ if (searchForm) {
163
+ searchForm.fields = updatedFields
164
+ }
165
+ }
166
+
156
167
  this.dataGrist.fetch()
157
168
  }
158
169
  }
@@ -2,27 +2,15 @@ import '@things-factory/form-ui'
2
2
  import '@things-factory/grist-ui'
3
3
 
4
4
  import gql from 'graphql-tag'
5
- import {
6
- css,
7
- html
8
- } from 'lit-element'
5
+ import { css, html } from 'lit-element'
9
6
  import { connect } from 'pwa-helpers/connect-mixin'
10
7
 
11
8
  import { getCodeByName } from '@things-factory/code-base'
12
- import {
13
- i18next,
14
- localize
15
- } from '@things-factory/i18n-base'
16
- import {
17
- client,
18
- PageView,
19
- store
20
- } from '@things-factory/shell'
9
+ import { i18next, localize } from '@things-factory/i18n-base'
10
+ import { client, PageView, store } from '@things-factory/shell'
21
11
  import { ScrollbarStyles } from '@things-factory/styles'
22
- import {
23
- flattenObject,
24
- isMobileDevice
25
- } from '@things-factory/utils'
12
+ import { flattenObject, isMobileDevice } from '@things-factory/utils'
13
+ import { applyParamsToFields } from '../../util'
26
14
 
27
15
  class OnhandInventory extends connect(store)(localize(i18next)(PageView)) {
28
16
  static get styles() {
@@ -420,8 +408,47 @@ class OnhandInventory extends connect(store)(localize(i18next)(PageView)) {
420
408
  ]
421
409
  }
422
410
 
423
- async pageUpdated(changes, lifecycle) {
411
+ pageUpdated(changes, lifecycle) {
424
412
  if (this.active) {
413
+ let { params } = lifecycle
414
+ if (params && this._searchFields) {
415
+ if (params.expiration) {
416
+ this._showExpiration = params.expiration
417
+ }
418
+ if (params.expRange) {
419
+ switch (params.expRange) {
420
+ case 'expired':
421
+ params.expFromDate = new Date(new Date().setFullYear(new Date().getFullYear() - 1))
422
+ .toISOString()
423
+ .split('T')[0]
424
+ params.expToDate = new Date().toISOString().split('T')[0]
425
+ break
426
+ case '6m':
427
+ params.expFromDate = new Date().toISOString().split('T')[0]
428
+ params.expToDate = new Date(new Date().setMonth(new Date().getMonth() + 6)).toISOString().split('T')[0]
429
+ break
430
+ case '9m':
431
+ params.expFromDate = new Date().toISOString().split('T')[0]
432
+ params.expToDate = new Date(new Date().setMonth(new Date().getMonth() + 9)).toISOString().split('T')[0]
433
+ break
434
+ default:
435
+ break
436
+ }
437
+ const updatedExpFields = applyParamsToFields(this._expSearchFields, params)
438
+ this._expSearchFields = updatedExpFields
439
+ const expSearchForm = this.searchExpForm
440
+ if (expSearchForm) {
441
+ expSearchForm.fields = updatedExpFields
442
+ }
443
+ }
444
+
445
+ const updatedFields = applyParamsToFields(this._searchFields, params)
446
+ this._searchFields = updatedFields
447
+ const searchForm = this.searchForm
448
+ if (searchForm) {
449
+ searchForm.fields = updatedFields
450
+ }
451
+ }
425
452
  this.dataGrist.fetch()
426
453
  }
427
454
  }
@@ -612,13 +639,9 @@ class OnhandInventory extends connect(store)(localize(i18next)(PageView)) {
612
639
  if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
613
640
  data = this.dataGrist.selected.map(item => {
614
641
  const formatter = new Intl.DateTimeFormat(navigator.language)
615
- const expirationDate = item.expirationDate
616
- ? formatter.format(new Date(item.expirationDate))
617
- : ''
618
- const manufactureDate = item.manufactureDate
619
- ? formatter.format(new Date(item.manufactureDate))
620
- : ''
621
-
642
+ const expirationDate = item.expirationDate ? formatter.format(new Date(item.expirationDate)) : ''
643
+ const manufactureDate = item.manufactureDate ? formatter.format(new Date(item.manufactureDate)) : ''
644
+
622
645
  return {
623
646
  ...item,
624
647
  expirationDate: expirationDate,
@@ -632,13 +655,9 @@ class OnhandInventory extends connect(store)(localize(i18next)(PageView)) {
632
655
  }
633
656
  data = (await this.fetchHandler({ page: 1, limit: 9999999 })).records.map(item => {
634
657
  const formatter = new Intl.DateTimeFormat(navigator.language)
635
- const expirationDate = item.expirationDate
636
- ? formatter.format(new Date(item.expirationDate))
637
- : ''
638
- const manufactureDate = item.manufactureDate
639
- ? formatter.format(new Date(item.manufactureDate))
640
- : ''
641
-
658
+ const expirationDate = item.expirationDate ? formatter.format(new Date(item.expirationDate)) : ''
659
+ const manufactureDate = item.manufactureDate ? formatter.format(new Date(item.manufactureDate)) : ''
660
+
642
661
  return {
643
662
  ...item,
644
663
  expirationDate: expirationDate,
@@ -9,9 +9,7 @@ import { i18next, localize } from '@things-factory/i18n-base'
9
9
  import { client, navigate, PageView } from '@things-factory/shell'
10
10
  import { ScrollbarStyles } from '@things-factory/styles'
11
11
  import { isMobileDevice } from '@things-factory/utils'
12
-
13
- import { ORDER_STATUS } from '../../constants'
14
-
12
+ import { applyParamsToFields } from '../../../util'
15
13
  class ArrivalNoticeList extends localize(i18next)(PageView) {
16
14
  static get styles() {
17
15
  return [
@@ -76,6 +74,31 @@ class ArrivalNoticeList extends localize(i18next)(PageView) {
76
74
 
77
75
  pageUpdated(changes, lifecycle) {
78
76
  if (this.active) {
77
+ let { params } = lifecycle
78
+ if (params && this._searchFields) {
79
+ if (params.range) {
80
+ params.toDate = new Date().toISOString().split('T')[0]
81
+ switch (params.range) {
82
+ case '1d':
83
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split('T')[0]
84
+ break
85
+ case '1w':
86
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 7)).toISOString().split('T')[0]
87
+ break
88
+ case '1m':
89
+ params.fromDate = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().split('T')[0]
90
+ break
91
+ default:
92
+ break
93
+ }
94
+ }
95
+ const updatedFields = applyParamsToFields(this._searchFields, params)
96
+ this._searchFields = updatedFields
97
+ const searchForm = this.searchForm
98
+ if (searchForm) {
99
+ searchForm.fields = updatedFields
100
+ }
101
+ }
79
102
  this.dataGrist.fetch()
80
103
  }
81
104
  }
@@ -11,6 +11,7 @@ import { i18next, localize } from '@things-factory/i18n-base'
11
11
  import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
12
12
  import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
13
13
  import { isMobileDevice } from '@things-factory/utils'
14
+ import { applyParamsToFields } from '../../../util'
14
15
 
15
16
  import { DRAFT_RELEASE_ORDER_STATUS } from '../../../constants'
16
17
 
@@ -105,6 +106,31 @@ class DraftReleaseGoodList extends localize(i18next)(PageView) {
105
106
 
106
107
  pageUpdated(changes, lifecycle) {
107
108
  if (this.active) {
109
+ let { params } = lifecycle
110
+ if (params && this._searchFields) {
111
+ if (params.range) {
112
+ params.toDate = new Date().toISOString().split('T')[0]
113
+ switch (params.range) {
114
+ case '1d':
115
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split('T')[0]
116
+ break
117
+ case '1w':
118
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 7)).toISOString().split('T')[0]
119
+ break
120
+ case '1m':
121
+ params.fromDate = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().split('T')[0]
122
+ break
123
+ default:
124
+ break
125
+ }
126
+ }
127
+ const updatedFields = applyParamsToFields(this._searchFields, params)
128
+ this._searchFields = updatedFields
129
+ const searchForm = this.searchForm
130
+ if (searchForm) {
131
+ searchForm.fields = updatedFields
132
+ }
133
+ }
108
134
  this.dataGrist.fetch()
109
135
  }
110
136
  }
@@ -17,6 +17,8 @@ import { isMobileDevice, sleep } from '@things-factory/utils'
17
17
  import { ORDER_STATUS, ORDER_VAS_STATUS } from '../../../constants'
18
18
  import { fetchSettingRule } from '../../../../fetch-setting-value'
19
19
 
20
+ import { applyParamsToFields } from '../../../../util'
21
+
20
22
  class B2bOrderList extends localize(i18next)(PageView) {
21
23
  static get styles() {
22
24
  return [
@@ -105,6 +107,32 @@ class B2bOrderList extends localize(i18next)(PageView) {
105
107
 
106
108
  pageUpdated(changes, lifecycle) {
107
109
  if (this.active) {
110
+ let { params } = lifecycle
111
+ if (params && this._searchFields) {
112
+ if (params.range) {
113
+ params.toDate = new Date().toISOString().split('T')[0]
114
+ switch (params.range) {
115
+ case '1d':
116
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split('T')[0]
117
+ break
118
+ case '1w':
119
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 7)).toISOString().split('T')[0]
120
+ break
121
+ case '1m':
122
+ params.fromDate = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().split('T')[0]
123
+ break
124
+ default:
125
+ break
126
+ }
127
+ }
128
+ const updatedFields = applyParamsToFields(this._searchFields, params)
129
+ this._searchFields = updatedFields
130
+ const searchForm = this.searchForm
131
+ if (searchForm) {
132
+ searchForm.fields = updatedFields
133
+ }
134
+ }
135
+
108
136
  this.dataGrist.fetch()
109
137
  }
110
138
  }
@@ -659,7 +687,7 @@ class B2bOrderList extends localize(i18next)(PageView) {
659
687
  openPopup(
660
688
  html`
661
689
  <select-operator-popup
662
- .selectSorter = "${true}"
690
+ .selectSorter="${true}"
663
691
  @updateOperator="${async e => {
664
692
  let assignee = e.detail
665
693
 
@@ -13,6 +13,7 @@ import { client, navigate, PageView } from '@things-factory/shell'
13
13
  import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
14
14
  import { isMobileDevice } from '@things-factory/utils'
15
15
 
16
+ import { applyParamsToFields } from '../../../../util'
16
17
  import { ORDER_STATUS } from '../../../constants'
17
18
 
18
19
  class B2bOrderRequests extends localize(i18next)(PageView) {
@@ -91,6 +92,31 @@ class B2bOrderRequests extends localize(i18next)(PageView) {
91
92
 
92
93
  pageUpdated(changes, lifecycle) {
93
94
  if (this.active) {
95
+ let { params } = lifecycle
96
+ if (params && this._searchFields) {
97
+ if (params.range) {
98
+ params.toDate = new Date().toISOString().split('T')[0]
99
+ switch (params.range) {
100
+ case '1d':
101
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split('T')[0]
102
+ break
103
+ case '1w':
104
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 7)).toISOString().split('T')[0]
105
+ break
106
+ case '1m':
107
+ params.fromDate = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().split('T')[0]
108
+ break
109
+ default:
110
+ break
111
+ }
112
+ }
113
+ const updatedFields = applyParamsToFields(this._searchFields, params)
114
+ this._searchFields = updatedFields
115
+ const searchForm = this.searchForm
116
+ if (searchForm) {
117
+ searchForm.fields = updatedFields
118
+ }
119
+ }
94
120
  this.dataGrist.fetch()
95
121
  }
96
122
  }
@@ -20,6 +20,8 @@ import { isMobileDevice, sleep } from '@things-factory/utils'
20
20
  import { fetchSettingRule } from '../../../../fetch-setting-value'
21
21
  import { INTENALIZED_AWB_SETTING_KEY, ORDER_STATUS } from '../../../constants'
22
22
 
23
+ import { applyParamsToFields } from '../../../../util'
24
+
23
25
  const HEADER_JSON = {
24
26
  'Content-Type': 'application/json',
25
27
  Accept: 'application/json'
@@ -117,6 +119,31 @@ class B2cOrderRequests extends connect(store)(localize(i18next)(PageView)) {
117
119
 
118
120
  pageUpdated(changes, lifecycle) {
119
121
  if (this.active) {
122
+ let { params } = lifecycle
123
+ if (params && this._searchFields) {
124
+ if (params.range) {
125
+ params.toDate = new Date().toISOString().split('T')[0]
126
+ switch (params.range) {
127
+ case '1d':
128
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split('T')[0]
129
+ break
130
+ case '1w':
131
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 7)).toISOString().split('T')[0]
132
+ break
133
+ case '1m':
134
+ params.fromDate = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().split('T')[0]
135
+ break
136
+ default:
137
+ break
138
+ }
139
+ }
140
+ const updatedFields = applyParamsToFields(this._searchFields, params)
141
+ this._searchFields = updatedFields
142
+ const searchForm = this.searchForm
143
+ if (searchForm) {
144
+ searchForm.fields = updatedFields
145
+ }
146
+ }
120
147
  this.dataGrist.fetch()
121
148
  }
122
149
  }
@@ -399,6 +399,7 @@ class CreateReturnOrder extends localize(i18next)(PageView) {
399
399
  { name: 'id', hidden: true },
400
400
  { name: 'name', hidden: true },
401
401
  { name: 'productId', hidden: true },
402
+ { name: 'releaseOrderId', hidden: true },
402
403
  {
403
404
  name: 'releaseGoodName',
404
405
  header: i18next.t('field.ro')
@@ -795,6 +796,7 @@ class CreateReturnOrder extends localize(i18next)(PageView) {
795
796
  type: ORDER_TYPES.RETURN_ORDER.value,
796
797
  status: ORDER_INVENTORY_STATUS.PENDING.value
797
798
  }
799
+ newRecord.releaseOrderId = record?.releaseOrderId
798
800
  newRecord.product = { id: record?.productId, name: record?.productName }
799
801
  newRecord.productDetail = { id: record?.productDetailId }
800
802
  newRecord.inventory = { id: record.id }
@@ -114,7 +114,7 @@ class ReturnOrderInventoryPopup extends localize(i18next)(LitElement) {
114
114
  this.searchFields = [
115
115
  {
116
116
  name: 'releaseGoodName',
117
- label: i18next.t('field.ro'),
117
+ label: i18next.t('field.order_info'),
118
118
  type: 'text',
119
119
  value: this.releaseOrderNo || this.releaseGoodNameInput || null,
120
120
  props: { searchOper: 'i_like' }
@@ -136,6 +136,24 @@ class ReturnOrderInventoryPopup extends localize(i18next)(LitElement) {
136
136
  header: i18next.t('field.ro'),
137
137
  width: 150
138
138
  },
139
+ {
140
+ type: 'string',
141
+ name: 'releaseGoodRefNo',
142
+ header: i18next.t('field.ref_no'),
143
+ width: 150
144
+ },
145
+ {
146
+ type: 'string',
147
+ name: 'releaseGoodRefNo2',
148
+ header: i18next.t('field.ref_no_2'),
149
+ width: 150
150
+ },
151
+ {
152
+ type: 'string',
153
+ name: 'releaseGoodRefNo3',
154
+ header: i18next.t('field.ref_no_3'),
155
+ width: 150
156
+ },
139
157
  {
140
158
  type: 'string',
141
159
  name: 'palletId',
@@ -248,7 +266,11 @@ class ReturnOrderInventoryPopup extends localize(i18next)(LitElement) {
248
266
  palletId
249
267
  productId
250
268
  productDetailId
269
+ releaseOrderId
251
270
  releaseGoodName
271
+ releaseGoodRefNo
272
+ releaseGoodRefNo2
273
+ releaseGoodRefNo3
252
274
  }
253
275
  total
254
276
  }
@@ -692,10 +692,6 @@ class LoadingProduct extends connect(store)(localize(i18next)(PageView)) {
692
692
  this._releaseGoodNo = response.data.loadingWorksheet.worksheetInfo.releaseGood.name
693
693
  this._fillUpForm(this.infoForm, response.data.loadingWorksheet.worksheetInfo)
694
694
  this._ownCollection = response.data.loadingWorksheet.worksheetInfo.ownCollection
695
- // const hasVas = response.data.loadingWorksheet.worksheetDetailInfos.filter(wd => {
696
- // return wd.targetVas ? wd.targetVas : undefined
697
- // })
698
- // debugger
699
695
 
700
696
  this.pickedProductData = {
701
697
  records: response.data.loadingWorksheet.worksheetDetailInfos.map(record => {
@@ -17,6 +17,8 @@ import { fetchSettingRule } from '../../fetch-setting-value'
17
17
 
18
18
  import { WORKSHEET_TYPE } from '../constants'
19
19
 
20
+ import { applyParamsToFields } from '../../util'
21
+
20
22
  class MergedOutboundWorksheet extends localize(i18next)(PageView) {
21
23
  static get styles() {
22
24
  return [
@@ -103,6 +105,11 @@ class MergedOutboundWorksheet extends localize(i18next)(PageView) {
103
105
  this.assigneeId = lifecycle.params.assigneeId || null
104
106
  this.status = lifecycle.params.status || null
105
107
 
108
+ let { params } = lifecycle
109
+ if (params && this._searchFields) {
110
+ applyParamsToFields(this._searchFields, params, this.searchForm)
111
+ }
112
+
106
113
  this.dataGrist.fetch()
107
114
  }
108
115
  }
@@ -16,6 +16,8 @@ import { isMobileDevice } from '@things-factory/utils'
16
16
  import { fetchSettingRule } from '../../fetch-setting-value'
17
17
  import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
18
18
 
19
+ import { applyParamsToFields } from '../../util'
20
+
19
21
  class SingleOutboundWorksheet extends localize(i18next)(PageView) {
20
22
  static get styles() {
21
23
  return [
@@ -111,6 +113,31 @@ class SingleOutboundWorksheet extends localize(i18next)(PageView) {
111
113
  this.assigneeId = lifecycle.params.assigneeId || null
112
114
  this.status = lifecycle.params.status || null
113
115
 
116
+ let { params } = lifecycle
117
+ if (params && this._searchFields) {
118
+ if (params.range) {
119
+ params.toDate = new Date().toISOString().split('T')[0]
120
+ switch (params.range) {
121
+ case '1d':
122
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split('T')[0]
123
+ break
124
+ case '1w':
125
+ params.fromDate = new Date(new Date().setDate(new Date().getDate() - 7)).toISOString().split('T')[0]
126
+ break
127
+ case '1m':
128
+ params.fromDate = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().split('T')[0]
129
+ break
130
+ default:
131
+ break
132
+ }
133
+ }
134
+ const updatedFields = applyParamsToFields(this._searchFields, params)
135
+ this._searchFields = updatedFields
136
+ const searchForm = this.searchForm
137
+ if (searchForm) {
138
+ searchForm.fields = updatedFields
139
+ }
140
+ }
114
141
  this.dataGrist.fetch()
115
142
  }
116
143
  }
@@ -396,12 +423,6 @@ class SingleOutboundWorksheet extends localize(i18next)(PageView) {
396
423
  })
397
424
  }
398
425
 
399
- // Add extra condition if path variable has status
400
- // It's for navigate from picking UI to list up assigned tasks of user
401
- if (this.status) {
402
- filters.push({ name: 'status', operator: 'eq', value: this.status })
403
- }
404
-
405
426
  const response = await client.query({
406
427
  query: gql`
407
428
  query worksheets($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
@@ -11,6 +11,7 @@ import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
11
11
  import { ScrollbarStyles, CommonButtonStyles } from '@things-factory/styles'
12
12
  import { isMobileDevice } from '@things-factory/utils'
13
13
  import { openPopup } from '@things-factory/layout-base'
14
+ import { applyParamsToFields } from '../../util'
14
15
 
15
16
  import { WORKSHEET_TYPE } from '../constants'
16
17
 
@@ -87,6 +88,12 @@ class ZoneWorksheet extends localize(i18next)(PageView) {
87
88
  if (this.active) {
88
89
  this.assignedId = lifecycle.params.assignedId || null
89
90
  this.status = lifecycle.params.status || null
91
+
92
+ let { params } = lifecycle
93
+ if (params && this._searchFields) {
94
+ applyParamsToFields(this._searchFields, params, this.searchForm)
95
+ }
96
+
90
97
  this.dataGrist.fetch()
91
98
  }
92
99
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Applies parameter values from a params object to a list of field definitions.
3
+ *
4
+ * For each field in the fields array, if a property with the same name exists in params,
5
+ * the field's value will be set to the corresponding value from params.
6
+ *
7
+ * If a formInstance is provided, its fields property will be updated as well.
8
+ *
9
+ * @param {Array<Object>} fields - The array of field definition objects. Each object should have a 'name' property.
10
+ * @param {Object} params - The object containing parameter values, typically from URL query params.
11
+ * @returns {Array<Object>} A new array of field objects with updated 'value' properties where applicable.
12
+ */
13
+ export const applyParamsToFields = (fields, params) => {
14
+ if (!params || !fields) return fields
15
+ const updatedFields = fields.map(field => {
16
+ if (params.hasOwnProperty(field.name)) {
17
+ switch (field.type) {
18
+ case 'select':
19
+ if (field.options && typeof params[field.name] === 'string') {
20
+ const paramValue = params[field.name]
21
+ const matchedOption = field.options.find(opt =>
22
+ typeof opt.value === 'string'
23
+ ? opt.value.toLowerCase() === paramValue.toLowerCase()
24
+ : opt.value === paramValue
25
+ )
26
+ if (matchedOption) {
27
+ return { ...field, value: matchedOption.value }
28
+ }
29
+ }
30
+ break
31
+ default:
32
+ return { ...field, value: params[field.name] }
33
+ }
34
+ return field
35
+ }
36
+ return field
37
+ })
38
+
39
+ return updatedFields
40
+ }
@@ -3,3 +3,4 @@ export * from './toast'
3
3
  export * from './send-to-printer'
4
4
  export * from './qr-decoder'
5
5
  export * from './url-validator'
6
+ export * from './apply-params-to-field'
@@ -4,92 +4,57 @@ module.exports = {
4
4
  useVirtualHostBasedDomain: false,
5
5
  fallbackRoute: '/',
6
6
  subdomainOffset: 2,
7
- port: 4000,
7
+ port: 4444,
8
8
  inspect: '9330',
9
- // postgres2
10
- ormconfig: {
11
- name: 'default',
12
- type: 'postgres',
13
- database: 'postgres',
14
- username: 'postgres',
15
- password: 'hatio',
16
- host: '192.168.0.151',
17
- port: 15432,
18
- synchronize: false,
19
- logging: true
20
- },
21
- //operato
22
9
  // ormconfig: {
23
10
  // name: 'default',
24
11
  // type: 'postgres',
25
12
  // database: 'operato',
26
13
  // username: 'postgres',
27
14
  // password: 'hatio',
28
- // host: '192.168.0.151',
29
- // port: 15432,
30
- // synchronize: false,
31
- // logging: true
32
- // },
33
- //153 - operato
34
- // ormconfig: {
35
- // name: 'default',
36
- // type: 'postgres',
37
- // database: 'operato',
38
- // username: 'postgres',
39
- // password: 'hatio',
40
- // host: '192.168.0.153',
41
- // port: 15432,
42
- // synchronize: false,
43
- // logging: true
44
- // },
45
- //eric2
46
- // ormconfig: {
47
- // name: 'default',
48
- // type: 'postgres',
49
- // database: 'eric2',
50
- // username: 'postgres',
51
- // password: 'hatio',
52
15
  // host: '192.168.0.153',
53
16
  // port: 15432,
54
17
  // synchronize: false,
55
18
  // logging: true
56
19
  // },
57
- // arif's
58
- // ormconfig: {
59
- // name: 'default',
60
- // type: 'postgres',
61
- // database: 'arif',
62
- // username: 'postgres',
63
- // password: 'hatio',
64
- // host: '192.168.0.151',
65
- // port: 15432,
66
- // synchronize: false,
67
- // logging: true
68
- // },
69
- //EMS
70
20
  // ormconfig: {
71
21
  // name: 'default',
72
22
  // type: 'postgres',
73
- // database: 'EMS',
23
+ // host: 'operatov3.cluster-cijhm4n1hbst.ap-southeast-1.rds.amazonaws.com',
24
+ // port: 55432,
25
+ // database: 'postgres',
74
26
  // username: 'postgres',
75
- // password: 'hatio',
76
- // host: '192.168.0.161',
77
- // port: 15432,
27
+ // password: 'abcd1234',
78
28
  // synchronize: false,
79
- // logging: true
29
+ // logging: true,
30
+ // connectTimeoutMS: 30000,
31
+ // extra: { poolSize: 30 }
80
32
  // },
81
- //db nora
33
+ //db izzah
82
34
  // ormconfig: {
83
35
  // name: 'default',
84
36
  // type: 'postgres',
85
- // database: 'postgres',
37
+ // database: '06072023',
86
38
  // username: 'postgres',
87
39
  // password: 'hatio',
88
- // host: '192.168.0.36',
89
- // port: 15432,
40
+ // host: '192.168.0.153',
41
+ // port: 15432,f
90
42
  // synchronize: true,
91
43
  // logging: true
92
44
  // },
45
+ ormconfig: {
46
+ name: 'default',
47
+ type: 'postgres',
48
+ database: 'postgres',
49
+ username: 'postgres',
50
+ password: 'hatio',
51
+ host: '192.168.0.151',
52
+ port: 15432,
53
+ synchronize: false,
54
+ logging: true
55
+ },
56
+
57
+ // //ERIC
93
58
  // ormconfig: {
94
59
  // name: 'default',
95
60
  // type: 'postgres',
@@ -98,14 +63,15 @@ module.exports = {
98
63
  // password: 'hatio',
99
64
  // host: '192.168.0.153',
100
65
  // port: 15432,
101
- // synchronize: true,
66
+ // synchronize: false,
102
67
  // logging: true
103
68
  // },
104
- //db izzah
69
+
70
+ //eric 2
105
71
  // ormconfig: {
106
72
  // name: 'default',
107
73
  // type: 'postgres',
108
- // database: '06072023',
74
+ // database: 'eric2',
109
75
  // username: 'postgres',
110
76
  // password: 'hatio',
111
77
  // host: '192.168.0.153',
@@ -113,6 +79,7 @@ module.exports = {
113
79
  // synchronize: false,
114
80
  // logging: true
115
81
  // },
82
+
116
83
  // ormconfig: {
117
84
  // name: 'default',
118
85
  // type: 'postgres',
@@ -201,72 +168,30 @@ module.exports = {
201
168
  // privateKey: '4pmlt3Wk019u7nqU3Q_oGZE6LbUDjjf8DpmAcn9-iss'
202
169
  // }
203
170
  },
204
- fulfillmentIntegrationOperato: {
205
- host: '192.168.0.161:3000',
206
- protocol: 'http',
207
- platform: 'operato',
208
- application: 'Operato MMS',
209
- appKey: 'a9bf751e622bf146662b240d58971051',
210
- appSecret: '1c385935dc131c4b902b9bbf6a4798af',
211
- callback: 'http://192.168.0.161:5000/callback-operato'
212
- },
213
- lmdIntegrationNinjavan: {
214
- clientId: 'P8WCEwMo0FHNlPECwTLetwN3diAmt5KF',
215
- secretKey: '1D0yNZGseOjhxnwri29xmuZiiuRp131L',
216
- refreshThreshold: 43200
217
- },
218
-
219
- lmdIntegrationEms: { refreshThreshold: 43200 },
220
- marketplaceIntegrationShopee: {
221
- platform: 'shopee',
222
- isUAT: false,
223
- application: 'Operato MMS',
224
- partnerId: 846025,
225
- partnerKey: 'd34cfd85a603f196a0d74ebe08043280c1a27788bb36bdffd61e7e0bb1c90b64',
226
- v2: true
227
- },
228
- marketplaceIntegrationLazada: {
229
- platform: 'lazada',
230
- application: 'operato-mms',
231
- appKey: '120961',
232
- appSecret: 'HB3RTNEXHlVSlBr9SmWF8AjbSUT7a825',
233
- callback: 'https://maybank.operato-m.com/lazada-callback'
234
- },
235
-
236
- //testinglazada
237
- // marketplaceIntegrationLazada: {
238
- // platform: 'lazada',
239
- // application: 'powrup_bi',
240
- // appKey: '117890',
241
- // appSecret: 'tQVllnUa7irAHoNxAwXEVxoP1we1bUjE',
242
- // callback: 'https://73c5-175-141-30-142.ngrok-free.app/lazada-callback'
243
- // },
244
- reportApiUrl: 'http://localhost:8888/rest/report/show_html',
245
- // reportApiUrl: 'http://192.168.0.153:8888/rest/report/show_html'
171
+ // reportApiUrl:
172
+ // 'http://k8s-default-operator-8eeba2e246-3e3a5ee7979bcd57.elb.ap-southeast-1.amazonaws.com/rest/report/show_html',
173
+ // reportApiUrl: 'http://192.168.0.153:8888/rest/report/show_html',
174
+ // reportApiUrl: 'http://192.168.0.153:8888/rest/report/show_html',
246
175
  // reportApiUrl: 'http://10.100.109.66:8090/rest/report/show_html',
247
176
  awbFileStorage: {
248
177
  type: 's3',
249
- accessKeyId: 'AKIAUQEOPWEJPXIVER74',
250
- secretAccessKey: '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',
178
+ accessKeyId: 'AKIAUQEOPWEJKL43OMZA',
179
+ secretAccessKey: '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',
251
180
  bucketName: 'operato-awb',
252
181
  region: 'ap-southeast-1'
253
182
  },
183
+ invoiceFileStorage: {
184
+ type: 's3',
185
+ accessKeyId: 'AKIAUQEOPWEJKL43OMZA',
186
+ secretAccessKey: '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',
187
+ invoiceBucket: 'operato-invoice',
188
+ region: 'ap-southeast-1'
189
+ },
254
190
  lambda: {
255
191
  region: 'ap-southeast-1',
256
- accessKeyId: 'AKIAUQEOPWEJPXIVER74',
257
- secretAccessKey: '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'
258
- },
259
- lmdIntegrationConfig: {
260
- version: {
261
- v1: 'lmdMiddleware',
262
- v2: 'lmdMiddlewareV2'
263
- }
264
- },
265
- awsSesEmail: {
266
- accessKeyId: 'AKIAUQEOPWEJPXIVER74',
267
- secretAccessKey: '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',
268
- email: 'support@hatio.asia'
192
+ accessKeyId: 'AKIAUQEOPWEJKL43OMZA',
193
+ secretAccessKey: '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'
269
194
  },
270
195
  reportApiUrl:
271
- 'http://k8s-default-operator-2fd6178d98-66c66a0f76c09575.elb.ap-southeast-1.amazonaws.com/rest/report/show_html'
196
+ 'http://k8s-default-operator-8eeba2e246-3e3a5ee7979bcd57.elb.ap-southeast-1.amazonaws.com/rest/report/show_html'
272
197
  }
@@ -15,5 +15,6 @@ const release_inventory_report_1 = require("./release-inventory-report");
15
15
  const shortage_report_1 = require("./shortage-report");
16
16
  const tote_loading_qc_report_1 = require("./tote-loading-qc-report");
17
17
  const vas_report_1 = require("./vas-report");
18
- exports.Query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inbound_serial_number_report_1.inboundSerialNumberReport), outbound_serial_number_report_1.outboundSerialNumberReport), costing_report_1.costingReport), inbound_order_details_report_1.inboundOrderDetailsReport), outbound_order_details_report_1.outboundOrderDetailsReport), product_label_report_1.productLabelReport), release_inventory_report_1.releaseInventoryReport), shortage_report_1.shortageReport), tote_loading_qc_report_1.loadingQcReport), vas_report_1.orderVasReport), vas_report_1.vasReport), analysis_picking_packing_report_1.analysisPickingPackingReport), cycle_count_report_1.cycleCountReport), non_loaded_inventory_report_1.nonLoadedOrderInventoriesReport), manifest_report_1.manifestReport);
18
+ const pg_udf_query_1 = require("./pg-udf-query");
19
+ exports.Query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inbound_serial_number_report_1.inboundSerialNumberReport), outbound_serial_number_report_1.outboundSerialNumberReport), costing_report_1.costingReport), inbound_order_details_report_1.inboundOrderDetailsReport), outbound_order_details_report_1.outboundOrderDetailsReport), product_label_report_1.productLabelReport), release_inventory_report_1.releaseInventoryReport), shortage_report_1.shortageReport), tote_loading_qc_report_1.loadingQcReport), vas_report_1.orderVasReport), vas_report_1.vasReport), analysis_picking_packing_report_1.analysisPickingPackingReport), cycle_count_report_1.cycleCountReport), non_loaded_inventory_report_1.nonLoadedOrderInventoriesReport), manifest_report_1.manifestReport), pg_udf_query_1.pgUdfQuery);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/index.ts"],"names":[],"mappings":";;;AAAA,uFAAgF;AAChF,qDAAgD;AAChD,6DAAuD;AACvD,iFAA0E;AAC1E,iFAA0E;AAC1E,uDAAkD;AAClD,+EAA+E;AAC/E,mFAA4E;AAC5E,mFAA4E;AAC5E,iEAA2D;AAC3D,yEAAmE;AACnE,uDAAkD;AAClD,qEAA0D;AAC1D,6CAGqB;AAER,QAAA,KAAK,yNACb,wDAAyB,GACzB,0DAA0B,GAC1B,8BAAa,GACb,wDAAyB,GACzB,0DAA0B,GAC1B,yCAAkB,GAClB,iDAAsB,GACtB,gCAAc,GACd,wCAAe,GACf,2BAAc,GACd,sBAAS,GACT,8DAA4B,GAC5B,qCAAgB,GAChB,6DAA+B,GAC/B,gCAAc,EAClB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/index.ts"],"names":[],"mappings":";;;AAAA,uFAAgF;AAChF,qDAAgD;AAChD,6DAAuD;AACvD,iFAA0E;AAC1E,iFAA0E;AAC1E,uDAAkD;AAClD,+EAA+E;AAC/E,mFAA4E;AAC5E,mFAA4E;AAC5E,iEAA2D;AAC3D,yEAAmE;AACnE,uDAAkD;AAClD,qEAA0D;AAC1D,6CAGqB;AACrB,iDAA2C;AAE9B,QAAA,KAAK,uOACb,wDAAyB,GACzB,0DAA0B,GAC1B,8BAAa,GACb,wDAAyB,GACzB,0DAA0B,GAC1B,yCAAkB,GAClB,iDAAsB,GACtB,gCAAc,GACd,wCAAe,GACf,2BAAc,GACd,sBAAS,GACT,8DAA4B,GAC5B,qCAAgB,GAChB,6DAA+B,GAC/B,gCAAc,GACd,yBAAU,EACd"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pgUdfQuery = void 0;
4
+ exports.pgUdfQuery = {
5
+ async pgUdfQuery(_, params, context) {
6
+ const { domain, tx } = context.state;
7
+ let udfName = params.filters.find(param => param.name === 'udf');
8
+ try {
9
+ if (!(udfName === null || udfName === void 0 ? void 0 : udfName.value)) {
10
+ throw new Error('UDF name is required');
11
+ }
12
+ // Remove the udf filter and convert remaining filters to an object
13
+ const parameters = params.filters
14
+ .filter(f => f.name !== 'udf')
15
+ .map(filter => ({
16
+ [filter.name]: filter.value
17
+ }));
18
+ return { items: JSON.stringify(await callPostgresFunction(udfName.value, tx, parameters)) };
19
+ }
20
+ catch (error) {
21
+ throw error;
22
+ }
23
+ }
24
+ };
25
+ /**
26
+ * Calls a PostgreSQL user-defined function through TypeORM
27
+ *
28
+ * @param functionName - Name of the PostgreSQL UDF to call
29
+ * @param entityManager - EntityManager instance
30
+ * @param parameters - Array of parameters or string to pass to the function
31
+ * @returns Promise with the function result
32
+ */
33
+ async function callPostgresFunction(functionName, entityManager, parameters) {
34
+ try {
35
+ const exists = await entityManager.query(`
36
+ SELECT EXISTS (
37
+ SELECT 1 FROM pg_proc p
38
+ JOIN pg_namespace n ON p.pronamespace = n.oid
39
+ WHERE p.proname = $1
40
+ AND n.nspname = 'public'
41
+ )`, [functionName]);
42
+ if (!exists[0].exists) {
43
+ throw new Error(`PostgreSQL function '${functionName}' does not exist in the database.`);
44
+ }
45
+ let query, params;
46
+ if (typeof parameters === 'string') {
47
+ // Pass string parameter directly
48
+ query = `SELECT * FROM ${functionName}($1)`;
49
+ params = [parameters];
50
+ }
51
+ else {
52
+ // Handle array of parameters
53
+ const paramPlaceholders = parameters.map((_, index) => `$${index + 1}`).join(', ');
54
+ query = `SELECT * FROM ${functionName}(${paramPlaceholders})`;
55
+ params = parameters.map(param => Object.values(param)).flat();
56
+ }
57
+ // Execute the query with the provided parameters
58
+ const result = await entityManager.query(query, params);
59
+ // PostgreSQL functions typically return rows, so we handle both single and multiple results
60
+ return Array.isArray(result) && result.length === 1
61
+ ? result[0]
62
+ : result;
63
+ }
64
+ catch (error) {
65
+ throw new Error(`Error calling PostgreSQL function '${functionName}': ${error.message}`);
66
+ }
67
+ }
68
+ //# sourceMappingURL=pg-udf-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-udf-query.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/pg-udf-query.ts"],"names":[],"mappings":";;;AAGa,QAAA,UAAU,GAAG;IACxB,KAAK,CAAC,UAAU,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACtD,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAA0C,OAAO,CAAC,KAAK,CAAA;QAC3E,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAA;QAEhE,IAAI;YACF,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;aACxC;YAED,mEAAmE;YACnE,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO;iBAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC;iBAC7B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACd,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK;aAC5B,CAAC,CAAC,CAAC;YAEN,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,oBAAoB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,EAAE,CAAA;SAC5F;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,oBAAoB,CACjC,YAAoB,EACpB,aAA4B,EAC5B,UAA0B;IAE1B,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC;;;;;;MAMvC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAA;QAEnB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,wBAAwB,YAAY,mCAAmC,CAAC,CAAA;SACzF;QAED,IAAI,KAAa,EAAE,MAAa,CAAA;QAEhC,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;YAClC,iCAAiC;YACjC,KAAK,GAAG,iBAAiB,YAAY,MAAM,CAAA;YAC3C,MAAM,GAAG,CAAC,UAAU,CAAC,CAAA;SACtB;aAAM;YACL,6BAA6B;YAC7B,MAAM,iBAAiB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClF,KAAK,GAAG,iBAAiB,YAAY,IAAI,iBAAiB,GAAG,CAAA;YAC7D,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;SAC9D;QAED,iDAAiD;QACjD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAEvD,4FAA4F;QAC5F,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YACjD,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACX,CAAC,CAAC,MAAM,CAAA;KACX;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,sCAAsC,YAAY,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;KACzF;AACH,CAAC"}
@@ -29,6 +29,7 @@ const shortage_report_list_1 = require("./shortage-report-list");
29
29
  const shortage_report_type_1 = require("./shortage-report-type");
30
30
  const vas_report_1 = require("./vas-report");
31
31
  const vas_report_list_1 = require("./vas-report-list");
32
+ const pg_udf_query_list_1 = require("./pg-udf-query-list");
32
33
  exports.Query = `
33
34
  inboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundSerialNumberReportList @transaction
34
35
  outboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundSerialNumberReportList @transaction
@@ -45,6 +46,7 @@ exports.Query = `
45
46
  cycleCountReport(filters: [Filter], pagination: Pagination, sortings: [Sorting], name: String!): CycleCountReportList @transaction
46
47
  nonLoadedOrderInventories(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): NonLoadedOrderInventoryReportList @transaction
47
48
  manifestReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ManifestReportList @transaction
49
+ pgUdfQuery(filters: [Filter!]): PgUdfQueryList @transaction
48
50
  `;
49
51
  exports.Types = [
50
52
  inbound_serial_number_report_1.InboundSerialNumberReport,
@@ -76,6 +78,7 @@ exports.Types = [
76
78
  non_loaded_inventory_report_1.NonLoadedOrderInventoryReport,
77
79
  non_loaded_inventory_report_list_1.NonLoadedOrderInventoryReportList,
78
80
  manifest_report_type_1.ManifestReport,
79
- manifest_report_list_1.ManifestReportList
81
+ manifest_report_list_1.ManifestReportList,
82
+ pg_udf_query_list_1.PgUdfQueryList
80
83
  ];
81
84
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/index.ts"],"names":[],"mappings":";;;AAAA,uFAAgF;AAChF,iGAAyF;AACzF,qDAAgD;AAChD,+DAAyD;AACzD,6DAAuD;AACvD,uEAAgE;AAChE,iFAA0E;AAC1E,2FAAmF;AACnF,iFAA0E;AAC1E,2FAAmF;AACnF,2DAAqD;AACrD,qEAA8D;AAC9D,iEAA2D;AAC3D,iEAAuD;AACvD,+EAA6E;AAC7E,yFAAsF;AACtF,mFAA4E;AAC5E,6FAAqF;AACrF,mFAA4E;AAC5E,6FAAqF;AACrF,iEAA2D;AAC3D,2EAAoE;AACpE,yEAAmE;AACnE,mFAA4E;AAC5E,iEAA2D;AAC3D,iEAAuD;AACvD,6CAAwD;AACxD,uDAAqE;AAExD,QAAA,KAAK,GAAG;;;;;;;;;;;;;;;;CAgBpB,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,yCAAkB;IAClB,kDAAsB;IACtB,8BAAa;IACb,uCAAiB;IACjB,iDAAsB;IACtB,0DAA0B;IAC1B,qCAAc;IACd,yCAAkB;IAClB,mCAAe;IACf,4CAAmB;IACnB,2BAAc;IACd,oCAAkB;IAClB,sBAAS;IACT,+BAAa;IACb,8DAA4B;IAC5B,uEAAgC;IAChC,qCAAgB;IAChB,8CAAoB;IACpB,2DAA6B;IAC7B,oEAAiC;IACjC,qCAAc;IACd,yCAAkB;CACnB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/index.ts"],"names":[],"mappings":";;;AAAA,uFAAgF;AAChF,iGAAyF;AACzF,qDAAgD;AAChD,+DAAyD;AACzD,6DAAuD;AACvD,uEAAgE;AAChE,iFAA0E;AAC1E,2FAAmF;AACnF,iFAA0E;AAC1E,2FAAmF;AACnF,2DAAqD;AACrD,qEAA8D;AAC9D,iEAA2D;AAC3D,iEAAuD;AACvD,+EAA6E;AAC7E,yFAAsF;AACtF,mFAA4E;AAC5E,6FAAqF;AACrF,mFAA4E;AAC5E,6FAAqF;AACrF,iEAA2D;AAC3D,2EAAoE;AACpE,yEAAmE;AACnE,mFAA4E;AAC5E,iEAA2D;AAC3D,iEAAuD;AACvD,6CAAwD;AACxD,uDAAqE;AACrE,2DAAoD;AAEvC,QAAA,KAAK,GAAG;;;;;;;;;;;;;;;;;CAiBpB,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,yCAAkB;IAClB,kDAAsB;IACtB,8BAAa;IACb,uCAAiB;IACjB,iDAAsB;IACtB,0DAA0B;IAC1B,qCAAc;IACd,yCAAkB;IAClB,mCAAe;IACf,4CAAmB;IACnB,2BAAc;IACd,oCAAkB;IAClB,sBAAS;IACT,+BAAa;IACb,8DAA4B;IAC5B,uEAAgC;IAChC,qCAAgB;IAChB,8CAAoB;IACpB,2DAA6B;IAC7B,oEAAiC;IACjC,qCAAc;IACd,yCAAkB;IAClB,kCAAc;CACf,CAAA"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PgUdfQueryList = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.PgUdfQueryList = (0, graphql_tag_1.default) `
9
+ type PgUdfQueryList {
10
+ items: String
11
+ }
12
+ `;
13
+ //# sourceMappingURL=pg-udf-query-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-udf-query-list.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/pg-udf-query-list.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,cAAc,GAAG,IAAA,qBAAG,EAAA;;;;CAIhC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.633",
3
+ "version": "4.3.635",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -91,7 +91,7 @@
91
91
  "@things-factory/print-ui": "^4.3.591",
92
92
  "@things-factory/product-base": "^4.3.595",
93
93
  "@things-factory/resource-ui": "^4.3.591",
94
- "@things-factory/sales-ui": "^4.3.632",
94
+ "@things-factory/sales-ui": "^4.3.635",
95
95
  "@things-factory/scene-data-transform": "^4.3.591",
96
96
  "@things-factory/scene-excel": "^4.3.591",
97
97
  "@things-factory/scene-firebase": "^4.3.591",
@@ -108,7 +108,7 @@
108
108
  "@things-factory/transport-base": "^4.3.631",
109
109
  "@things-factory/tutorial-ui": "^4.3.591",
110
110
  "@things-factory/warehouse-base": "^4.3.626",
111
- "@things-factory/worksheet-base": "^4.3.633"
111
+ "@things-factory/worksheet-base": "^4.3.635"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@things-factory/builder": "^4.3.591",
@@ -117,5 +117,5 @@
117
117
  "cypress-localstorage-commands": "^1.6.1",
118
118
  "eslint-plugin-cypress": "^2.12.1"
119
119
  },
120
- "gitHead": "e550612b9ee56d93020d0ea39b9320c4962dd134"
120
+ "gitHead": "bf18da41305936d8a50b2884ea7a0e54b3cb0faa"
121
121
  }
@@ -15,6 +15,7 @@ import {
15
15
  orderVasReport,
16
16
  vasReport
17
17
  } from './vas-report'
18
+ import { pgUdfQuery } from './pg-udf-query'
18
19
 
19
20
  export const Query = {
20
21
  ...inboundSerialNumberReport,
@@ -31,5 +32,6 @@ export const Query = {
31
32
  ...analysisPickingPackingReport,
32
33
  ...cycleCountReport,
33
34
  ...nonLoadedOrderInventoriesReport,
34
- ...manifestReport
35
+ ...manifestReport,
36
+ ...pgUdfQuery
35
37
  }
@@ -0,0 +1,77 @@
1
+ import { EntityManager } from 'typeorm'
2
+ import { Domain, ListParam } from '@things-factory/shell'
3
+
4
+ export const pgUdfQuery = {
5
+ async pgUdfQuery(_: any, params: ListParam, context: any) {
6
+ const { domain, tx }: { domain: Domain, tx: EntityManager } = context.state
7
+ let udfName = params.filters.find(param => param.name === 'udf')
8
+
9
+ try {
10
+ if (!udfName?.value) {
11
+ throw new Error('UDF name is required')
12
+ }
13
+
14
+ // Remove the udf filter and convert remaining filters to an object
15
+ const parameters = params.filters
16
+ .filter(f => f.name !== 'udf')
17
+ .map(filter => ({
18
+ [filter.name]: filter.value
19
+ }));
20
+
21
+ return { items: JSON.stringify(await callPostgresFunction(udfName.value, tx, parameters)) }
22
+ } catch (error) {
23
+ throw error
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Calls a PostgreSQL user-defined function through TypeORM
30
+ *
31
+ * @param functionName - Name of the PostgreSQL UDF to call
32
+ * @param entityManager - EntityManager instance
33
+ * @param parameters - Array of parameters or string to pass to the function
34
+ * @returns Promise with the function result
35
+ */
36
+ async function callPostgresFunction(
37
+ functionName: string,
38
+ entityManager: EntityManager,
39
+ parameters: any[] | string
40
+ ) {
41
+ try {
42
+ const exists = await entityManager.query(`
43
+ SELECT EXISTS (
44
+ SELECT 1 FROM pg_proc p
45
+ JOIN pg_namespace n ON p.pronamespace = n.oid
46
+ WHERE p.proname = $1
47
+ AND n.nspname = 'public'
48
+ )`, [functionName])
49
+
50
+ if (!exists[0].exists) {
51
+ throw new Error(`PostgreSQL function '${functionName}' does not exist in the database.`)
52
+ }
53
+
54
+ let query: string, params: any[]
55
+
56
+ if (typeof parameters === 'string') {
57
+ // Pass string parameter directly
58
+ query = `SELECT * FROM ${functionName}($1)`
59
+ params = [parameters]
60
+ } else {
61
+ // Handle array of parameters
62
+ const paramPlaceholders = parameters.map((_, index) => `$${index + 1}`).join(', ')
63
+ query = `SELECT * FROM ${functionName}(${paramPlaceholders})`
64
+ params = parameters.map(param => Object.values(param)).flat()
65
+ }
66
+
67
+ // Execute the query with the provided parameters
68
+ const result = await entityManager.query(query, params)
69
+
70
+ // PostgreSQL functions typically return rows, so we handle both single and multiple results
71
+ return Array.isArray(result) && result.length === 1
72
+ ? result[0]
73
+ : result
74
+ } catch (error) {
75
+ throw new Error(`Error calling PostgreSQL function '${functionName}': ${error.message}`)
76
+ }
77
+ }
@@ -26,6 +26,7 @@ import { ShortageReportList } from './shortage-report-list'
26
26
  import { ShortageReport } from './shortage-report-type'
27
27
  import { OrderVasReport, VasReport } from './vas-report'
28
28
  import { OrderVasReportList, VasReportList } from './vas-report-list'
29
+ import { PgUdfQueryList } from './pg-udf-query-list'
29
30
 
30
31
  export const Query = `
31
32
  inboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundSerialNumberReportList @transaction
@@ -43,6 +44,7 @@ export const Query = `
43
44
  cycleCountReport(filters: [Filter], pagination: Pagination, sortings: [Sorting], name: String!): CycleCountReportList @transaction
44
45
  nonLoadedOrderInventories(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): NonLoadedOrderInventoryReportList @transaction
45
46
  manifestReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ManifestReportList @transaction
47
+ pgUdfQuery(filters: [Filter!]): PgUdfQueryList @transaction
46
48
  `
47
49
 
48
50
  export const Types = [
@@ -75,5 +77,6 @@ export const Types = [
75
77
  NonLoadedOrderInventoryReport,
76
78
  NonLoadedOrderInventoryReportList,
77
79
  ManifestReport,
78
- ManifestReportList
80
+ ManifestReportList,
81
+ PgUdfQueryList
79
82
  ]
@@ -0,0 +1,7 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const PgUdfQueryList = gql`
4
+ type PgUdfQueryList {
5
+ items: String
6
+ }
7
+ `