@things-factory/operato-hub 4.3.161 → 4.3.163

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 (61) hide show
  1. package/dist-server/entities/email-attachment.js +77 -0
  2. package/dist-server/entities/email-attachment.js.map +1 -0
  3. package/dist-server/entities/email-recipient.js +69 -0
  4. package/dist-server/entities/email-recipient.js.map +1 -0
  5. package/dist-server/entities/email.js +90 -0
  6. package/dist-server/entities/email.js.map +1 -0
  7. package/dist-server/entities/index.js +10 -0
  8. package/dist-server/entities/index.js.map +1 -1
  9. package/dist-server/graphql/resolvers/email/index.js +6 -0
  10. package/dist-server/graphql/resolvers/email/index.js.map +1 -0
  11. package/dist-server/graphql/resolvers/email/send-emails.js +177 -0
  12. package/dist-server/graphql/resolvers/email/send-emails.js.map +1 -0
  13. package/dist-server/graphql/resolvers/index.js +4 -2
  14. package/dist-server/graphql/resolvers/index.js.map +1 -1
  15. package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js +200 -0
  16. package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js.map +1 -0
  17. package/dist-server/graphql/resolvers/reports/index.js +7 -0
  18. package/dist-server/graphql/resolvers/reports/index.js.map +1 -0
  19. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +231 -0
  20. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -0
  21. package/dist-server/graphql/types/index.js +3 -2
  22. package/dist-server/graphql/types/index.js.map +1 -1
  23. package/dist-server/graphql/types/reports/inbound-order-details-report-list.js +14 -0
  24. package/dist-server/graphql/types/reports/inbound-order-details-report-list.js.map +1 -0
  25. package/dist-server/graphql/types/reports/inbound-order-details-report.js +59 -0
  26. package/dist-server/graphql/types/reports/inbound-order-details-report.js.map +1 -0
  27. package/dist-server/graphql/types/reports/index.js +13 -0
  28. package/dist-server/graphql/types/reports/index.js.map +1 -0
  29. package/dist-server/graphql/types/reports/outbound-order-details-report-list.js +14 -0
  30. package/dist-server/graphql/types/reports/outbound-order-details-report-list.js.map +1 -0
  31. package/dist-server/graphql/types/reports/outbound-order-details-report.js +76 -0
  32. package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -0
  33. package/dist-server/graphql/types/synchronization/index.js +1 -0
  34. package/dist-server/graphql/types/synchronization/index.js.map +1 -1
  35. package/dist-server/index.js +1 -0
  36. package/dist-server/index.js.map +1 -1
  37. package/dist-server/utils/index.js +1 -0
  38. package/dist-server/utils/index.js.map +1 -1
  39. package/dist-server/utils/report-query-util.js +42 -0
  40. package/dist-server/utils/report-query-util.js.map +1 -0
  41. package/package.json +29 -28
  42. package/server/entities/email-attachment.ts +49 -0
  43. package/server/entities/email-recipient.ts +51 -0
  44. package/server/entities/email.ts +68 -0
  45. package/server/entities/index.ts +7 -0
  46. package/server/graphql/resolvers/email/index.ts +5 -0
  47. package/server/graphql/resolvers/email/send-emails.ts +173 -0
  48. package/server/graphql/resolvers/index.ts +4 -2
  49. package/server/graphql/resolvers/reports/inbound-order-details-report.ts +218 -0
  50. package/server/graphql/resolvers/reports/index.ts +7 -0
  51. package/server/graphql/resolvers/reports/outbound-order-details-report.ts +251 -0
  52. package/server/graphql/types/index.ts +3 -2
  53. package/server/graphql/types/reports/inbound-order-details-report-list.ts +8 -0
  54. package/server/graphql/types/reports/inbound-order-details-report.ts +53 -0
  55. package/server/graphql/types/reports/index.ts +11 -0
  56. package/server/graphql/types/reports/outbound-order-details-report-list.ts +8 -0
  57. package/server/graphql/types/reports/outbound-order-details-report.ts +70 -0
  58. package/server/graphql/types/synchronization/index.ts +1 -0
  59. package/server/index.ts +1 -0
  60. package/server/utils/index.ts +1 -0
  61. package/server/utils/report-query-util.ts +47 -0
@@ -0,0 +1,218 @@
1
+ import { EntityManager } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
4
+ import { Bizplace } from '@things-factory/biz-base'
5
+ import { ListParam } from '@things-factory/shell'
6
+
7
+ import { rawProductsQuery } from '../../../utils'
8
+
9
+ export const inboundOrderDetailsReport = {
10
+ async inboundOrderDetailsReport(_: any, params: ListParam, context: any) {
11
+ try {
12
+ const { tx }: { tx: EntityManager } = context.state
13
+ let bizplaceFilter = { name: '', operator: '', value: '' }
14
+ let userFilter = params.filters.find(data => data.name === 'user')
15
+ let fromDate = params.filters.find(data => data.name === 'fromDate')
16
+ let toDate = params.filters.find(data => data.name === 'toDate')
17
+ let ganNo = params.filters.find(data => data.name === 'ganNo')
18
+ let grnNo = params.filters.find(data => data.name === 'grnNo')
19
+ let poNo = params.filters.find(data => data.name === 'poNo')
20
+ let doNo = params.filters.find(data => data.name === 'doNo')
21
+
22
+ if (userFilter) {
23
+ const user: User = await tx.getRepository(User).findOne({
24
+ where: { id: userFilter.value },
25
+ relations: ['bizplaces']
26
+ })
27
+
28
+ const bizplace: Bizplace = user.bizplaces[0]
29
+
30
+ if (!bizplace) throw 'Invalid input'
31
+
32
+ bizplaceFilter = { name: 'bizplace', operator: 'eq', value: bizplace.id }
33
+ } else {
34
+ bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
35
+ }
36
+
37
+ if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
38
+
39
+ const bizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
40
+ id: bizplaceFilter.value
41
+ })
42
+
43
+ await rawProductsQuery(tx, params, bizplace)
44
+
45
+ let extraQueryFilters = ''
46
+ if (ganNo) {
47
+ extraQueryFilters = `${extraQueryFilters} and gan_no like '%${ganNo.value}%' `
48
+ }
49
+ if (grnNo) {
50
+ extraQueryFilters = `${extraQueryFilters} and grn_no like '%${grnNo.value}%' `
51
+ }
52
+ if (poNo) {
53
+ extraQueryFilters = `${extraQueryFilters} and purchase_order_name like '%${poNo.value}%' `
54
+ }
55
+ if (doNo) {
56
+ extraQueryFilters = `${extraQueryFilters} and delivery_order_no like '%${doNo.value}%' `
57
+ }
58
+
59
+ await tx.query(
60
+ `
61
+ create temp table temp_inbound_order_report on commit drop as (
62
+ select * from (
63
+ select b2.id as "bizplace_id", b2.name as "bizplace_name", b2.description as "bizplace_description",
64
+ grn.name as "grn_no",
65
+ an.name as "gan_no", an.ref_no as "ref_no_1", an.ref_no_2 as "ref_no_2", an.ref_no_3 as "ref_no_3",
66
+ an.loose_item, an.import_cargo, an.container_no, an.container_size, an.own_transport,
67
+ u.name as "accepted_by", an.accepted_at,
68
+ an.created_at as "order_created_at",
69
+ w.started_at as "unload_start", w.ended_at as "unload_complete",
70
+ w2.started_at as "putaway_start", w2.ended_at as "putaway_complete",
71
+ an.delivery_order_no,
72
+ cp.id as "supplier_id",
73
+ cp.company_name as "supplier_name",
74
+ po.id as "purchase_order_id",
75
+ po.name as "purchase_order_name",
76
+ row_number() over(partition by an.name order by an.name, p.sku, ih.batch_id) as "order_line_item",
77
+ 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",
78
+ ih.packing_type as "pack_type", op.packing_size as "pack_size",
79
+ ih.qty, ih.uom_value, ih.uom, ih.pallet_id, ih.carton_id, ih.batch_id, ih.batch_id_ref,
80
+ i.expiration_date, i.manufacture_date,
81
+ ih.unit_cost,
82
+ ih.created_at as "unloaded_at",u2.name as "unloaded_by",
83
+ ih2.created_at as "putaway_at", u3.name as "putaway_by",
84
+ coalesce((select volume from product_details pd where pd.id = i.product_detail_id
85
+ order by created_at desc
86
+ fetch first 1 rows only),0) as unit_volume,
87
+ coalesce((select nett_weight from product_details pd where pd.id = i.product_detail_id
88
+ order by created_at desc
89
+ fetch first 1 rows only),0) as unit_nett_weight,
90
+ coalesce((select gross_weight from product_details pd where pd.id = i.product_detail_id
91
+ order by created_at desc
92
+ fetch first 1 rows only),0) as unit_gross_weight,
93
+ coalesce((select weight_unit from product_details pd where pd.id = i.product_detail_id
94
+ order by created_at desc
95
+ fetch first 1 rows only),'') as weight_unit
96
+ from (
97
+ select * from arrival_notices
98
+ where domain_id = $1 and bizplace_id = $2 and status ='DONE'
99
+ and created_at >= $3 and created_at <= $4) an
100
+ left join goods_receival_notes grn on grn.arrival_notice_id = an.id
101
+ left join purchase_orders po on po.id = an.purchase_order_id
102
+ left join contact_points cp on cp.id = po.supplier_id
103
+ inner join bizplaces b2 on b2.id = an.bizplace_id
104
+ left join users u on u.id = an.accepted_by_id
105
+ inner join order_inventories oi on oi.arrival_notice_id = an.id
106
+ inner join inventories i on i.id = oi.inventory_id
107
+ left join worksheets w on w.arrival_notice_id = an.id and w."type" ='UNLOADING'
108
+ inner join reduced_inventory_histories ih on ih.inventory_id = oi.inventory_id and ih.transaction_type ='UNLOADING' and ih.ref_order_id = an.id::varchar
109
+ left join users u2 on u2.id = ih.creator_id
110
+ left join worksheets w2 on w2.arrival_notice_id = an.id and w2."type" ='PUTAWAY'
111
+ inner join reduced_inventory_histories ih2 on ih2.inventory_id = oi.inventory_id and ih2.transaction_type ='PUTAWAY' and ih2.ref_order_id = an.id::varchar
112
+ left join users u3 on u3.id = ih2.creator_id
113
+ inner join temp_products p on p.id = ih.product_id
114
+ inner join order_products op on op.arrival_notice_id = an.id and op.actual_pack_qty is not null and op.product_detail_id = ih.product_detail_id and
115
+ op.batch_id = ih.batch_id
116
+ order by an.name, p.sku, ih.batch_id
117
+ ) src
118
+ where 1=1
119
+ ${extraQueryFilters}
120
+ )
121
+ `,
122
+ [context.state.domain.id, bizplace.id, fromDate.value, toDate.value]
123
+ )
124
+
125
+ const total: any = await tx.query(`
126
+ select count(*) from temp_inbound_order_report
127
+ `)
128
+
129
+ const result: any = await tx.query(
130
+ `
131
+ select *,
132
+ round((qty * unit_volume)::numeric ,4) as total_volume,
133
+ round((qty * unit_nett_weight)::numeric ,4) as total_unit_nett_weight,
134
+ round((qty * unit_gross_weight)::numeric ,4) as total_unit_gross_weight
135
+ from temp_inbound_order_report
136
+ offset $1 limit $2
137
+ `,
138
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
139
+ )
140
+
141
+ let items = result.map(itm => {
142
+ let data = {
143
+ bizplace: {
144
+ description: itm.bizplace_description,
145
+ name: itm.bizplace_name
146
+ },
147
+ grnNo: itm.grn_no,
148
+ ganNo: itm.gan_no,
149
+ deliveryOrderNo: itm.delivery_order_no,
150
+ refNo1: itm.ref_no_1,
151
+ refNo2: itm.ref_no_2,
152
+ refNo3: itm.ref_no_3,
153
+ looseItem: itm.loose_item,
154
+ importCargo: itm.import_cargo,
155
+ containerNo: itm.container_no,
156
+ containerSize: itm.container_size,
157
+ ownTransport: itm.own_transport,
158
+ acceptedBy: itm.accepted_by,
159
+ acceptedAt: itm.accepted_at,
160
+ orderCreatedAt: itm.order_created_at,
161
+ unloadStart: itm.unload_start,
162
+ unloadComplete: itm.unload_complete,
163
+ putawayStart: itm.putaway_start,
164
+ putawayComplete: itm.putaway_complete,
165
+ orderLineItem: itm.order_line_item,
166
+ product: {
167
+ id: itm.product_id,
168
+ sku: itm.product_sku,
169
+ name: itm.product_name,
170
+ description: itm.product_description,
171
+ type: itm.product_type
172
+ },
173
+ purchaseOrderId: itm.purchase_order_id,
174
+ purchaseOrderNo: itm.purchase_order_name,
175
+ packType: itm.pack_type,
176
+ packSize: itm.pack_size,
177
+ qty: itm.qty,
178
+ uomValue: itm.uom_value,
179
+ uom: itm.uom,
180
+ unitVolume: itm.unit_volume,
181
+ unitCost: itm.unit_cost,
182
+ totalVolume: itm.total_volume,
183
+ unitNettWeight: itm.unit_nett_weight,
184
+ totalUnitNettWeight: itm.total_unit_nett_weight,
185
+ unitGrossWeight: itm.unit_gross_weight,
186
+ totalUnitGrossWeight: itm.total_unit_gross_weight,
187
+ weightUnit: itm.weight_unit,
188
+ palletId: itm.pallet_id,
189
+ cartonId: itm.carton_id,
190
+ batchId: itm.batch_id,
191
+ batchIdRef: itm.batch_id_ref,
192
+ expirationDate: itm.expiration_date,
193
+ manufactureDate: itm.manufacture_date,
194
+ unloadedAt: itm.unloaded_at,
195
+ unloadedBy: itm.unloaded_by,
196
+ putawayAt: itm.putaway_at,
197
+ putawayBy: itm.putaway_by
198
+ }
199
+
200
+ if (itm.supplier_id) {
201
+ data['supplier'] = {
202
+ id: itm.supplier_id,
203
+ name: itm.supplier_name
204
+ }
205
+ }
206
+
207
+ return data
208
+ })
209
+
210
+ return {
211
+ items,
212
+ total: total[0].count
213
+ }
214
+ } catch (error) {
215
+ throw error
216
+ }
217
+ }
218
+ }
@@ -0,0 +1,7 @@
1
+ import { inboundOrderDetailsReport } from './inbound-order-details-report'
2
+ import { outboundOrderDetailsReport } from './outbound-order-details-report'
3
+
4
+ export const Query = {
5
+ ...inboundOrderDetailsReport,
6
+ ...outboundOrderDetailsReport
7
+ }
@@ -0,0 +1,251 @@
1
+ import { EntityManager } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
4
+ import { Bizplace } from '@things-factory/biz-base'
5
+ import { ListParam } from '@things-factory/shell'
6
+
7
+ import { rawProductsQuery } from '../../../utils'
8
+
9
+ export const outboundOrderDetailsReport = {
10
+ async outboundOrderDetailsReport(_: any, params: ListParam, context: any) {
11
+ try {
12
+ const { tx }: { tx: EntityManager } = context.state
13
+ let bizplaceFilter = { name: '', operator: '', value: '' }
14
+ let userFilter = params.filters.find(data => data.name === 'user')
15
+ let fromDate = params.filters.find(data => data.name === 'fromDate')
16
+ let toDate = params.filters.find(data => data.name === 'toDate')
17
+ let roNo = params.filters.find(data => data.name === 'roNo')
18
+ let doNo = params.filters.find(data => data.name === 'doNo')
19
+ let status = params.filters.find(data => data.name === 'status')
20
+
21
+ if (userFilter) {
22
+ const user: User = await tx.getRepository(User).findOne({
23
+ where: { id: userFilter.value },
24
+ relations: ['bizplaces']
25
+ })
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).findOne({
39
+ id: bizplaceFilter.value
40
+ })
41
+
42
+ await rawProductsQuery(tx, params, bizplace)
43
+
44
+ let extraQueryFilters = ''
45
+ if (roNo) {
46
+ extraQueryFilters = `${extraQueryFilters} and ro_no like '%${roNo.value}%' `
47
+ }
48
+ if (doNo) {
49
+ extraQueryFilters = `${extraQueryFilters} and delivery_order_no like '%${doNo.value}%' `
50
+ }
51
+
52
+ console.time('temp')
53
+ await tx.query(
54
+ `
55
+ create temp table temp_outbound_order_report on commit drop as (
56
+ select * from (
57
+ select oi.id,
58
+ oi.release_qty AS "release_qty", oi.picked_at, oi.picked_by, oi.packed_at, oi.packed_by, oi.loaded_at, oi.loaded_by,
59
+ oi.release_qty as "qty", oi.release_uom_value as "uom_value", oi.return_to_location_qty, oi.return_to_location_uom_value, oi.product_detail_id,
60
+ coalesce(do2.other_driver, td.name) as driver_name,
61
+ coalesce(do2.truck_no, tv.name, rg.truck_no) as vehicle_no,
62
+ do2.name AS "delivery_order_no", do2.delivery_date AS "delivery_order_delivery_date", do2."to", do2.contact_point_ref_id, do2.pallet_qty,
63
+ coalesce(do2.delivery_date_time, do2.delivery_date::timestamp, ms.dispatched_at, null) as "dispatched_at",
64
+ rg.bizplace_id, $5 AS "bizplace_name", $6 AS "bizplace_description",
65
+ 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,
66
+ so.container_no, so.container_size,
67
+ 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",
68
+ u1.name as "order_created_by", rg.created_at AS "order_created_at",
69
+ 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,
70
+ 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", oi.packing_type as "packing_type", oi.packing_size as "packing_size",
71
+ i.uom, i.unit_cost,
72
+ i.id as inventory_id, i.pallet_id, i.carton_id, i.batch_id, i.batch_id_ref, i.expiration_date, i.manufacture_date,
73
+ coalesce(ms.name,'') as manifest_no, coalesce(rg.manifested_at, ms.created_at) as manifested_at, coalesce(u6.name, u5.name) as manifested_by
74
+ from release_goods rg
75
+ left join users u1 on u1.id = rg.creator_id
76
+ inner join order_inventories oi on rg.id = oi.release_good_id
77
+ left join shipping_orders so on so.id = rg.shipping_order_id
78
+ left join users u4 on u4.id = rg.accepted_by_id
79
+ left join manifests ms on ms.id = rg.manifest_id
80
+ left join users u5 on u5.id = ms.creator_id
81
+ left join users u6 on u6.id = rg.manifested_by_id
82
+ inner join inventories i on i.id = oi.inventory_id
83
+ inner join temp_products p on p.id = oi.product_id
84
+ left join delivery_orders do2 on do2.id = oi.delivery_order_id
85
+ left join transport_drivers td ON td.id = do2.transport_driver_id
86
+ left join transport_vehicles tv on tv.id = do2.transport_vehicle_id
87
+ where rg.bizplace_id = $2 and rg.domain_id = $1
88
+ and rg.created_at >= $3 and rg.created_at <= $4
89
+ and oi.status <> 'REPLACED'
90
+ ${status ? `and rg.status = '${status.value}' ` : ``}
91
+ ) src
92
+ where 1=1
93
+ ${extraQueryFilters}
94
+ )
95
+ `,
96
+ [context.state.domain.id, bizplace.id, fromDate.value, toDate.value, bizplace.name, bizplace.description]
97
+ )
98
+
99
+ console.timeEnd('temp')
100
+ const total: any = await tx.query(`
101
+ select count(*) from temp_outbound_order_report
102
+ `)
103
+
104
+ await tx.query(
105
+ `
106
+ create temp table temp_outbound_order_worksheet on commit drop as (
107
+ select oi.id, w.started_at, w.ended_at, w.type from temp_outbound_order_report oi
108
+ inner join worksheet_details wd on wd.target_inventory_id = oi.id
109
+ inner join worksheets w on w.id = wd.worksheet_id
110
+ )
111
+ `
112
+ )
113
+
114
+ console.time('result')
115
+ const result: any = await tx.query(
116
+ `
117
+ select *,
118
+ round((qty * unit_volume)::numeric ,4) as total_volume,
119
+ round((qty * unit_nett_weight)::numeric ,4) as total_unit_nett_weight,
120
+ round((qty * unit_gross_weight)::numeric ,4) as total_unit_gross_weight
121
+ from (
122
+ select oi.*,
123
+ wpick.started_at as picking_start, wpick.ended_at as picking_complete,
124
+ wpack.started_at as packing_start, wpack.ended_at as packing_complete,
125
+ wsort.started_at as sorting_start, wsort.ended_at as sorting_complete,
126
+ wload.started_at as loading_start, wload.ended_at as loading_complete,
127
+ coalesce(delivery_address, concat(cp.address, cp.address_2)) as "delivery_address",
128
+ coalesce((select volume from product_details pd where pd.id = oi.product_detail_id
129
+ order by created_at desc
130
+ fetch first 1 rows only),0) as unit_volume,
131
+ coalesce((select nett_weight from product_details pd where pd.id = oi.product_detail_id
132
+ order by created_at desc
133
+ fetch first 1 rows only),0) as unit_nett_weight,
134
+ coalesce((select gross_weight from product_details pd where pd.id = oi.product_detail_id
135
+ order by created_at desc
136
+ fetch first 1 rows only),0) as unit_gross_weight,
137
+ coalesce((select weight_unit from product_details pd where pd.id = oi.product_detail_id
138
+ order by created_at desc
139
+ fetch first 1 rows only),'') as weight_unit,
140
+ coalesce((select unit_cost from reduced_inventory_histories rih where
141
+ rih.ref_order_id::uuid = oi.id and
142
+ rih.inventory_id::uuid = oi.inventory_id and
143
+ rih.transaction_type = 'PICKING'
144
+ order by created_at desc
145
+ fetch first 1 rows only), oi.unit_cost, 0) as unit_cost
146
+ from temp_outbound_order_report oi
147
+ left join contact_points cp on cp.id = oi.contact_point_ref_id
148
+ left join temp_outbound_order_worksheet wpick on wpick.id = oi.id
149
+ and (wpick.type= 'PICKING' OR wpick.type = 'BATCH_PICKING')
150
+ left join temp_outbound_order_worksheet wpack on wpack.id = oi.id
151
+ and wpack.type= 'PACKING'
152
+ left join temp_outbound_order_worksheet wsort on wsort.id = oi.id
153
+ and wsort.type= 'SORTING'
154
+ left join temp_outbound_order_worksheet wload on wload.id = oi.id
155
+ and wload.type= 'LOADING'
156
+ order by oi.ro_no, oi.product_sku
157
+ offset $1 limit $2
158
+ ) src
159
+ `,
160
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
161
+ )
162
+
163
+ console.timeEnd('result')
164
+
165
+ let items = result.map(itm => {
166
+ return {
167
+ bizplace: {
168
+ id: itm.bizplace_id,
169
+ name: itm.bizplace_name,
170
+ description: itm.bizplace_description
171
+ },
172
+ doNo: itm.delivery_order_no,
173
+ doDeliveryDate: itm.delivery_order_delivery_date,
174
+ dispatchedAt: itm.dispatched_at,
175
+ deliveryAddress: itm.delivery_address,
176
+ manifestNo: itm.manifest_no,
177
+ roNo: itm.ro_no,
178
+ roType: itm.ro_type,
179
+ status: itm.ro_status,
180
+ refNo1: itm.ref_no_1,
181
+ refNo3: itm.ref_no_3,
182
+ refNo2: itm.ref_no_2,
183
+ acceptedBy: itm.accepted_by,
184
+ acceptedAt: itm.accepted_at,
185
+ orderCreatedBy: itm.order_created_by,
186
+ orderCreatedAt: itm.order_created_at,
187
+ pickingStart: itm.picking_start,
188
+ pickingComplete: itm.picking_complete,
189
+ packingStart: itm.packing_start,
190
+ packingComplete: itm.packing_complete,
191
+ sortingStart: itm.sorting_start,
192
+ sortingComplete: itm.sorting_complete,
193
+ loadingStart: itm.loading_start,
194
+ loadingComplete: itm.loading_complete,
195
+ product: {
196
+ id: itm.product_id,
197
+ sku: itm.product_sku,
198
+ name: itm.product_name,
199
+ description: itm.product_description,
200
+ type: itm.product_type
201
+ },
202
+ packType: itm.packing_type,
203
+ packSize: itm.packing_size,
204
+ qty: Math.abs(itm.qty),
205
+ uomValue: Math.abs(itm.uom_value),
206
+ uom: itm.uom,
207
+ unitCost: itm.unit_cost,
208
+ returnToLocationQty: itm.return_to_location_qty,
209
+ returnToLocationUomValue: itm.return_to_location_uom_value,
210
+ unitVolume: itm.unit_volume,
211
+ totalVolume: itm.total_volume,
212
+ unitNettWeight: itm.unit_nett_weight,
213
+ totalUnitNettWeight: itm.total_unit_nett_weight,
214
+ unitGrossWeight: itm.unit_gross_weight,
215
+ totalUnitGrossWeight: itm.total_unit_gross_weight,
216
+ weightUnit: itm.weight_unit,
217
+ palletId: itm.pallet_id,
218
+ cartonId: itm.carton_id,
219
+ batchId: itm.batch_id,
220
+ batchIdRef: itm.batch_id_ref,
221
+ expirationDate: itm.expiration_date,
222
+ manufactureDate: itm.manufacture_date,
223
+ pickedAt: itm.picked_at,
224
+ pickedBy: itm.picked_by,
225
+ packedAt: itm.packed_at,
226
+ packedBy: itm.packed_by,
227
+ checkedRemarkBy: itm.checked_remark_by,
228
+ checkedRemarkAt: itm.checked_remark_at,
229
+ loadedAt: itm.loaded_at,
230
+ loadedBy: itm.loaded_by,
231
+ manifestedAt: itm.manifested_at,
232
+ manifestedBy: itm.manifested_by,
233
+ exportOption: itm.export_option,
234
+ containerNo: itm.container_no,
235
+ containerSize: itm.container_size,
236
+ palletQty: itm.pallet_qty,
237
+ transportOption: itm.own_transport ? 'Own Transport' : 'Warehouse Transport',
238
+ vehicleNo: itm.vehicle_no,
239
+ driverName: itm.driver_name
240
+ }
241
+ })
242
+
243
+ return {
244
+ items,
245
+ total: total[0].count
246
+ }
247
+ } catch (error) {
248
+ throw error
249
+ }
250
+ }
251
+ }
@@ -2,9 +2,10 @@ import * as Generators from './generators'
2
2
  import * as Invitations from './invitations'
3
3
  import * as Oauth2 from './oauth2'
4
4
  import * as Synchronization from './synchronization'
5
+ import * as Reports from './reports'
5
6
 
6
- export const queries = [Synchronization.Query, Oauth2.Query]
7
+ export const queries = [Synchronization.Query, Oauth2.Query, Reports.Query]
7
8
 
8
9
  export const mutations = [Generators.Mutation, Invitations.Mutation, Synchronization.Mutation]
9
10
 
10
- export const types = [...Generators.Types, ...Synchronization.Types, ...Oauth2.Types]
11
+ export const types = [...Generators.Types, ...Synchronization.Types, ...Oauth2.Types, ...Reports.Types]
@@ -0,0 +1,8 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const InboundOrderDetailsReportList = gql`
4
+ type InboundOrderDetailsReportList {
5
+ items: [InboundOrderDetailsReport]
6
+ total: Int
7
+ }
8
+ `
@@ -0,0 +1,53 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const InboundOrderDetailsReport = gql`
4
+ type InboundOrderDetailsReport {
5
+ bizplace: Bizplace
6
+ grnNo: String
7
+ ganNo: String
8
+ deliveryOrderNo: String
9
+ refNo1: String
10
+ refNo2: String
11
+ refNo3: String
12
+ looseItem: Boolean
13
+ importCargo: Boolean
14
+ containerNo: String
15
+ containerSize: String
16
+ ownTransport: Boolean
17
+ acceptedBy: String
18
+ acceptedAt: String
19
+ orderCreatedAt: String
20
+ unloadStart: String
21
+ unloadComplete: String
22
+ putawayStart: String
23
+ putawayComplete: String
24
+ orderLineItem: Int
25
+ product: Product
26
+ purchaseOrderId: String
27
+ purchaseOrderNo: String
28
+ contactPoint: ContactPoint
29
+ packType: String
30
+ packSize: Int
31
+ qty: Int
32
+ uomValue: Float
33
+ uom: String
34
+ unitCost: Float
35
+ unitVolume: Float
36
+ totalVolume: Float
37
+ unitNettWeight: Float
38
+ totalUnitNettWeight: Float
39
+ unitGrossWeight: Float
40
+ totalUnitGrossWeight: Float
41
+ weightUnit: String
42
+ palletId: String
43
+ cartonId: String
44
+ batchId: String
45
+ batchIdRef: String
46
+ expirationDate: String
47
+ manufactureDate: String
48
+ unloadedAt: String
49
+ unloadedBy: String
50
+ putawayAt: String
51
+ putawayBy: String
52
+ }
53
+ `
@@ -0,0 +1,11 @@
1
+ import { InboundOrderDetailsReport } from './inbound-order-details-report'
2
+ import { InboundOrderDetailsReportList } from './inbound-order-details-report-list'
3
+ import { OutboundOrderDetailsReport } from './outbound-order-details-report'
4
+ import { OutboundOrderDetailsReportList } from './outbound-order-details-report-list'
5
+
6
+ export const Query = `
7
+ inboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundOrderDetailsReportList @transaction
8
+ outboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundOrderDetailsReportList @transaction
9
+ `
10
+
11
+ export const Types = [InboundOrderDetailsReport, InboundOrderDetailsReportList, OutboundOrderDetailsReport, OutboundOrderDetailsReportList]
@@ -0,0 +1,8 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const OutboundOrderDetailsReportList = gql`
4
+ type OutboundOrderDetailsReportList {
5
+ items: [OutboundOrderDetailsReport]
6
+ total: Int
7
+ }
8
+ `
@@ -0,0 +1,70 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const OutboundOrderDetailsReport = gql`
4
+ type OutboundOrderDetailsReport {
5
+ bizplace: Bizplace
6
+ doNo: String
7
+ doDeliveryDate: String
8
+ deliveryAddress: String
9
+ manifestNo: String
10
+ roNo: String
11
+ roType: String
12
+ status: String
13
+ refNo1: String
14
+ refNo2: String
15
+ refNo3: String
16
+ exportOption: Boolean
17
+ containerNo: String
18
+ containerSize: String
19
+ transportOption: String
20
+ vehicleNo: String
21
+ driverName: String
22
+ palletQty: Int
23
+ acceptedBy: String
24
+ acceptedAt: String
25
+ orderCreatedBy: String
26
+ orderCreatedAt: String
27
+ pickingStart: String
28
+ pickingComplete: String
29
+ packingStart: String
30
+ packingComplete: String
31
+ sortingStart: String
32
+ sortingComplete: String
33
+ loadingStart: String
34
+ loadingComplete: String
35
+ orderLineItem: Int
36
+ product: Product
37
+ packType: String
38
+ packSize: Int
39
+ qty: Int
40
+ uomValue: Float
41
+ returnToLocationQty: Int
42
+ returnToLocationUomValue: Float
43
+ uom: String
44
+ unitCost: Float
45
+ unitVolume: Float
46
+ totalVolume: Float
47
+ unitNettWeight: Float
48
+ totalUnitNettWeight: Float
49
+ unitGrossWeight: Float
50
+ totalUnitGrossWeight: Float
51
+ weightUnit: String
52
+ palletId: String
53
+ cartonId: String
54
+ batchId: String
55
+ batchIdRef: String
56
+ expirationDate: String
57
+ manufactureDate: String
58
+ pickedAt: String
59
+ pickedBy: String
60
+ packedAt: String
61
+ packedBy: String
62
+ checkedRemarkBy: String
63
+ checkedRemarkAt: String
64
+ loadedAt: String
65
+ loadedBy: String
66
+ manifestedAt: String
67
+ manifestedBy: String
68
+ dispatchedAt: String
69
+ }
70
+ `
@@ -19,6 +19,7 @@ export const Mutation = /* GraphQL */ `
19
19
  sellercraftPackMarketplaceOrder: Boolean @transaction
20
20
  createDatShipments: Boolean @transaction
21
21
  autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
22
+ sendEmails: Boolean @transaction
22
23
  `
23
24
 
24
25
  export const Types = [
package/server/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './graphql'
2
2
  export * from './middlewares'
3
3
  export * from './migrations'
4
+ export * from './entities'
4
5
 
5
6
  import { User } from '@things-factory/auth-base'
6
7
  import { Bizplace } from '@things-factory/biz-base'
@@ -1,3 +1,4 @@
1
1
  export * from './build-map'
2
2
  export * from './get-warehouses'
3
3
  export * from './order-no-generator'
4
+ export * from './report-query-util'