@things-factory/operato-wms 6.1.83 → 6.1.84

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 (94) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +39 -39
  3. package/server/graphql/index.ts +0 -7
  4. package/server/graphql/resolvers/board-setting/board-settings.ts +0 -93
  5. package/server/graphql/resolvers/board-setting/index.ts +0 -5
  6. package/server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.ts +0 -92
  7. package/server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.ts +0 -147
  8. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.ts +0 -135
  9. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +0 -178
  10. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +0 -123
  11. package/server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.ts +0 -36
  12. package/server/graphql/resolvers/custom/elccl/index.ts +0 -15
  13. package/server/graphql/resolvers/custom/kimeda/index.ts +0 -5
  14. package/server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.ts +0 -42
  15. package/server/graphql/resolvers/dashboard/arrival-notices-by-status.ts +0 -34
  16. package/server/graphql/resolvers/dashboard/collection-orders-by-status.ts +0 -24
  17. package/server/graphql/resolvers/dashboard/delivery-orders-by-status.ts +0 -24
  18. package/server/graphql/resolvers/dashboard/index.ts +0 -17
  19. package/server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts +0 -60
  20. package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +0 -126
  21. package/server/graphql/resolvers/dashboard/release-goods-by-status.ts +0 -34
  22. package/server/graphql/resolvers/dashboard/unit-inbounded-outbounded.ts +0 -61
  23. package/server/graphql/resolvers/index.ts +0 -24
  24. package/server/graphql/resolvers/inventory-comparison/index.ts +0 -5
  25. package/server/graphql/resolvers/inventory-comparison/inventory-comparison-list.ts +0 -101
  26. package/server/graphql/resolvers/opa-menu/index.ts +0 -5
  27. package/server/graphql/resolvers/opa-menu/opa-menus.ts +0 -77
  28. package/server/graphql/resolvers/other/add-release-good-products.ts +0 -413
  29. package/server/graphql/resolvers/other/index.ts +0 -10
  30. package/server/graphql/resolvers/other/page-settings.ts +0 -105
  31. package/server/graphql/resolvers/reports/costing-report.ts +0 -194
  32. package/server/graphql/resolvers/reports/inbound-order-details-report.ts +0 -216
  33. package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +0 -156
  34. package/server/graphql/resolvers/reports/index.ts +0 -18
  35. package/server/graphql/resolvers/reports/outbound-order-details-report.ts +0 -250
  36. package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +0 -159
  37. package/server/graphql/resolvers/reports/product-label-report.ts +0 -55
  38. package/server/graphql/resolvers/reports/release-inventory-report.ts +0 -201
  39. package/server/graphql/resolvers/shipping-provider/index.ts +0 -5
  40. package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +0 -18
  41. package/server/graphql/resolvers/warehouse-inventory-adjustment/index.ts +0 -5
  42. package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +0 -79
  43. package/server/graphql/types/board-setting/board-setting.ts +0 -10
  44. package/server/graphql/types/board-setting/index.ts +0 -6
  45. package/server/graphql/types/custom/elccl/elccl-daily-collection-report-list.ts +0 -8
  46. package/server/graphql/types/custom/elccl/elccl-daily-collection-report.ts +0 -24
  47. package/server/graphql/types/custom/elccl/elccl-daily-order-inventory-report-list.ts +0 -8
  48. package/server/graphql/types/custom/elccl/elccl-daily-order-inventory-report.ts +0 -19
  49. package/server/graphql/types/custom/elccl/elccl-inventory-report.ts +0 -16
  50. package/server/graphql/types/custom/elccl/elccl-inventory-summary-report-list.ts +0 -8
  51. package/server/graphql/types/custom/elccl/elccl-inventory-summary-report.ts +0 -17
  52. package/server/graphql/types/custom/elccl/elccl-pallet-detail-report.ts +0 -16
  53. package/server/graphql/types/custom/elccl/index.ts +0 -28
  54. package/server/graphql/types/custom/kimeda/index.ts +0 -3
  55. package/server/graphql/types/dashboard/index.ts +0 -14
  56. package/server/graphql/types/dashboard/inventory-expiry-counter.ts +0 -9
  57. package/server/graphql/types/dashboard/inventory-expiry-status.ts +0 -8
  58. package/server/graphql/types/dashboard/order-status-counter.ts +0 -8
  59. package/server/graphql/types/index.ts +0 -38
  60. package/server/graphql/types/inventory-comparison/index.ts +0 -11
  61. package/server/graphql/types/inventory-comparison/inventory-comparison-list.ts +0 -8
  62. package/server/graphql/types/inventory-comparison/inventory-comparison.ts +0 -12
  63. package/server/graphql/types/opa-menu/index.ts +0 -6
  64. package/server/graphql/types/opa-menu/opa-menu.ts +0 -39
  65. package/server/graphql/types/other/index.ts +0 -19
  66. package/server/graphql/types/other/page-setting.ts +0 -33
  67. package/server/graphql/types/reports/costing-report-list.ts +0 -8
  68. package/server/graphql/types/reports/costing-report.ts +0 -13
  69. package/server/graphql/types/reports/inbound-order-details-report-list.ts +0 -8
  70. package/server/graphql/types/reports/inbound-order-details-report.ts +0 -53
  71. package/server/graphql/types/reports/inbound-serial-number-report-list.ts +0 -8
  72. package/server/graphql/types/reports/inbound-serial-number-report.ts +0 -17
  73. package/server/graphql/types/reports/index.ts +0 -43
  74. package/server/graphql/types/reports/outbound-order-details-report-list.ts +0 -8
  75. package/server/graphql/types/reports/outbound-order-details-report.ts +0 -70
  76. package/server/graphql/types/reports/outbound-serial-number-report-list.ts +0 -8
  77. package/server/graphql/types/reports/outbound-serial-number-report.ts +0 -19
  78. package/server/graphql/types/reports/product-label-report-list.ts +0 -8
  79. package/server/graphql/types/reports/product-label-report.ts +0 -10
  80. package/server/graphql/types/reports/release-inventory-report-list.ts +0 -8
  81. package/server/graphql/types/reports/release-inventory-report.ts +0 -23
  82. package/server/graphql/types/shipping-provider/index.ts +0 -8
  83. package/server/graphql/types/shipping-provider/shipping-provider-list.ts +0 -7
  84. package/server/graphql/types/shipping-provider/shipping-provider.ts +0 -7
  85. package/server/graphql/types/warehouse-inventory-adjustment/index.ts +0 -5
  86. package/server/index.ts +0 -4
  87. package/server/migrations/1568858861188-SeedSetting.ts +0 -57
  88. package/server/migrations/1623308919899-SeedLocationRecommendSetting.ts +0 -35
  89. package/server/migrations/1623381200659-SeedStoringRule.ts +0 -33
  90. package/server/migrations/index.ts +0 -9
  91. package/server/opa-app-setting-constants.ts +0 -9
  92. package/server/routes.ts +0 -1
  93. package/server/utils/index.ts +0 -1
  94. package/server/utils/report-query-util.ts +0 -47
@@ -1,250 +0,0 @@
1
- import { User } from '@things-factory/auth-base'
2
- import { Bizplace } from '@things-factory/biz-base'
3
- import { Filter, ListParam } from '@things-factory/shell'
4
-
5
- import { rawProductsQuery } from '../../../utils'
6
-
7
- export const outboundOrderDetailsReport = {
8
- async outboundOrderDetailsReport(_: any, params: ListParam, context: ResolverContext) {
9
- try {
10
- const { tx } = context.state
11
- let bizplaceFilter: Filter = { name: '', operator: '', value: '' }
12
- let userFilter = params.filters.find(data => data.name === 'user')
13
- let fromDate = params.filters.find(data => data.name === 'fromDate')
14
- let toDate = params.filters.find(data => data.name === 'toDate')
15
- let roNo = params.filters.find(data => data.name === 'roNo')
16
- let doNo = params.filters.find(data => data.name === 'doNo')
17
- let status = params.filters.find(data => data.name === 'status')
18
-
19
- if (userFilter) {
20
- const user = (await tx.getRepository(User).findOne({
21
- where: { id: userFilter.value },
22
- relations: ['bizplaces']
23
- })) as User & { bizplaces: Bizplace[] }
24
-
25
- const bizplace: Bizplace = user.bizplaces[0]
26
-
27
- if (!bizplace) throw 'Invalid input'
28
-
29
- bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
30
- } else {
31
- bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
32
- }
33
-
34
- if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
35
-
36
- const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({
37
- id: bizplaceFilter.value
38
- })
39
-
40
- await rawProductsQuery(tx, params, bizplace)
41
-
42
- let extraQueryFilters = ''
43
- if (roNo) {
44
- extraQueryFilters = `${extraQueryFilters} and ro_no like '%${roNo.value}%' `
45
- }
46
- if (doNo) {
47
- extraQueryFilters = `${extraQueryFilters} and delivery_order_no like '%${doNo.value}%' `
48
- }
49
-
50
- console.time('temp')
51
- await tx.query(
52
- `
53
- create temp table temp_outbound_order_report on commit drop as (
54
- select * from (
55
- select oi.id,
56
- oi.release_qty AS "release_qty", oi.picked_at, oi.picked_by, oi.packed_at, oi.packed_by, oi.loaded_at, oi.loaded_by,
57
- oi.release_qty as "qty", oi.release_uom_value as "uom_value", oi.return_to_location_qty, oi.return_to_location_uom_value,
58
- coalesce(do2.other_driver, td.name) as driver_name,
59
- coalesce(do2.truck_no, tv.name, rg.truck_no) as vehicle_no,
60
- do2.name AS "delivery_order_no", do2.delivery_date AS "delivery_order_delivery_date", do2."to", do2.contact_point_ref_id, do2.pallet_qty,
61
- coalesce(do2.delivery_date_time, do2.delivery_date::timestamp, ms.dispatched_at, null) as "dispatched_at",
62
- rg.bizplace_id, $5 AS "bizplace_name", $6 AS "bizplace_description",
63
- coalesce( concat(do2.delivery_address_1, do2.delivery_address_2, do2.delivery_address_3, do2.delivery_address_4, do2.delivery_address_5, do2.postal_code, do2.country), concat(rg.delivery_address_1, rg.delivery_address_2, rg.delivery_address_3, rg.delivery_address_4, rg.delivery_address_5, rg.postal_code, rg.country)) as delivery_address,
64
- so.container_no, so.container_size,
65
- rg.export_option, rg.name AS "ro_no", rg."type" as "ro_type", rg.ref_no AS "ref_no_1", rg.ref_no_2 AS "ref_no_2", rg.ref_no_3 AS "ref_no_3", rg.status as "ro_status",
66
- u1.name as "order_created_by", rg.created_at AS "order_created_at",
67
- rg.accepted_at, u4.name as accepted_by, rg.checked_remark_by, rg.checked_remark_at, coalesce(do2.own_collection, rg.own_transport) AS own_transport,
68
- p.id as "product_id", p.sku as "product_sku", p.name AS "product_name", p.description AS "product_description", p.type as "product_type",
69
- i.packing_type as "pack_type", i.packing_size as "pack_size",
70
- i.uom, i.unit_cost,
71
- i.id as inventory_id, i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date,
72
- coalesce(ms.name,'') as manifest_no, coalesce(rg.manifested_at, ms.created_at) as manifested_at, coalesce(u6.name, u5.name) as manifested_by
73
- from release_goods rg
74
- left join users u1 on u1.id = rg.creator_id
75
- inner join order_inventories oi on rg.id = oi.release_good_id
76
- left join shipping_orders so on so.id = rg.shipping_order_id
77
- left join users u4 on u4.id = rg.accepted_by_id
78
- left join manifests ms on ms.id = rg.manifest_id
79
- left join users u5 on u5.id = ms.creator_id
80
- left join users u6 on u6.id = rg.manifested_by_id
81
- inner join inventories i on i.id = oi.inventory_id
82
- inner join temp_products p on p.id = oi.product_id
83
- left join delivery_orders do2 on do2.id = oi.delivery_order_id
84
- left join transport_drivers td ON td.id = do2.transport_driver_id
85
- left join transport_vehicles tv on tv.id = do2.transport_vehicle_id
86
- where rg.bizplace_id = $2 and rg.domain_id = $1
87
- and rg.created_at >= $3 and rg.created_at <= $4
88
- and oi.status <> 'REPLACED'
89
- ${status ? `and rg.status = '${status.value}' ` : ``}
90
- ) src
91
- where 1=1
92
- ${extraQueryFilters}
93
- )
94
- `,
95
- [context.state.domain.id, bizplace.id, fromDate.value, toDate.value, bizplace.name, bizplace.description]
96
- )
97
-
98
- console.timeEnd('temp')
99
- const total: any = await tx.query(`
100
- select count(*) from temp_outbound_order_report
101
- `)
102
-
103
- await tx.query(
104
- `
105
- create temp table temp_outbound_order_worksheet on commit drop as (
106
- select oi.id, w.started_at, w.ended_at, w.type from temp_outbound_order_report oi
107
- inner join worksheet_details wd on wd.target_inventory_id = oi.id
108
- inner join worksheets w on w.id = wd.worksheet_id
109
- )
110
- `
111
- )
112
-
113
- console.time('result')
114
- const result: any = await tx.query(
115
- `
116
- select *,
117
- round((qty * unit_volume)::numeric ,4) as total_volume,
118
- round((qty * unit_nett_weight)::numeric ,4) as total_unit_nett_weight,
119
- round((qty * unit_gross_weight)::numeric ,4) as total_unit_gross_weight
120
- from (
121
- select oi.*,
122
- wpick.started_at as picking_start, wpick.ended_at as picking_complete,
123
- wpack.started_at as packing_start, wpack.ended_at as packing_complete,
124
- wsort.started_at as sorting_start, wsort.ended_at as sorting_complete,
125
- wload.started_at as loading_start, wload.ended_at as loading_complete,
126
- coalesce(delivery_address, concat(cp.address, cp.address_2)) as "delivery_address",
127
- coalesce((select volume from product_details pd where pd.product_id = oi.product_id and pd.packing_type = oi.pack_type and pd.packing_size = oi.pack_size
128
- order by created_at desc
129
- fetch first 1 rows only),0) as unit_volume,
130
- coalesce((select nett_weight from product_details pd where pd.product_id = oi.product_id and pd.packing_type = oi.pack_type and pd.packing_size = oi.pack_size
131
- order by created_at desc
132
- fetch first 1 rows only),0) as unit_nett_weight,
133
- coalesce((select gross_weight from product_details pd where pd.product_id = oi.product_id and pd.packing_type = oi.pack_type and pd.packing_size = oi.pack_size
134
- order by created_at desc
135
- fetch first 1 rows only),0) as unit_gross_weight,
136
- coalesce((select weight_unit from product_details pd where pd.product_id = oi.product_id and pd.packing_type = oi.pack_type and pd.packing_size = oi.pack_size
137
- order by created_at desc
138
- fetch first 1 rows only),'') as weight_unit,
139
- coalesce((select unit_cost from reduced_inventory_histories rih where
140
- rih.ref_order_id::uuid = oi.id and
141
- rih.inventory_id::uuid = oi.inventory_id and
142
- rih.transaction_type = 'PICKING'
143
- order by created_at desc
144
- fetch first 1 rows only), oi.unit_cost, 0) as unit_cost
145
- from temp_outbound_order_report oi
146
- left join contact_points cp on cp.id = oi.contact_point_ref_id
147
- left join temp_outbound_order_worksheet wpick on wpick.id = oi.id
148
- and (wpick.type= 'PICKING' OR wpick.type = 'BATCH_PICKING')
149
- left join temp_outbound_order_worksheet wpack on wpack.id = oi.id
150
- and wpack.type= 'PACKING'
151
- left join temp_outbound_order_worksheet wsort on wsort.id = oi.id
152
- and wsort.type= 'SORTING'
153
- left join temp_outbound_order_worksheet wload on wload.id = oi.id
154
- and wload.type= 'LOADING'
155
- order by oi.ro_no, oi.product_sku
156
- offset $1 limit $2
157
- ) src
158
- `,
159
- [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
160
- )
161
-
162
- console.timeEnd('result')
163
-
164
- let items = result.map(itm => {
165
- return {
166
- bizplace: {
167
- id: itm.bizplace_id,
168
- name: itm.bizplace_name,
169
- description: itm.bizplace_description
170
- },
171
- doNo: itm.delivery_order_no,
172
- doDeliveryDate: itm.delivery_order_delivery_date,
173
- dispatchedAt: itm.dispatched_at,
174
- deliveryAddress: itm.delivery_address,
175
- manifestNo: itm.manifest_no,
176
- roNo: itm.ro_no,
177
- roType: itm.ro_type,
178
- status: itm.ro_status,
179
- refNo1: itm.ref_no_1,
180
- refNo3: itm.ref_no_3,
181
- refNo2: itm.ref_no_2,
182
- acceptedBy: itm.accepted_by,
183
- acceptedAt: itm.accepted_at,
184
- orderCreatedBy: itm.order_created_by,
185
- orderCreatedAt: itm.order_created_at,
186
- pickingStart: itm.picking_start,
187
- pickingComplete: itm.picking_complete,
188
- packingStart: itm.packing_start,
189
- packingComplete: itm.packing_complete,
190
- sortingStart: itm.sorting_start,
191
- sortingComplete: itm.sorting_complete,
192
- loadingStart: itm.loading_start,
193
- loadingComplete: itm.loading_complete,
194
- product: {
195
- id: itm.product_id,
196
- sku: itm.product_sku,
197
- name: itm.product_name,
198
- description: itm.product_description,
199
- type: itm.product_type
200
- },
201
- packType: itm.pack_type,
202
- packSize: itm.pack_size,
203
- qty: Math.abs(itm.qty),
204
- uomValue: Math.abs(itm.uom_value),
205
- uom: itm.uom,
206
- unitCost: itm.unit_cost,
207
- returnToLocationQty: itm.return_to_location_qty,
208
- returnToLocationUomValue: itm.return_to_location_uom_value,
209
- unitVolume: itm.unit_volume,
210
- totalVolume: itm.total_volume,
211
- unitNettWeight: itm.unit_nett_weight,
212
- totalUnitNettWeight: itm.total_unit_nett_weight,
213
- unitGrossWeight: itm.unit_gross_weight,
214
- totalUnitGrossWeight: itm.total_unit_gross_weight,
215
- weightUnit: itm.weight_unit,
216
- palletId: itm.pallet_id,
217
- cartonId: itm.carton_id,
218
- batchId: itm.batch_id,
219
- batchIdRef: itm.batch_id_ref,
220
- expirationDate: itm.expiration_date,
221
- manufactureDate: itm.manufacture_date,
222
- pickedAt: itm.picked_at,
223
- pickedBy: itm.picked_by,
224
- packedAt: itm.packed_at,
225
- packedBy: itm.packed_by,
226
- checkedRemarkBy: itm.checked_remark_by,
227
- checkedRemarkAt: itm.checked_remark_at,
228
- loadedAt: itm.loaded_at,
229
- loadedBy: itm.loaded_by,
230
- manifestedAt: itm.manifested_at,
231
- manifestedBy: itm.manifested_by,
232
- exportOption: itm.export_option,
233
- containerNo: itm.container_no,
234
- containerSize: itm.container_size,
235
- palletQty: itm.pallet_qty,
236
- transportOption: itm.own_transport ? 'Own Transport' : 'Warehouse Transport',
237
- vehicleNo: itm.vehicle_no,
238
- driverName: itm.driver_name
239
- }
240
- })
241
-
242
- return {
243
- items,
244
- total: total[0].count
245
- }
246
- } catch (error) {
247
- throw error
248
- }
249
- }
250
- }
@@ -1,159 +0,0 @@
1
- import { User } from '@things-factory/auth-base'
2
- import { Bizplace } from '@things-factory/biz-base'
3
- import { Filter, ListParam } from '@things-factory/shell'
4
-
5
- import { rawProductsQuery } from '../../../utils'
6
-
7
- export const outboundSerialNumberReport = {
8
- async outboundSerialNumberReport(_: any, params: ListParam, context: ResolverContext) {
9
- try {
10
- const { tx } = context.state
11
- let bizplaceFilter: Filter = { name: '', operator: '', value: '' }
12
- let userFilter = params.filters.find(data => data.name === 'user')
13
- let fromDate = params.filters.find(data => data.name === 'fromDate')
14
- let toDate = params.filters.find(data => data.name === 'toDate')
15
- let orderNo = params.filters.find(data => data.name === 'orderNo')
16
- let ref = params.filters.find(data => data.name === 'ref')
17
- let palletId = params.filters.find(data => data.name === 'palletId')
18
- let cartonId = params.filters.find(data => data.name === 'cartonId')
19
- let serialNumber = params.filters.find(data => data.name === 'serialNumber')
20
-
21
- if (userFilter) {
22
- const user = (await tx.getRepository(User).findOne({
23
- where: { id: userFilter.value },
24
- relations: ['bizplaces']
25
- })) as User & { bizplaces: Bizplace[] }
26
-
27
- const bizplace: Bizplace = user.bizplaces[0]
28
-
29
- if (!bizplace) throw 'Invalid input'
30
-
31
- bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
32
- } else {
33
- bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
34
- }
35
-
36
- if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
37
-
38
- const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({
39
- id: bizplaceFilter.value
40
- })
41
-
42
- await rawProductsQuery(tx, params, bizplace)
43
-
44
- let extraQueryFilters = ''
45
- if (orderNo) {
46
- extraQueryFilters = `${extraQueryFilters} and order_no like '%${orderNo.value}%' `
47
- }
48
- if (palletId) {
49
- extraQueryFilters = `${extraQueryFilters} and pallet_id like '%${palletId.value}%' `
50
- }
51
- if (cartonId) {
52
- extraQueryFilters = `${extraQueryFilters} and carton_id like '%${cartonId.value}%' `
53
- }
54
- if (serialNumber) {
55
- extraQueryFilters = `${extraQueryFilters} and serial_number like '%${serialNumber.value}%' `
56
- }
57
-
58
- let refNoQueryFilter = ''
59
- if (ref) {
60
- let refValue = ref.value
61
- .toLowerCase()
62
- .split(',')
63
- .map(ref => {
64
- return "'%" + ref.trim().replace(/'/g, "''") + "%'"
65
- })
66
- .join(',')
67
- refNoQueryFilter = `AND (
68
- Lower(rg.ref_no) LIKE ANY(ARRAY[${refValue}])
69
- OR Lower(rg.ref_no_2) LIKE ANY(ARRAY[${refValue}])
70
- OR Lower(rg.ref_no_3) LIKE ANY(ARRAY[${refValue}])
71
- )`
72
- }
73
-
74
- await tx.query(
75
- `
76
- create temp table temp_outbound_serial_number_report on commit drop as (
77
- select * from (
78
- select
79
- row_number() over(partition by rg."name" order by coalesce(w.started_at, ii.created_at), p.sku ) as "no",
80
- rg."name" as "order_no", concat_ws(', ',rg.delivery_address_1,rg.delivery_address_2,rg.delivery_address_3,rg.delivery_address_4,rg.delivery_address_5,rg.postal_code,rg.city,rg.state) as "full_delivery_address",
81
- rg."attention_to" as "attention_to",
82
- i.pallet_id, i.carton_id, rg.ref_no, rg.ref_no_2, rg.ref_no_3,
83
- p.id as "product_id", p.sku as "product_sku", p.brand_sku as "product_brand_sku",
84
- p.name as "product_name", p.description as "product_description", p."type" as "product_type",
85
- coalesce(pd.volume, '0') as "product_volume",
86
- ii.serial_number,
87
- coalesce(w.started_at,ii.created_at) as "etd"
88
- from inventory_items ii
89
- inner join inventories i on i.id = ii.inventory_id
90
- inner join temp_products p on p.id = i.product_id
91
- left join product_details pd on pd.product_id = p.id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
92
- inner join release_goods rg on rg.id = ii.outbound_order_id::uuid
93
- left join worksheets w on w.arrival_notice_id = rg.id and w.type = 'PICKING'
94
- where
95
- i.domain_id = $1 and i.bizplace_id = $2
96
- and coalesce(w.started_at, ii.created_at) between $3 and $4
97
- ${refNoQueryFilter}
98
- order by coalesce(w.started_at, ii.created_at), p.sku
99
- ) src
100
- where 1=1
101
- ${extraQueryFilters}
102
- )
103
- `,
104
- [context.state.domain.id, bizplace.id, fromDate.value, toDate.value]
105
- )
106
-
107
- const total: any = await tx.query(`
108
- select count(*) from temp_outbound_serial_number_report
109
- `)
110
-
111
- const result: any = await tx.query(
112
- `
113
- select *
114
- from temp_outbound_serial_number_report
115
- offset $1 limit $2
116
- `,
117
- [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
118
- )
119
-
120
- let items = result.map(itm => {
121
- let data = {
122
- no: itm.no,
123
- bizplace: {
124
- description: bizplace.description,
125
- name: bizplace.name
126
- },
127
- fullDeliveryAddress: itm.full_delivery_address,
128
- attentionTo: itm.attention_to,
129
- palletId: itm.pallet_id,
130
- cartonId: itm.carton_id,
131
- orderNo: itm.order_no,
132
- refNo1: itm.ref_no,
133
- refNo2: itm.ref_no_2,
134
- refNo3: itm.ref_no_3,
135
- product: {
136
- id: itm.product_id,
137
- sku: itm.product_sku,
138
- brandSku: itm.product_brand_sku,
139
- name: itm.product_name,
140
- description: itm.product_description,
141
- type: itm.product_type,
142
- volume: itm.product_volume
143
- },
144
- serialNumber: itm.serial_number,
145
- etd: itm.etd
146
- }
147
-
148
- return data
149
- })
150
-
151
- return {
152
- items,
153
- total: total[0].count
154
- }
155
- } catch (error) {
156
- throw error
157
- }
158
- }
159
- }
@@ -1,55 +0,0 @@
1
- import { Sequence, SEQUENCE_TYPE } from '@things-factory/id-rule-base'
2
- import { getRepository, ListParam } from '@things-factory/shell'
3
-
4
- export const productLabelReport = {
5
- async productLabelReport(_: any, params: ListParam, context: ResolverContext) {
6
- try {
7
- const { domain } = context.state
8
- // const { domain } = context.state
9
- const bizplaceId = params.filters.find(data => data.name === 'bizplace').value
10
- const type = params.filters.find(data => data.name === 'type')?.value
11
- const fromDate = params.filters.find(data => data.name === 'fromDate').value
12
- const toDate = params.filters.find(data => data.name === 'toDate').value
13
-
14
- if (!bizplaceId || !fromDate || !toDate) throw new Error('Invalid input')
15
-
16
- const items = await getRepository(Sequence).query(`
17
- SELECT "date", "type", "count", "bizplace_id" FROM (
18
- SELECT
19
- "sq"."pattern"::JSONB ->> 'type' AS "type",
20
- "sq"."pattern"::JSONB ->> 'date' AS "date",
21
- "sq"."pattern"::JSONB ->> 'bizplaceId' AS "bizplace_id",
22
- "sq"."seq" AS "count"
23
- FROM "sequences" "sq" WHERE "sq"."type" = '${SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER}'
24
- AND "sq"."domain_id" = '${domain.id}'
25
- ) AS foo
26
- WHERE "bizplace_id" = '${bizplaceId}'
27
- ${type ? `AND "type" ilike '%${type}%'` : ''}
28
- AND "date"::date BETWEEN '${fromDate}' AND '${toDate}'
29
- ORDER BY type ASC, date ASC
30
- `)
31
-
32
- // @farishelmi any usage for this function? If no please remove.
33
- /*
34
- need to transform into queryBuilder form
35
- const qb: SelectQueryBuilder<Sequence> = tx
36
- .getRepository(Sequence)
37
- .createQueryBuilder('sq')
38
- .select(`"sq"."pattern"::JSONB ->> 'type'`, 'type')
39
- .addSelect(`"sq"."pattern"::JSONB ->> 'date'`, 'date')
40
- .addSelect(`"sq"."pattern"::JSONB ->> 'bizplaceId'`, 'bizplace_id')
41
- .addSelect(`"sq"."seq"`, 'count')
42
- .where('"sq"."type" = :sequenceType', { sequenceType: SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER })
43
- .andWhere(`"sq"."pattern"::JSONB ->> 'bizplaceId' = :bizplaceId`, { bizplaceId })
44
- .andWhere(`"sq"."domain_id" = :domainId`, { domainId: domain.id })
45
- */
46
-
47
- return {
48
- items,
49
- total: 0
50
- }
51
- } catch (error) {
52
- throw error
53
- }
54
- }
55
- }
@@ -1,201 +0,0 @@
1
- import { Bizplace } from '@things-factory/biz-base'
2
- import { ListParam } from '@things-factory/shell'
3
-
4
- import { rawProductsQuery } from '../../../utils'
5
-
6
- export const releaseInventoryReport = {
7
- async releaseInventoryReport(_: any, params: ListParam, context: ResolverContext) {
8
- try {
9
- const { tx } = context.state
10
- // let bizplaceFilter = { name: '', operator: '', value: '' }
11
- // let userFilter = params.filters.find(data => data.name === 'user')
12
- let order = params.filters.find(data => data.name === 'order')
13
- let orderDate = params.filters.find(data => data.name === 'orderDate')
14
- let product = params.filters.find(data => data.name === 'product')
15
- let bizplace = params.filters.find(data => data.name === 'bizplace')
16
- let palletId = params.filters.find(data => data.name === 'palletId')
17
- let cartonId = params.filters.find(data => data.name === 'cartonId')
18
-
19
- // if (userFilter) {
20
- // const user = await tx.getRepository(User).findOne({
21
- // where: { id: userFilter.value },
22
- // relations: ['bizplaces']
23
- // }) as User & { bizplaces: Bizplace[] }
24
-
25
- // const bizplace: Bizplace = user.bizplaces[0]
26
-
27
- if (!bizplace) throw 'Invalid input'
28
-
29
- // bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
30
- // } else {
31
- // bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
32
- // }
33
-
34
- // if (!bizplaceFilter) throw 'Invalid input'
35
- let roFilter = '',
36
- ccFilter = '',
37
- queryFilter = ''
38
- if (order) {
39
- let orderValue = order.value
40
- .toLowerCase()
41
- .split(',')
42
- .map(prod => {
43
- return "'%" + prod.trim().replace(/'/g, "''") + "%'"
44
- })
45
- .join(',')
46
- roFilter += `AND (
47
- Lower(od.name) LIKE ANY(ARRAY[${orderValue}])
48
- OR Lower(od.ref_no) LIKE ANY(ARRAY[${orderValue}])
49
- OR Lower(od.ref_no_2) LIKE ANY(ARRAY[${orderValue}])
50
- OR Lower(od.ref_no_3) LIKE ANY(ARRAY[${orderValue}])
51
- )`
52
- ccFilter += `AND (
53
- Lower(od.name) LIKE ANY(ARRAY[${orderValue}])
54
- )`
55
- }
56
- if (orderDate) {
57
- queryFilter += ` AND od.created_at between '${orderDate.value}'::timestamp and '${orderDate.value}'::timestamp + INTERVAL '1 day'`
58
- }
59
-
60
- if (palletId) {
61
- queryFilter += ` AND lower(i.pallet_id) like '%${palletId.value.toLowerCase()}%'`
62
- }
63
-
64
- if (cartonId) {
65
- queryFilter += ` AND lower(i.carton_id) like '%${cartonId.value.toLowerCase()}%'`
66
- }
67
-
68
- if (bizplace) {
69
- queryFilter += ` AND od.bizplace_id = '${bizplace.value}'`
70
- }
71
-
72
- const bizplaceObj: Bizplace = await tx.getRepository(Bizplace).findOneBy({
73
- id: bizplace.value
74
- })
75
- await rawProductsQuery(tx, params, bizplaceObj)
76
-
77
- // let productQuery = ''
78
- // if (product) {
79
- // let productValue = product.value
80
- // .toLowerCase()
81
- // .split(',')
82
- // .map(prod => {
83
- // return "'%" + prod.trim().replace(/'/g, "''") + "%'"
84
- // })
85
- // .join(',')
86
- // queryFilter = `AND (
87
- // Lower(p.name) LIKE ANY(ARRAY[${productValue}])
88
- // OR Lower(p.sku) LIKE ANY(ARRAY[${productValue}])
89
- // OR Lower(p.description) LIKE ANY(ARRAY[${productValue}])
90
- // OR Lower(p.brand_sku) LIKE ANY(ARRAY[${productValue}])
91
- // OR Lower(p.brand) LIKE ANY(ARRAY[${productValue}])
92
- // )`
93
- // }
94
-
95
- await tx.query(
96
- `
97
- create temp table data_src on commit drop as (
98
- select * from (
99
- select p.sku as product_sku, p.name as product_name, p.description as product_description, p.brand as product_brand,
100
- b.id as bizplace_id, b.name as bizplace_name, b.description as bizplace_description, i.packing_type,
101
- oi.release_qty as assigned_qty, oi.release_uom_value as uom_value, i.uom,
102
- od.name as order_no, od.type::varchar as "type", od.status, od.created_at as order_at, od.release_date,
103
- i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date, l.name as location_name
104
- from (
105
- select inventory_id, release_good_id, sum(release_qty) as release_qty, sum(release_uom_value) as release_uom_value from order_inventories oi
106
- inner join release_goods od on od.id = oi.release_good_id
107
- where release_good_id is not null
108
- and od.status in ('PENDING', 'PENDING_RECEIVE', 'PENDING_CANCEL', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING')
109
- and od.domain_id = $1
110
- and oi.status != 'REPLACED'
111
- group by inventory_id, release_good_id
112
- ) oi
113
- inner join release_goods od on od.id = oi.release_good_id
114
- inner join bizplaces b on b.id = od.bizplace_id
115
- inner join inventories i on i.id = oi.inventory_id
116
- inner join locations l on l.id = i.location_id
117
- inner join temp_products p on p.id = i.product_id
118
- where 1 = 1
119
- ${roFilter}
120
- ${queryFilter}
121
- union all
122
- select p.sku as product_sku, p.name as product_name, p.description as product_description, p.brand as product_brand,
123
- b.id as bizplace_id, b.name as bizplace_name, b.description as bizplace_description, i.packing_type,
124
- oi.release_qty as assigned_qty, oi.release_uom_value as uom_value, i.uom,
125
- od.name as order_no, 'cc' as "type", od.status, od.created_at as order_at, od.execution_date,
126
- i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date, l.name as location_name
127
- from order_inventories oi
128
- inner join bizplaces b on b.id = oi.bizplace_id
129
- inner join inventory_checks od on od.id = oi.inventory_check_id
130
- inner join inventories i on i.id = oi.inventory_id
131
- inner join locations l on l.id = i.location_id
132
- inner join temp_products p on p.id = i.product_id
133
- where od.status <> 'DONE'
134
- and od.domain_id = $1
135
- ${ccFilter}
136
- ${queryFilter}
137
- ) src
138
- order by product_sku, packing_type, order_no
139
- );
140
- `,
141
- [context.state.domain.id]
142
- )
143
-
144
- const total: any = await tx.query(`
145
- select count(*) from data_src
146
- `)
147
-
148
- const result: any = await tx.query(
149
- `
150
- select * from data_src
151
- offset $1 limit $2
152
- `,
153
- [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
154
- )
155
-
156
- let items = result.map(itm => {
157
- let data = {
158
- bizplace: {
159
- id: itm.bizplace_id,
160
- name: itm.bizplace_name,
161
- description: itm.bizplace_description
162
- },
163
- product: {
164
- id: itm.product_id,
165
- sku: itm.product_sku,
166
- name: itm.product_name,
167
- description: itm.product_description,
168
- brand: itm.product_brand
169
- },
170
- location: {
171
- name: itm.location_name
172
- },
173
- packingType: itm.packing_type,
174
- assignedQty: itm.assigned_qty,
175
- assignedUomValue: itm.uom_value,
176
- assignedUom: itm.uom,
177
- orderNo: itm.order_no,
178
- type: itm.type,
179
- status: itm.status,
180
- orderAt: itm.order_at,
181
- releaseDate: itm.release_date,
182
- palletId: itm.pallet_id,
183
- cartonId: itm.carton_id,
184
- batchId: itm.batch_id,
185
- batchIdRef: itm.batch_id_ref,
186
- expirationDate: itm.expiration_date,
187
- manufactureDate: itm.manufacture_date
188
- }
189
-
190
- return data
191
- })
192
-
193
- return {
194
- items,
195
- total: total[0].count
196
- }
197
- } catch (error) {
198
- throw error
199
- }
200
- }
201
- }
@@ -1,5 +0,0 @@
1
- import { shippingProviders } from "./shipping-providers"
2
-
3
- export const Query = {
4
- ...shippingProviders
5
- }