@things-factory/operato-wms 6.1.83 → 6.1.85

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,126 +0,0 @@
1
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
2
- import { ListParam } from '@things-factory/shell'
3
-
4
- export const outboundOrderByStatusResolver = {
5
- async outboundOrderByStatus(_: 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 orderStatus: { status: string; count: number }[] = await tx.query(
22
- `
23
- WITH cte_list ("status", "count") AS (
24
- SELECT 'PICKING UNASSIGNED' AS status, 0 AS "count"
25
- UNION
26
- SELECT 'PICKING ASSIGNED' AS status, 0 AS "count"
27
- UNION
28
- SELECT 'BATCH PICKING ASSIGNED' AS status, 0 AS "count"
29
- UNION
30
- SELECT 'PACKING' AS status, 0 AS "count"
31
- UNION
32
- SELECT 'AWAITING DISPATCH' AS status, 0 AS "count"
33
- UNION
34
- SELECT 'OUT FROM WAREHOUSE' AS status, 0 AS "count"
35
- UNION
36
- SELECT 'PENDING MANIFEST CREATION' AS status, 0 AS "count"
37
- UNION
38
- SELECT 'DONE' AS status, 0 AS "count"
39
- UNION
40
- SELECT 'PENDING CANCEL' AS status, 0 AS "count"
41
- UNION
42
- SELECT 'CANCELLED' AS status, 0 AS "count"
43
- UNION
44
- SELECT 'OTHERS' AS status, 0 AS "count"
45
- UNION
46
- SELECT 'DRAFT' AS status, 0 AS "count"
47
- ) SELECT l."status", coalesce(src."count", l."count") AS "count"
48
- FROM cte_list l
49
- LEFT JOIN (
50
- SELECT "status", SUM("count") AS count FROM (
51
- SELECT "status", COUNT(*) AS "count" FROM (
52
- SELECT
53
- CASE WHEN "status" = 'DONE' AND rg.updated_at::date = CURRENT_DATE THEN 'DONE'
54
- WHEN "status" = 'PENDING_CANCEL' THEN 'PENDING CANCEL'
55
- WHEN "status" = 'CANCELLED' AND rg.updated_at::date = CURRENT_DATE THEN 'CANCELLED'
56
- WHEN "status" IN('PENDING_RECEIVE','PENDING_WORKSHEET') THEN 'PICKING UNASSIGNED'
57
- END AS "status"
58
- FROM release_goods rg
59
- WHERE "domain_id" = $1
60
- AND rg."bizplace_id" IN (${bizplaceIds})
61
- AND rg."status" IN ('PENDING','PENDING_RECEIVE','PENDING_WORKSHEET','READY_TO_PICK','PICKING','READY_TO_PACK','PACKING','PENDING_CANCEL','CANCELLED','DONE')
62
- ) AS foo
63
- GROUP BY "status"
64
- UNION ALL
65
- SELECT "status", COUNT(*) AS "count" FROM (
66
- SELECT
67
- CASE WHEN "dispatchment_status" = 'DISPATCHED' AND rg.updated_at::date = CURRENT_DATE THEN 'OUT FROM WAREHOUSE'
68
- END AS "status"
69
- FROM release_goods rg
70
- WHERE "domain_id" = $1
71
- AND rg."bizplace_id" IN (${bizplaceIds})
72
- AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
73
- AND rg."tracking_no" NOTNULL
74
- AND rg."type" = 'b2c'
75
- ) AS foo
76
- GROUP BY "status"
77
- UNION ALL
78
- SELECT 'AWAITING DISPATCH' AS "status", count(*) FROM manifests m
79
- INNER JOIN release_goods rg ON rg.manifest_id = m.id
80
- WHERE m."status" in ('OPEN', 'IN_QUEUE')
81
- AND m."domain_id" = $1
82
- AND rg."bizplace_id" IN (${bizplaceIds})
83
- UNION ALL
84
- SELECT 'PICKING ASSIGNED' AS "status", count(*) FROM worksheets w
85
- WHERE w."domain_id" = $1
86
- AND w."bizplace_id" IN (${bizplaceIds})
87
- AND w."type" = 'PICKING'
88
- AND w."status" IN ('DEACTIVATED','EXECUTING')
89
- GROUP BY w."status"
90
- UNION ALL
91
- SELECT 'BATCH PICKING ASSIGNED' AS "status", count(*) FROM worksheets w
92
- WHERE w."domain_id" = $1
93
- AND w."bizplace_id" IN (${bizplaceIds})
94
- AND w."type" = 'BATCH_PICKING'
95
- AND w."status" IN ('DEACTIVATED','EXECUTING')
96
- GROUP BY w."status"
97
- UNION ALL
98
- SELECT 'PACKING' AS "status", count(*) FROM worksheets w
99
- WHERE w."domain_id" = $1 AND w."type" = 'PACKING'
100
- AND w."bizplace_id" IN (${bizplaceIds})
101
- AND w."status" IN ('DEACTIVATED','EXECUTING')
102
- GROUP BY w."status"
103
- UNION ALL
104
- SELECT 'PENDING MANIFEST CREATION' AS "status", count(*) FROM release_goods rg
105
- WHERE rg."domain_id" = $1
106
- AND rg."bizplace_id" IN (${bizplaceIds})
107
- AND rg."status" = 'DONE'
108
- AND rg."manifest_id" ISNULL
109
- AND rg."type" = 'b2c'
110
- AND rg."updated_at" >= (CURRENT_DATE - 30)
111
- UNION ALL
112
- SELECT 'DRAFT' AS "status", count(*) FROM draft_release_goods drg
113
- WHERE drg."domain_id" = $1
114
- AND drg."bizplace_id" IN (${bizplaceIds})
115
- AND drg."status" = 'DRAFT'
116
- AND drg."type" = 'b2c'
117
- ) AS src
118
- GROUP BY "status"
119
- ) src ON src."status" = l."status"
120
- `,
121
- [domain.id]
122
- )
123
-
124
- return orderStatus
125
- }
126
- }
@@ -1,34 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm'
2
-
3
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
4
- import { ReleaseGood } from '@things-factory/sales-base'
5
- import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
6
-
7
- export const releaseGoodsByStatusResolver = {
8
- async releaseGoodsByStatus(_: 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<ReleaseGood> = getRepository(ReleaseGood).createQueryBuilder('rg')
26
- buildQuery(qb, params, context)
27
- return qb
28
- .select('rg.status', 'status')
29
- .addSelect('COUNT(*) AS count')
30
- .andWhere(`rg.bizplace_id IN (${bizplaceIds})`)
31
- .groupBy('rg.status')
32
- .getRawMany()
33
- }
34
- }
@@ -1,61 +0,0 @@
1
- import { getRepository, SelectQueryBuilder, EntityManager } from 'typeorm'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
- import { buildQuery, Domain, ListParam } from '@things-factory/shell'
6
-
7
- export const unitInboundedOutboundedResolver = {
8
- async unitInboundedOutbounded(_: any, params: ListParam, context: any) {
9
- const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
10
- const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
11
- const fromDate: string = params.filters.find((filter: any) => filter.name === 'createdAt1')?.value
12
- const toDate: string = params.filters.find((filter: any) => filter.name === 'createdAt2')?.value
13
- 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)
14
- let bizplaceIds: string
15
-
16
- if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
17
- let bizplaces: string[] =
18
- bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
19
- bizplaceIds = bizplaces
20
- .map(bizplace => {
21
- return "'" + bizplace?.trim() + "'"
22
- })
23
- .join(',')
24
- } else throw new Error('invalid bizplaceId')
25
-
26
- const orderStatus: { status: string; count: number }[] = await tx.query(
27
- `
28
- WITH cte_unit ("status", "count", "type") AS (
29
- SELECT 'INBOUNDED' AS status, 0 AS "count", 'inbound' AS "type"
30
- UNION
31
- SELECT 'OUTBOUNDED' AS status, 0 AS "count", 'outbound' AS "type"
32
- ) SELECT u."status", coalesce(src."count", u."count") AS "count", u."type"
33
- FROM cte_unit u
34
- LEFT JOIN (
35
- SELECT "status", SUM("count") AS count, "type" FROM (
36
- SELECT 'INBOUNDED' AS "status", SUM(coalesce(op.actual_pack_qty, op.pack_qty)) as "count", 'inbound' as "type" FROM order_products op
37
- INNER JOIN arrival_notices an ON an.id = op.arrival_notice_id
38
- WHERE an."status" in ('PUTTING_AWAY','DONE')
39
- AND an."domain_id" = $1
40
- AND an."bizplace_id" IN (${bizplaceIds})
41
- AND an.created_at BETWEEN '${fromDate}' AND '${toDate}'
42
- GROUP BY an."status"
43
- UNION ALL
44
- SELECT 'OUTBOUNDED' AS "status", SUM(coalesce(oi.release_qty , oi.picked_qty)) as "count", 'outbound' as "type" FROM order_inventories oi
45
- INNER JOIN release_goods rg on rg.id = oi.release_good_id
46
- WHERE rg."status" in ('DONE')
47
- AND rg."domain_id" = $1
48
- AND rg."bizplace_id" IN (${bizplaceIds})
49
- AND rg.created_at BETWEEN '${fromDate}' AND '${toDate}'
50
- GROUP BY rg."status"
51
- ) AS src
52
- GROUP BY "status", "type"
53
- ) src ON src."status" = u."status"
54
- order by "type", "status"
55
- `,
56
- [domain.id]
57
- )
58
-
59
- return orderStatus
60
- }
61
- }
@@ -1,24 +0,0 @@
1
- import * as BoardSetting from './board-setting'
2
- import * as CustomElccl from './custom/elccl'
3
- import * as CustomKimeda from './custom/kimeda'
4
- import * as Dashboard from './dashboard'
5
- import * as Other from './other'
6
- import * as OpaMenu from './opa-menu'
7
- import * as Reports from './reports'
8
- import * as InventoryComparison from './inventory-comparison'
9
- import * as ShippingProviders from './shipping-provider'
10
- import * as WarehouseInventoryAdjustment from './warehouse-inventory-adjustment'
11
-
12
- export const queries = [
13
- BoardSetting.Query,
14
- CustomElccl.Query,
15
- CustomKimeda.Query,
16
- Dashboard.Query,
17
- InventoryComparison.Query,
18
- OpaMenu.Query,
19
- Other.Query,
20
- Reports.Query,
21
- ShippingProviders.Query
22
- ]
23
-
24
- export const mutations = [Other.Mutation, WarehouseInventoryAdjustment.Mutation]
@@ -1,5 +0,0 @@
1
- import { inventoryComparisonList } from './inventory-comparison-list'
2
-
3
- export const Query = {
4
- ...inventoryComparisonList
5
- }
@@ -1,101 +0,0 @@
1
- import { ListParam } from '@things-factory/shell'
2
- import { onhandInventories } from '@things-factory/warehouse-base'
3
-
4
- import { inventoryHistorySummaryReportQuery } from '../custom/elccl/elccl-inventory-history-summary-report'
5
-
6
- export const inventoryComparisonList = {
7
- async inventoryComparisonList(_: any, params: ListParam, context: ResolverContext) {
8
- try {
9
- const { tx } = context.state
10
-
11
- let bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
12
-
13
- if (!bizplaceFilter) {
14
- return
15
- }
16
-
17
- let toDateFilter = params.filters.find(data => data.name === 'toDate')
18
- let toDateDate = new Date(toDateFilter.value)
19
- let fromDate = toDateDate.setDate(toDateDate.getDate() - 1)
20
- let fromDateISO = new Date(fromDate).toISOString()
21
- let nonTallyFilter = params.filters.find(data => data.name === 'nonTally').value
22
- let productFilter = params.filters.find(data => data.name === 'product')
23
-
24
- params.filters.push({
25
- name: 'fromDate',
26
- operator: 'eq',
27
- value: fromDateISO
28
- })
29
-
30
- params.filters.push(
31
- { name: 'status', operator: 'notin', value: ['INTRANSIT', 'TERMINATED', 'DELETED'] },
32
- { name: 'remainOnly', operator: 'eq', value: true },
33
- { name: 'unlockOnly', operator: 'eq', value: true },
34
- { name: 'created_at', operator: 'eq', value: toDateFilter.value },
35
- { name: 'timezoneOffset', operator: 'eq', value: new Date().getTimezoneOffset() },
36
- { name: 'expiration', operator: 'eq', value: false }
37
- )
38
-
39
- let productQueryFilter = ``
40
-
41
- if (productFilter) {
42
- let products = productFilter.value
43
- .toLowerCase()
44
- .split(',')
45
- .map(prod => {
46
- return "'%" + prod.trim().replace(/'/g, "''") + "%'"
47
- })
48
- .join(',')
49
-
50
- productQueryFilter =
51
- productQueryFilter +
52
- `
53
- ${nonTallyFilter ? 'and' : 'where'} (lower(summ.product_name) like any(array[${products}])
54
- or lower(summ.product_sku) like any(array[${products}]))`
55
- }
56
-
57
- await Promise.all([
58
- inventoryHistorySummaryReportQuery(_, params, context),
59
- onhandInventories(params.filters, params.pagination, params.sortings, [], context, false)
60
- ])
61
-
62
- await tx.query(`
63
- create temp table tmp_inv_comp on commit drop as (
64
- select summ."batch_id", summ.product_id, summ.product_name, summ.product_sku, summ.packing_type, summ.closing_qty, coalesce(oh.qty, 0) as "onhand_qty" from temp_inventory_summary summ
65
- left join (
66
- select "batch_id" as "batch_id", product_id, sum("qty") as qty from tmp_data group by "batch_id", product_id
67
- ) oh on oh.batch_id = summ.batch_id and oh.product_id = summ.product_id
68
- ${nonTallyFilter ? 'where coalesce(oh.qty, 0) <> summ.closing_qty' : ''}
69
- ${productQueryFilter}
70
- );
71
- `)
72
-
73
- let sumData = await tx.query(
74
- `
75
- select * from tmp_inv_comp
76
- offset $1 limit $2
77
- `,
78
- [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
79
- )
80
-
81
- const totalQuery: number = await tx.query(`select count(*) from tmp_inv_comp `)
82
-
83
- const total = parseInt(totalQuery[0].count)
84
-
85
- const items: any[] = sumData.map(item => {
86
- return {
87
- productName: item.product_name,
88
- productSku: item.product_sku,
89
- packingType: item.packing_type,
90
- closingQty: item.closing_qty,
91
- remainQty: item.onhand_qty,
92
- batchId: item.batch_id
93
- }
94
- })
95
-
96
- return { items, total }
97
- } catch (error) {
98
- throw error
99
- }
100
- }
101
- }
@@ -1,5 +0,0 @@
1
- import { opaMenusResolver } from './opa-menus'
2
-
3
- export const Query = {
4
- ...opaMenusResolver
5
- }
@@ -1,77 +0,0 @@
1
- import { In, SelectQueryBuilder } from 'typeorm'
2
-
3
- import { Role, User } from '@things-factory/auth-base'
4
- import { Menu } from '@things-factory/menu-base'
5
- import { Domain, getRepository } from '@things-factory/shell'
6
-
7
- export const opaMenusResolver = {
8
- async opaMenus(_: any, _params: any, context: ResolverContext) {
9
- let menus: Menu[] = []
10
- if (context?.state?.domain?.id && context?.state?.user?.id) {
11
- try {
12
- const qb: SelectQueryBuilder<User> = getRepository(User).createQueryBuilder('USER')
13
- const user: User = await qb
14
- .leftJoinAndSelect('USER.roles', 'ROLES')
15
- .leftJoinAndSelect('ROLES.domain', 'ROLES_DOMAIN')
16
- .where('USER.id = :userId', { userId: context.state.user.id })
17
- .andWhere('ROLES_DOMAIN.id = :domainId', { domainId: context.state.domain.id })
18
- .getOne()
19
-
20
- // get menus which are non-restricted by any role.
21
- menus.push(...(await getNonRestrictedMenus(context.state.domain)))
22
-
23
- const userRoleIds: string[] = user.roles.map((role: Role) => role.id)
24
- let restrictedMenus: Menu[] = []
25
- if (userRoleIds?.length) {
26
- // get menus which are restricted by role ()
27
- restrictedMenus = [...(await getRestrictedMenus(userRoleIds, context.state.domain))]
28
- }
29
-
30
- const restrictedMenuIds: string[] = restrictedMenus.map((restrictedMenu: Menu) => restrictedMenu.id)
31
- menus.forEach(menu => {
32
- const idx = restrictedMenuIds.indexOf(menu.id)
33
- if (idx !== -1) {
34
- menu.children = Array.from(new Set([...restrictedMenus[idx].children, ...menu.children]))
35
- }
36
- })
37
-
38
- return menus.filter((groupMenu: Menu) => groupMenu?.children?.length)
39
- } catch (e) {
40
- throw e
41
- }
42
- }
43
- }
44
- }
45
-
46
- async function getNonRestrictedMenus(domain: Domain): Promise<Menu[]> {
47
- const menus: Menu[] = await getRepository(Menu).find({
48
- where: { domain: { id: domain.id }, hiddenFlag: false, menuType: 'MENU' },
49
- relations: ['parent', 'children', 'children.roles'],
50
- order: { rank: 'ASC' }
51
- })
52
-
53
- menus.forEach(menu => {
54
- menu.children = menu.children.filter(child => !child.roles?.length)
55
- })
56
-
57
- return menus
58
- }
59
-
60
- async function getRestrictedMenus(roleIds: string[], domain: Domain): Promise<Menu[]> {
61
- const menus: Menu[] = await getRepository(Menu).find({
62
- where: { domain: { id: domain.id }, hiddenFlag: false, menuType: 'MENU' },
63
- relations: ['parent', 'children', 'children.roles'],
64
- order: { rank: 'ASC' }
65
- })
66
- const userRoles: Role[] = await getRepository(Role).find({ where: { domain: { id: domain.id }, id: In(roleIds) } })
67
-
68
- menus.forEach(menu => {
69
- menu.children = menu.children.filter(child => {
70
- const childRoleIds = child.roles?.map(role => role.id) || []
71
-
72
- return userRoles.find(role => childRoleIds.includes(role.id)) || false
73
- })
74
- })
75
-
76
- return menus
77
- }