@things-factory/operato-wms 6.1.82 → 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,178 +0,0 @@
1
- import { EntityManager } from 'typeorm'
2
-
3
- import { Bizplace } from '@things-factory/biz-base'
4
- import { ListParam } from '@things-factory/shell'
5
-
6
- export const elcclInventoryHistoryReport = {
7
- async elcclInventoryHistoryReport(_: any, params: ListParam, context: ResolverContext) {
8
- try {
9
- // const convertedParams = convertListParams(params)
10
- const { tx } = context.state
11
-
12
- let bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
13
-
14
- let fromDate = params.filters.find(data => data.name === 'fromDate')
15
- let toDate = params.filters.find(data => data.name === 'toDate')
16
- let batchNo = params.filters.find(data => data.name === 'batch_no')
17
- let product = params.filters.find(data => data.name === 'product')
18
-
19
- if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
20
-
21
- const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({
22
- id: bizplaceFilter.value
23
- })
24
-
25
- let batchNoQuery = ''
26
- if (batchNo) {
27
- batchNoQuery =
28
- 'AND Lower(invh.batch_id) LIKE ANY(ARRAY[' +
29
- batchNo.value
30
- .toLowerCase()
31
- .split(',')
32
- .map(prod => {
33
- return "'%" + prod.trim().replace(/'/g, "''") + "%'"
34
- })
35
- .join(',') +
36
- '])'
37
- }
38
-
39
- let productQuery = ''
40
- if (product) {
41
- let productValue = product.value
42
- .toLowerCase()
43
- .split(',')
44
- .map(prod => {
45
- return "'%" + prod.trim().replace(/'/g, "''") + "%'"
46
- })
47
- .join(',')
48
- productQuery = `AND (
49
- Lower(prd.name) LIKE ANY(ARRAY[${productValue}])
50
- OR Lower(prd.sku) LIKE ANY(ARRAY[${productValue}])
51
- OR Lower(prd.description) LIKE ANY(ARRAY[${productValue}])
52
- )`
53
- }
54
-
55
- await tx.query(
56
- `
57
- create temp table temp_data_src AS
58
- (
59
- SELECT prd.sku AS product_sku, prd.name AS product_name, prd.description AS product_description, trim(invh.batch_id) as batch_id, invh.product_id,
60
- invh.packing_type, invh.bizplace_id, invh.domain_id,
61
- invh.ref_order_id, invh.order_no, invh.order_ref_no, invh.transaction_type, invh.created_at,
62
- invh.qty, invh.opening_qty, invh.uom_value, invh.opening_uom_value
63
- FROM reduced_inventory_histories invh
64
- INNER JOIN products prd ON prd.id = invh.product_id
65
- WHERE invh.domain_id = $1
66
- AND invh.bizplace_id = $2
67
- AND invh.created_at <= $3
68
- ${batchNoQuery}
69
- ${productQuery}
70
- )
71
- `,
72
- [context.state.domain.id, bizplace.id, toDate.value]
73
- )
74
-
75
- await tx.query(
76
- `
77
- create temp table temp_inv_history as (
78
- SELECT src.product_sku, src.product_name, src.product_description, src.batch_id, src.product_id, src.packing_type,
79
- src.bizplace_id, src.domain_id,
80
- SUM(COALESCE(invh.qty,0)) AS qty,
81
- 0 AS opening_qty,
82
- SUM(COALESCE(invh.uom_value,0)) AS uom_value,
83
- 0 AS opening_uom_value,
84
- 'Opening Balance' AS order_name,
85
- '-' AS ref_no,
86
- 0 AS rn,
87
- $1 AS created_at
88
- FROM (
89
- SELECT src.product_sku, src.product_name, src.product_description, src.batch_id, src.product_id, src.packing_type, src.bizplace_id,
90
- src.domain_id
91
- FROM temp_data_src src
92
- GROUP BY src.product_sku, src.product_name, src.product_description, src.batch_id, src.product_id, src.packing_type, src.bizplace_id,
93
- src.domain_id
94
- ) AS src
95
- LEFT JOIN inventory_histories invh ON src.batch_id = trim(invh.batch_id) AND
96
- src.product_id = invh.product_id AND
97
- src.packing_type = invh.packing_type AND
98
- src.bizplace_id = invh.bizplace_id AND
99
- src.domain_id = invh.domain_id AND
100
- invh.created_at < $1::timestamp AND
101
- invh.transaction_type IN ('NEW', 'ADJUSTMENT', 'UNLOADING', 'PICKING', 'LOADING', 'UNDO_UNLOADING', 'CANCEL_ORDER', 'RETURN')
102
- GROUP BY src.product_sku, src.product_name, src.product_description, src.batch_id, src.product_id, src.packing_type, src.bizplace_id,
103
- src.domain_id
104
- UNION ALL
105
- SELECT product_sku, product_name, product_description, batch_id, product_id, packing_type, bizplace_id,
106
- domain_id, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value, order_name, ref_no, rn, MIN(created_at) as created_at
107
- FROM (
108
- SELECT invh.product_sku, invh.product_name, invh.product_description, invh.batch_id, invh.product_id, invh.packing_type, invh.bizplace_id,
109
- invh.domain_id,
110
- invh.qty, invh.opening_qty, invh.uom_value, invh.opening_uom_value,
111
- CASE WHEN invh.transaction_type = 'ADJUSTMENT' THEN 'ADJUSTMENT'
112
- WHEN invh.transaction_type = 'NEW' THEN 'NEW'
113
- ELSE COALESCE(order_no, '-') END AS order_name,
114
- CASE WHEN invh.transaction_type = 'ADJUSTMENT' THEN 'ADJUSTMENT'
115
- WHEN invh.transaction_type = 'NEW' THEN 'NEW'
116
- ELSE COALESCE(order_ref_no, '-') END AS ref_no,
117
- 1 AS rn, invh.created_at
118
- FROM temp_data_src invh
119
- LEFT JOIN arrival_notices arrNo ON cast(arrNo.id AS VARCHAR) = invh.ref_order_id AND (invh.transaction_type = 'UNLOADING' OR
120
- invh.transaction_type = 'UNDO_UNLOADING')
121
- LEFT JOIN worksheets wks ON cast(wks.id AS VARCHAR) = invh.ref_order_id AND invh.transaction_type = 'PICKING'
122
- LEFT JOIN release_goods rel ON cast(rel.id AS VARCHAR) = cast(wks.release_good_id AS VARCHAR) AND
123
- invh.transaction_type = 'PICKING'
124
- WHERE (invh.qty <> 0 OR invh.uom_value <> 0)
125
- AND invh.created_at BETWEEN $1::timestamp AND $2::timestamp
126
- ) AS inv_movement
127
- GROUP BY product_sku, product_name, product_description, batch_id, product_id, packing_type, bizplace_id,
128
- domain_id, order_name, ref_no, rn
129
- )`,
130
- [fromDate.value, toDate.value]
131
- )
132
-
133
- const result: any = await tx.query(
134
- `
135
- select product_sku, product_name, product_description, batch_id, product_id, packing_type, bizplace_id,
136
- domain_id, qty, opening_qty, uom_value, opening_uom_value, order_name, ref_no, created_at::date
137
- from temp_inv_history invh where
138
- exists (
139
- select * from (
140
- select batch_id, product_name, packing_type, sum(qty) as totalQty, count(*) as totalRow from temp_inv_history ih2 group by batch_id, product_name, packing_type
141
- ) src where src.batch_id = invh.batch_id and src.product_name = invh.product_name and src.packing_type = invh.packing_type and (src.totalRow > 1 or src.totalQty <> 0)
142
- )
143
- ORDER BY invh.batch_id asc, invh.product_name asc, invh.product_description asc, invh.packing_type asc, invh.rn asc, invh.created_at asc
144
- `
145
- )
146
-
147
- tx.query(
148
- `
149
- drop table temp_data_src, temp_inv_history
150
- `
151
- )
152
-
153
- let items = result.map(itm => {
154
- return {
155
- batchId: itm.batch_id,
156
- packingType: itm.packing_type,
157
- product: {
158
- id: itm.product_id,
159
- sku: itm.product_sku,
160
- name: itm.product_name,
161
- description: itm.product_description
162
- },
163
- refNo: itm.ref_no,
164
- qty: itm.qty,
165
- uomValue: itm.uom_value,
166
- openingQty: itm.opening_qty,
167
- openingUomValue: itm.opening_uom_value,
168
- orderNo: itm.order_name,
169
- createdAt: itm.created_at
170
- }
171
- })
172
-
173
- return items
174
- } catch (error) {
175
- throw error
176
- }
177
- }
178
- }
@@ -1,123 +0,0 @@
1
- import { Bizplace } from '@things-factory/biz-base'
2
- import { getRepository, ListParam } from '@things-factory/shell'
3
-
4
- export const elcclInventoryHistorySummaryReport = {
5
- async elcclInventoryHistorySummaryReport(_: any, params: ListParam, context: ResolverContext) {
6
- try {
7
- const { tx } = context.state
8
-
9
- await inventoryHistorySummaryReportQuery(_, params, context)
10
-
11
- const total: any = await tx.query(`select count(*) from temp_inventory_summary`)
12
-
13
- const result: any = await tx.query(
14
- `
15
- select * from temp_inventory_summary ORDER BY initial_date OFFSET $1 LIMIT $2
16
- `,
17
- [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
18
- )
19
-
20
- let items = result.map(itm => {
21
- return {
22
- ...itm,
23
- batchId: itm.batch_id,
24
- packingType: itm.packing_type,
25
- openingQty: itm.opening_qty,
26
- adjustmentQty: itm.adjustment_qty,
27
- closingQty: itm.closing_qty,
28
- totalInQty: itm.total_in_qty,
29
- totalOutQty: itm.total_out_qty,
30
- totalReturnQty: itm.total_return_qty,
31
- initialQty: itm.initial_qty,
32
- initialDate: itm.initial_date,
33
- product: {
34
- id: itm.product_id,
35
- sku: itm.product_sku,
36
- name: itm.product_name,
37
- description: itm.product_description
38
- }
39
- }
40
- })
41
-
42
- return { items, total: total[0].count }
43
- } catch (error) {
44
- throw error
45
- }
46
- }
47
- }
48
-
49
- export async function inventoryHistorySummaryReportQuery(
50
- _: any,
51
- params: ListParam,
52
- context: ResolverContext
53
- ): Promise<void> {
54
- try {
55
- const { tx } = context.state
56
-
57
- let balanceOnlyFilter = params.filters.find(data => data.name === 'balanceOnly')
58
-
59
- let bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
60
-
61
- let fromDate = params.filters.find(data => data.name === 'fromDate')
62
- let toDate = params.filters.find(data => data.name === 'toDate')
63
-
64
- if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
65
-
66
- const bizplace: Bizplace = await getRepository(Bizplace).findOneBy({
67
- id: bizplaceFilter.value
68
- })
69
-
70
- let balanceOnlyQuery = ''
71
- if (balanceOnlyFilter && balanceOnlyFilter.value) {
72
- balanceOnlyQuery = 'and (opening_qty + adjustment_qty + total_in_qty + total_out_qty + total_return_qty) > 0 '
73
- }
74
-
75
- await tx.query(
76
- `
77
- create temp table temp_inv_history on commit drop as (
78
- select i2.pallet_id, ih.product_id::uuid, ih.packing_type, ih.batch_id,
79
- ih.id as inventory_history_id, ih.seq, ih.status, ih.transaction_type, ih.qty, ih.opening_qty, ih.created_at,
80
- ih.ref_order_id::uuid as ref_order_id
81
- from inventories i2
82
- inner join reduced_inventory_histories ih on ih.pallet_id = i2.pallet_id and ih.domain_id = i2.domain_id
83
- where
84
- i2.domain_id = $1
85
- and i2.bizplace_id = $2
86
- and ih.created_at <= $3
87
- )
88
- `,
89
- [context.state.domain.id, bizplace.id, toDate.value]
90
- )
91
-
92
- await tx.query(
93
- `
94
- create temp table temp_inventory_summary on commit drop as (
95
- select src.*,
96
- opening_qty + adjustment_qty + total_in_qty + total_out_qty + total_return_qty as closing_qty,
97
- prd.name as product_name, prd.sku as product_sku, prd.description as product_description
98
- from (
99
- select ih.batch_id, ih.packing_type,
100
- min(ih.created_at) as initial_date,
101
- sum(case when (ih.transaction_type = 'UNLOADING' or ih.transaction_type = 'NEW') and rtn.id is null then qty else 0 end) as initial_qty,
102
- sum(case when ih.created_at > $1 and ih.transaction_type = 'ADJUSTMENT' then ih.qty else 0 end) as adjustment_qty,
103
- sum(case when ih.created_at < $1 then ih.qty else 0 end) as opening_qty,
104
- sum(case when ih.created_at > $1 then case when ih.qty > 0 and ih.transaction_type <> 'ADJUSTMENT' and ih.transaction_type <> 'RETURN' and rtn.id is null then ih.qty else 0 end else 0 end) as total_in_qty,
105
- sum(case when ih.created_at > $1 then case when (ih.qty < 0 and ih.transaction_type <> 'ADJUSTMENT') or ih.transaction_type = 'RETURN' then ih.qty else 0 end else 0 end) as total_out_qty,
106
- ih.product_id,
107
- sum(case when rtn.id is not null and ih.transaction_type <> 'ADJUSTMENT' and ih.created_at > $1 then qty else 0 end) as total_return_qty
108
- from temp_inv_history ih
109
- left join return_orders rtn on rtn.id = ih.ref_order_id
110
- group by ih.batch_id, ih.product_id, ih.packing_type
111
- order by batch_id
112
- ) src
113
- inner join products prd on prd.id = src.product_id
114
- where (opening_qty > 0 or total_in_qty > 0 or adjustment_qty > 0)
115
- ${balanceOnlyQuery}
116
- )
117
- `,
118
- [fromDate.value]
119
- )
120
- } catch (error) {
121
- throw error
122
- }
123
- }
@@ -1,36 +0,0 @@
1
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
2
- import { getRepository, ListParam } from '@things-factory/shell'
3
- import { Inventory } from '@things-factory/warehouse-base'
4
-
5
- export const elcclOnhandInventoryCounterResolver = {
6
- async elcclOnhandInventoryCounter(_: any, params: ListParam, context: ResolverContext) {
7
- let bizplaces = await getPermittedBizplaceIds(context.state.domain, context.state.user)
8
- bizplaces = bizplaces
9
- .map(bizplace => {
10
- return "'" + bizplace.trim() + "'"
11
- })
12
- .join(',')
13
-
14
- const result = await getRepository(Inventory).query(`
15
- select sum(qty) as total from (
16
- select count(pallet_id) as qty from inventories i2
17
- where status not in ('INTRANSIT', 'TERMINATED', 'DELETED')
18
- and reusable_pallet_id is null
19
- and bizplace_id in (${bizplaces})
20
- and domain_id = '${context.state.domain.id}'
21
- union all
22
- select count(distinct ref_order_id) as qty from inventories i2
23
- where status not in ('INTRANSIT', 'TERMINATED', 'DELETED')
24
- and reusable_pallet_id notnull
25
- and ref_order_id notnull
26
- and bizplace_id in (${bizplaces})
27
- and domain_id = '${context.state.domain.id}'
28
- group by reusable_pallet_id
29
- ) as foo
30
- `)
31
-
32
- const total = parseInt(result[0].total)
33
-
34
- return total
35
- }
36
- }
@@ -1,15 +0,0 @@
1
- import { elcclInventoryHistorySummaryReport } from './elccl-inventory-history-summary-report'
2
- import { elcclDailyCollectionReport } from './elccl-daily-collection-report'
3
- import { elcclInventoryHistoryReport } from './elccl-inventory-history-report'
4
- import { elcclInventoryHistoryPalletDetailReport } from './elccl-inventory-history-pallet-detail-report'
5
- import { elcclOnhandInventoryCounterResolver } from './elccl-onhand-inventory-counter'
6
- import { elcclDailyOrderInventoryReport } from './elccl-daily-order-inventory-report'
7
-
8
- export const Query = {
9
- ...elcclInventoryHistorySummaryReport,
10
- ...elcclDailyCollectionReport,
11
- ...elcclInventoryHistoryReport,
12
- ...elcclInventoryHistoryPalletDetailReport,
13
- ...elcclOnhandInventoryCounterResolver,
14
- ...elcclDailyOrderInventoryReport
15
- }
@@ -1,5 +0,0 @@
1
- import { kimedaOnhandInventoryCounterResolver } from './kimeda-onhand-inventory-counter'
2
-
3
- export const Query = {
4
- ...kimedaOnhandInventoryCounterResolver
5
- }
@@ -1,42 +0,0 @@
1
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
2
- import { getRepository, ListParam } from '@things-factory/shell'
3
- import { Inventory } from '@things-factory/warehouse-base'
4
-
5
- export const kimedaOnhandInventoryCounterResolver = {
6
- async kimedaOnhandInventoryCounter(_: any, params: ListParam, context: ResolverContext) {
7
- let bizplaces = await getPermittedBizplaceIds(context.state.domain, context.state.user)
8
- bizplaces = bizplaces
9
- .map(bizplace => {
10
- return "'" + bizplace.trim() + "'"
11
- })
12
- .join(',')
13
-
14
- const result = await getRepository(Inventory).query(`
15
- select sum(qty) as total from (
16
- select l2.name, count(distinct i2.location_id) as qty, string_agg(i2.pallet_id, ', ')
17
- from inventories i2
18
- inner join locations l2 on i2.location_id = l2.id
19
- and i2.domain_id = l2.domain_id
20
- where i2.status not in ('INTRANSIT', 'TERMINATED', 'DELETED')
21
- and i2.domain_id = '${context.state.domain.id}'
22
- and i2.bizplace_id in (${bizplaces})
23
- and l2.type = 'SHELF'
24
- group by l2.name
25
- union all
26
- select l2.name, count(i2.pallet_id) as qty, string_agg(i2.pallet_id, ', ')
27
- from inventories i2
28
- inner join locations l2 on i2.location_id = l2.id
29
- and i2.domain_id = l2.domain_id
30
- where i2.status not in ('INTRANSIT', 'TERMINATED', 'DELETED')
31
- and i2.domain_id = '${context.state.domain.id}'
32
- and i2.bizplace_id in (${bizplaces})
33
- and l2.type = 'FLOOR'
34
- group by l2.name
35
- ) as foo
36
- `)
37
-
38
- const total = parseInt(result[0].total)
39
-
40
- return total
41
- }
42
- }
@@ -1,34 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm'
2
-
3
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
4
- import { ArrivalNotice } from '@things-factory/sales-base'
5
- import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
6
-
7
- export const arrivalNoticesByStatusResolver = {
8
- async arrivalNoticesByStatus(_: any, params: ListParam, context: ResolverContext) {
9
- const { domain, user } = context.state
10
- const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
11
- params.filters = params.filters.filter(filter => filter.name !== 'bizplace')
12
- const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
13
- let bizplaceIds: string
14
-
15
- if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
16
- let bizplaces: string[] =
17
- bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
18
- bizplaceIds = bizplaces
19
- .map(bizplace => {
20
- return "'" + bizplace?.trim() + "'"
21
- })
22
- .join(',')
23
- } else throw new Error('invalid bizplaceId')
24
-
25
- const qb: SelectQueryBuilder<ArrivalNotice> = getRepository(ArrivalNotice).createQueryBuilder('an')
26
- buildQuery(qb, params, context)
27
- return qb
28
- .select('an.status', 'status')
29
- .addSelect('COUNT(*) AS count')
30
- .andWhere(`an.bizplace_id IN (${bizplaceIds})`)
31
- .groupBy('an.status')
32
- .getRawMany()
33
- }
34
- }
@@ -1,24 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm'
2
-
3
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
4
- import { CollectionOrder } from '@things-factory/sales-base'
5
- import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
6
-
7
- export const collectionOrdersByStatusResolver = {
8
- async collectionOrdersByStatus(_: any, params: ListParam, context: ResolverContext) {
9
- const { domain, user } = context.state
10
-
11
- if (!params.filters.find((filter: any) => filter.name === 'bizplace')) {
12
- params.filters.push({
13
- name: 'bizplaceId',
14
- operator: 'in',
15
- value: await getPermittedBizplaceIds(domain, user),
16
- relation: false
17
- })
18
- }
19
-
20
- const qb: SelectQueryBuilder<CollectionOrder> = getRepository(CollectionOrder).createQueryBuilder('co')
21
- buildQuery(qb, params, context)
22
- return qb.select('co.status', 'status').addSelect('COUNT(*) AS count').groupBy('co.status').getRawMany()
23
- }
24
- }
@@ -1,24 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm'
2
-
3
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
4
- import { DeliveryOrder } from '@things-factory/sales-base'
5
- import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
6
-
7
- export const deliveryOrdersByStatusResolver = {
8
- async deliveryOrdersByStatus(_: any, params: ListParam, context: ResolverContext) {
9
- const { domain, user } = context.state
10
-
11
- if (!params.filters.find((filter: any) => filter.name === 'bizplace')) {
12
- params.filters.push({
13
- name: 'bizplaceId',
14
- operator: 'in',
15
- value: await getPermittedBizplaceIds(domain, user),
16
- relation: false
17
- })
18
- }
19
-
20
- const qb: SelectQueryBuilder<DeliveryOrder> = getRepository(DeliveryOrder).createQueryBuilder('do')
21
- buildQuery(qb, params, context)
22
- return qb.select('do.status', 'status').addSelect('COUNT(*) AS count').groupBy('do.status').getRawMany()
23
- }
24
- }
@@ -1,17 +0,0 @@
1
- import { arrivalNoticesByStatusResolver } from './arrival-notices-by-status'
2
- import { collectionOrdersByStatusResolver } from './collection-orders-by-status'
3
- import { deliveryOrdersByStatusResolver } from './delivery-orders-by-status'
4
- import { inventoryExpiryMonitorResolver } from './inventory-expiry-monitor'
5
- import { outboundOrderByStatusResolver } from './outbound-order-by-status'
6
- import { releaseGoodsByStatusResolver } from './release-goods-by-status'
7
- import { unitInboundedOutboundedResolver } from './unit-inbounded-outbounded'
8
-
9
- export const Query = {
10
- ...arrivalNoticesByStatusResolver,
11
- ...collectionOrdersByStatusResolver,
12
- ...deliveryOrdersByStatusResolver,
13
- ...releaseGoodsByStatusResolver,
14
- ...outboundOrderByStatusResolver,
15
- ...inventoryExpiryMonitorResolver,
16
- ...unitInboundedOutboundedResolver
17
- }
@@ -1,60 +0,0 @@
1
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
2
- import { ListParam } from '@things-factory/shell'
3
-
4
- export const inventoryExpiryMonitorResolver = {
5
- async inventoryExpiryMonitor(_: any, params: ListParam, context: ResolverContext) {
6
- const { domain, user, tx } = context.state
7
- const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
8
- const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
9
- let bizplaceIds: string
10
-
11
- if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
12
- let bizplaces: string[] =
13
- bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
14
- bizplaceIds = bizplaces
15
- .map(bizplace => {
16
- return "'" + bizplace?.trim() + "'"
17
- })
18
- .join(',')
19
- } else throw new Error('invalid bizplaceId')
20
-
21
- const expInventories: {
22
- location: string
23
- expired: number
24
- thirtyDays: number
25
- fortyFiveDays: number
26
- sixtyDays: number
27
- }[] = await tx.query(
28
- `
29
- SELECT "location", sum("expired") AS "expired", sum("sixMonths") AS "sixMonths", sum("nineMonths") AS "nineMonths" FROM (
30
- SELECT
31
- CASE WHEN l.TYPE IN ('QUARANTINE','RESERVE') THEN 'QUARANTINED' ELSE 'IN SHELF' END AS "location",
32
- CASE WHEN i.expiration_date - now()::date <= 0 THEN 1 ELSE 0 END AS "expired",
33
- CASE WHEN i.expiration_date - now()::date > 0 AND i.expiration_date - now()::date <= 180 THEN 1 ELSE 0 END AS "sixMonths",
34
- CASE WHEN i.expiration_date - now()::date > 180 AND i.expiration_date - now()::date <= 270 THEN 1 ELSE 0 END AS "nineMonths"
35
- FROM inventories i
36
- INNER JOIN locations l ON i.location_id = l.id
37
- WHERE i.expiration_date - now()::date <= 270
38
- AND i.expiration_date NOTNULL
39
- AND i.status = 'STORED'
40
- AND i.domain_id = $1
41
- AND i.bizplace_id IN (${bizplaceIds})
42
- ) AS foo
43
- GROUP BY "location"
44
- `,
45
- [domain.id]
46
- )
47
-
48
- return {
49
- quarantined: getExpiryCountByStatus(expInventories, 'QUARANTINED'),
50
- inShelf: getExpiryCountByStatus(expInventories, 'IN SHELF')
51
- }
52
- }
53
- }
54
-
55
- function getExpiryCountByStatus(expInventories, location) {
56
- let matchedInv: any = expInventories.find(inv => inv.location == location)
57
-
58
- if (matchedInv) return (({ location, ...inv }) => inv)(matchedInv)
59
- else return { expired: 0, sixMonths: 0, nineMonths: 0 }
60
- }