@things-factory/operato-hub 4.3.385 → 4.3.386

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.
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Query = void 0;
4
4
  const inbound_order_details_report_1 = require("./inbound-order-details-report");
5
5
  const outbound_order_details_report_1 = require("./outbound-order-details-report");
6
- exports.Query = Object.assign(Object.assign({}, inbound_order_details_report_1.inboundOrderDetailsReport), outbound_order_details_report_1.outboundOrderDetailsReport);
6
+ const shortage_report_1 = require("./shortage-report");
7
+ exports.Query = Object.assign(Object.assign(Object.assign({}, inbound_order_details_report_1.inboundOrderDetailsReport), outbound_order_details_report_1.outboundOrderDetailsReport), shortage_report_1.shortageReport);
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0E;AAC1E,mFAA4E;AAE/D,QAAA,KAAK,mCACb,wDAAyB,GACzB,0DAA0B,EAC9B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0E;AAC1E,mFAA4E;AAC5E,uDAAkD;AAErC,QAAA,KAAK,iDACb,wDAAyB,GACzB,0DAA0B,GAC1B,gCAAc,EAClB"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shortageReport = void 0;
4
+ exports.shortageReport = {
5
+ async shortageReport(_, params, context) {
6
+ try {
7
+ const { tx } = context.state;
8
+ let bizplaceFilter = { name: '', operator: '', value: '' };
9
+ let order = params.filters.find(items => items.name === 'order');
10
+ let fromDate = params.filters.find(items => items.name === 'fromDate');
11
+ let toDate = params.filters.find(items => items.name === 'toDate');
12
+ let orderNo = params.filters.find(items => items.name === 'orderNo');
13
+ let product = params.filters.find(items => items.name === 'product');
14
+ let bizplace = params.filters.find(items => items.name === 'bizplace');
15
+ if (!bizplace)
16
+ throw 'Invalid input';
17
+ let roFilter = '', queryFilter = '';
18
+ if (product) {
19
+ let productInfoValue = product.value
20
+ .toLowerCase()
21
+ .split(',')
22
+ .map(prod => {
23
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'";
24
+ })
25
+ .join(',');
26
+ roFilter += `AND (
27
+ Lower(drg.name) LIKE ANY(ARRAY[${productInfoValue}])
28
+ OR Lower(p.sku) LIKE ANY(ARRAY[${productInfoValue}])
29
+ OR Lower(p.sku) LIKE ANY(ARRAY[${productInfoValue}])
30
+ OR Lower(p.sku) LIKE ANY(ARRAY[${productInfoValue}])
31
+ OR Lower(p."name") LIKE ANY(ARRAY[${productInfoValue}])
32
+ OR Lower(p."name") LIKE ANY(ARRAY[${productInfoValue}])
33
+ OR Lower(p."name") LIKE ANY(ARRAY[${productInfoValue}])
34
+
35
+ )`;
36
+ }
37
+ if (orderNo) {
38
+ let orderValue = orderNo.value
39
+ .toLowerCase()
40
+ .split(',')
41
+ .map(prod => {
42
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'";
43
+ })
44
+ .join(',');
45
+ roFilter += `AND (
46
+ Lower(drg.name) LIKE ANY(ARRAY[${orderValue}])
47
+ OR Lower(drg.ref_no) LIKE ANY(ARRAY[${orderValue}])
48
+ OR Lower(drg.ref_no_2) LIKE ANY(ARRAY[${orderValue}])
49
+ OR Lower(drg.ref_no_3) LIKE ANY(ARRAY[${orderValue}])
50
+ )`;
51
+ }
52
+ if (bizplace) {
53
+ queryFilter += ` AND drg.bizplace_id = '${bizplace.value}'`;
54
+ }
55
+ if (!bizplaceFilter || !fromDate || !toDate)
56
+ throw 'Invalid input';
57
+ await tx.query(`
58
+ create temp table shortage_report on commit drop as (
59
+ select b."name" as "company", drg.name as "order_no",drg.ref_no, p.sku as "product_sku", p."name" as "product_name", op.release_qty as "order_quantity",
60
+ coalesce(src.av_qty,0) as available_qty, coalesce(src.av_qty - op.release_qty,0)as "Nett_Stock",
61
+ concat(drg.delivery_address_1, ' ', drg.delivery_address_2, ' ', drg.delivery_address_3, ' ', drg.delivery_address_4, ' ', drg.delivery_address_5) as "delivery_address",
62
+ drg.state,drg.city, drg.country, drg.created_at
63
+ from draft_release_goods drg
64
+ inner join bizplaces b on b.id = drg.bizplace_id
65
+ inner join order_products op on op.draft_release_good_id = drg.id
66
+ inner join products p on p.id = op.product_id
67
+ left join (
68
+ select product_id, sum(qty - locked_qty)as "av_qty" from inventories i where i.domain_id = $1
69
+ group by product_id ) src
70
+ on op.product_id = src.product_id
71
+ where drg.status = 'DRAFT'
72
+ and drg.domain_id = $1
73
+ and coalesce(src.av_qty - op.release_qty,0) <= 0
74
+ and drg.created_at >= $2
75
+ and drg.created_at <= $3
76
+ ${roFilter}
77
+ ${queryFilter}
78
+ order by drg.created_at desc
79
+ );
80
+ `, [context.state.domain.id, fromDate.value, toDate.value]);
81
+ const total = await tx.query(`
82
+ select count(*) from shortage_report
83
+ `);
84
+ const result = await tx.query(`
85
+ select * from shortage_report
86
+ offset $1 limit $2
87
+ `, [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]);
88
+ let items = result.map(itm => {
89
+ return {
90
+ bizplaceName: itm.company,
91
+ orderNo: itm.order_no,
92
+ refNo: itm.ref_no,
93
+ productSku: itm.product_sku,
94
+ productName: itm.product_name,
95
+ orderQty: itm.order_quantity,
96
+ avQty: itm.available_qty,
97
+ nettStock: itm.Nett_Stock,
98
+ deliveryAddress: itm.delivery_address,
99
+ state: itm.state,
100
+ city: itm.city,
101
+ country: itm.country,
102
+ createdAt: itm.created_at
103
+ };
104
+ });
105
+ return {
106
+ items,
107
+ total: total[0].count
108
+ };
109
+ }
110
+ catch (error) {
111
+ throw error;
112
+ }
113
+ }
114
+ };
115
+ //# sourceMappingURL=shortage-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortage-report.js","sourceRoot":"","sources":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,KAAK,GAAQ,MAAM,EAAE,CAAC,KAAK,CAAC;;OAEjC,CAAC,CAAA;YAEF,MAAM,MAAM,GAAQ,MAAM,EAAE,CAAC,KAAK,CAChC;;;OAGD,EACC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAClF,CAAA;YAED,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC3B,OAAM;oBACJ,YAAY,EAAE,GAAG,CAAC,OAAO;oBACzB,OAAO,EAAE,GAAG,CAAC,QAAQ;oBACrB,KAAK,EAAC,GAAG,CAAC,MAAM;oBAChB,UAAU,EAAE,GAAG,CAAC,WAAW;oBAC3B,WAAW,EAAE,GAAG,CAAC,YAAY;oBAC7B,QAAQ,EAAC,GAAG,CAAC,cAAc;oBAC3B,KAAK,EAAC,GAAG,CAAC,aAAa;oBACvB,SAAS,EAAC,GAAG,CAAC,UAAU;oBACxB,eAAe,EAAC,GAAG,CAAC,gBAAgB;oBACpC,KAAK,EAAC,GAAG,CAAC,KAAK;oBACf,IAAI,EAAC,GAAG,CAAC,IAAI;oBACb,OAAO,EAAC,GAAG,CAAC,OAAO;oBACnB,SAAS,EAAC,GAAG,CAAC,UAAU;iBACzB,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,KAAK;gBACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;aACtB,CAAA;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA"}
@@ -5,9 +5,19 @@ const inbound_order_details_report_1 = require("./inbound-order-details-report")
5
5
  const inbound_order_details_report_list_1 = require("./inbound-order-details-report-list");
6
6
  const outbound_order_details_report_1 = require("./outbound-order-details-report");
7
7
  const outbound_order_details_report_list_1 = require("./outbound-order-details-report-list");
8
+ const shortage_report_list_1 = require("./shortage-report-list");
9
+ const shortage_report_type_1 = require("./shortage-report-type");
8
10
  exports.Query = `
9
11
  inboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundOrderDetailsReportList @transaction
10
12
  outboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundOrderDetailsReportList @transaction
13
+ shortageReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]):ShortageReportList @transaction
11
14
  `;
12
- exports.Types = [inbound_order_details_report_1.InboundOrderDetailsReport, inbound_order_details_report_list_1.InboundOrderDetailsReportList, outbound_order_details_report_1.OutboundOrderDetailsReport, outbound_order_details_report_list_1.OutboundOrderDetailsReportList];
15
+ exports.Types = [
16
+ inbound_order_details_report_1.InboundOrderDetailsReport,
17
+ inbound_order_details_report_list_1.InboundOrderDetailsReportList,
18
+ outbound_order_details_report_1.OutboundOrderDetailsReport,
19
+ outbound_order_details_report_list_1.OutboundOrderDetailsReportList,
20
+ shortage_report_type_1.ShortageReport,
21
+ shortage_report_list_1.ShortageReportList
22
+ ];
13
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0E;AAC1E,2FAAmF;AACnF,mFAA4E;AAC5E,6FAAqF;AAExE,QAAA,KAAK,GAAG;;;CAGpB,CAAA;AAEY,QAAA,KAAK,GAAG,CAAC,wDAAyB,EAAE,iEAA6B,EAAE,0DAA0B,EAAE,mEAA8B,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0E;AAC1E,2FAAmF;AACnF,mFAA4E;AAC5E,6FAAqF;AACrF,iEAA2D;AAC3D,iEAAuD;AAE1C,QAAA,KAAK,GAAG;;;;CAIpB,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,qCAAc;IACd,yCAAkB;CACnB,CAAA"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ShortageReportList = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.ShortageReportList = (0, graphql_tag_1.default) `
9
+ type ShortageReportList {
10
+ items: [ShortageReport]
11
+ total: Int
12
+ }
13
+ `;
14
+ //# sourceMappingURL=shortage-report-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortage-report-list.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/shortage-report-list.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,kBAAkB,GAAG,IAAA,qBAAG,EAAA;;;;;CAKpC,CAAA"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ShortageReport = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.ShortageReport = (0, graphql_tag_1.default) `
9
+ type ShortageReport {
10
+ bizplaceName: String
11
+ orderNo: String
12
+ refNo: String
13
+ productSku: String
14
+ productName: String
15
+ orderQty: String
16
+ avQty: String
17
+ nettStock: String
18
+ deliveryAddress: String
19
+ state: String
20
+ city: String
21
+ country: String
22
+ createdAt: Date
23
+ }
24
+ `;
25
+ //# sourceMappingURL=shortage-report-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortage-report-type.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/shortage-report-type.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,cAAc,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;CAgBhC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-hub",
3
- "version": "4.3.385",
3
+ "version": "4.3.386",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -121,5 +121,5 @@
121
121
  "resolutions": {
122
122
  "core-js": "^3.16.0"
123
123
  },
124
- "gitHead": "2d9e6d3ebda9e7c4680d7ea22ae9ac5c6bf9f5b8"
124
+ "gitHead": "d504ae7551567b12cd2011fb1c958300159c545f"
125
125
  }
@@ -1,7 +1,9 @@
1
1
  import { inboundOrderDetailsReport } from './inbound-order-details-report'
2
2
  import { outboundOrderDetailsReport } from './outbound-order-details-report'
3
+ import { shortageReport } from './shortage-report'
3
4
 
4
5
  export const Query = {
5
6
  ...inboundOrderDetailsReport,
6
- ...outboundOrderDetailsReport
7
+ ...outboundOrderDetailsReport,
8
+ ...shortageReport
7
9
  }
@@ -0,0 +1,132 @@
1
+ import { EntityManager } from 'typeorm'
2
+
3
+ import { ListParam } from '@things-factory/shell'
4
+
5
+ export const shortageReport = {
6
+ async shortageReport(_: any, params: ListParam, context: any) {
7
+ try {
8
+ const { tx }: { tx: EntityManager } = context.state
9
+ let bizplaceFilter = { name: '', operator: '', value: '' }
10
+ let order = params.filters.find(items => items.name === 'order')
11
+ let fromDate = params.filters.find(items => items.name === 'fromDate')
12
+ let toDate = params.filters.find(items => items.name === 'toDate')
13
+ let orderNo = params.filters.find(items => items.name === 'orderNo')
14
+ let product = params.filters.find(items => items.name === 'product')
15
+ let bizplace = params.filters.find(items => items.name === 'bizplace')
16
+
17
+ if (!bizplace) throw 'Invalid input'
18
+
19
+ let roFilter = '',
20
+ queryFilter = ''
21
+
22
+ if (product) {
23
+ let productInfoValue = product.value
24
+ .toLowerCase()
25
+ .split(',')
26
+ .map(prod => {
27
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'"
28
+ })
29
+ .join(',')
30
+
31
+ roFilter += `AND (
32
+ Lower(drg.name) LIKE ANY(ARRAY[${productInfoValue}])
33
+ OR Lower(p.sku) LIKE ANY(ARRAY[${productInfoValue}])
34
+ OR Lower(p.sku) LIKE ANY(ARRAY[${productInfoValue}])
35
+ OR Lower(p.sku) LIKE ANY(ARRAY[${productInfoValue}])
36
+ OR Lower(p."name") LIKE ANY(ARRAY[${productInfoValue}])
37
+ OR Lower(p."name") LIKE ANY(ARRAY[${productInfoValue}])
38
+ OR Lower(p."name") LIKE ANY(ARRAY[${productInfoValue}])
39
+
40
+ )`
41
+ }
42
+
43
+ if (orderNo) {
44
+ let orderValue = orderNo.value
45
+ .toLowerCase()
46
+ .split(',')
47
+ .map(prod => {
48
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'"
49
+ })
50
+ .join(',')
51
+
52
+ roFilter += `AND (
53
+ Lower(drg.name) LIKE ANY(ARRAY[${orderValue}])
54
+ OR Lower(drg.ref_no) LIKE ANY(ARRAY[${orderValue}])
55
+ OR Lower(drg.ref_no_2) LIKE ANY(ARRAY[${orderValue}])
56
+ OR Lower(drg.ref_no_3) LIKE ANY(ARRAY[${orderValue}])
57
+ )`
58
+ }
59
+
60
+ if (bizplace) {
61
+ queryFilter += ` AND drg.bizplace_id = '${bizplace.value}'`
62
+ }
63
+
64
+ if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
65
+
66
+ await tx.query(
67
+ `
68
+ create temp table shortage_report on commit drop as (
69
+ select b."name" as "company", drg.name as "order_no",drg.ref_no, p.sku as "product_sku", p."name" as "product_name", op.release_qty as "order_quantity",
70
+ coalesce(src.av_qty,0) as available_qty, coalesce(src.av_qty - op.release_qty,0)as "Nett_Stock",
71
+ concat(drg.delivery_address_1, ' ', drg.delivery_address_2, ' ', drg.delivery_address_3, ' ', drg.delivery_address_4, ' ', drg.delivery_address_5) as "delivery_address",
72
+ drg.state,drg.city, drg.country, drg.created_at
73
+ from draft_release_goods drg
74
+ inner join bizplaces b on b.id = drg.bizplace_id
75
+ inner join order_products op on op.draft_release_good_id = drg.id
76
+ inner join products p on p.id = op.product_id
77
+ left join (
78
+ select product_id, sum(qty - locked_qty)as "av_qty" from inventories i where i.domain_id = $1
79
+ group by product_id ) src
80
+ on op.product_id = src.product_id
81
+ where drg.status = 'DRAFT'
82
+ and drg.domain_id = $1
83
+ and coalesce(src.av_qty - op.release_qty,0) <= 0
84
+ and drg.created_at >= $2
85
+ and drg.created_at <= $3
86
+ ${roFilter}
87
+ ${queryFilter}
88
+ order by drg.created_at desc
89
+ );
90
+ `,
91
+ [context.state.domain.id, fromDate.value, toDate.value]
92
+ )
93
+
94
+ const total: any = await tx.query(`
95
+ select count(*) from shortage_report
96
+ `)
97
+
98
+ const result: any = await tx.query(
99
+ `
100
+ select * from shortage_report
101
+ offset $1 limit $2
102
+ `,
103
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
104
+ )
105
+
106
+ let items = result.map(itm => {
107
+ return{
108
+ bizplaceName: itm.company,
109
+ orderNo: itm.order_no,
110
+ refNo:itm.ref_no,
111
+ productSku: itm.product_sku,
112
+ productName: itm.product_name,
113
+ orderQty:itm.order_quantity,
114
+ avQty:itm.available_qty,
115
+ nettStock:itm.Nett_Stock,
116
+ deliveryAddress:itm.delivery_address,
117
+ state:itm.state,
118
+ city:itm.city,
119
+ country:itm.country,
120
+ createdAt:itm.created_at
121
+ }
122
+ })
123
+
124
+ return {
125
+ items,
126
+ total: total[0].count
127
+ }
128
+ } catch (error) {
129
+ throw error
130
+ }
131
+ }
132
+ }
@@ -2,10 +2,20 @@ import { InboundOrderDetailsReport } from './inbound-order-details-report'
2
2
  import { InboundOrderDetailsReportList } from './inbound-order-details-report-list'
3
3
  import { OutboundOrderDetailsReport } from './outbound-order-details-report'
4
4
  import { OutboundOrderDetailsReportList } from './outbound-order-details-report-list'
5
+ import { ShortageReportList } from './shortage-report-list'
6
+ import { ShortageReport } from './shortage-report-type'
5
7
 
6
8
  export const Query = `
7
9
  inboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundOrderDetailsReportList @transaction
8
10
  outboundOrderDetailsReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OutboundOrderDetailsReportList @transaction
11
+ shortageReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]):ShortageReportList @transaction
9
12
  `
10
13
 
11
- export const Types = [InboundOrderDetailsReport, InboundOrderDetailsReportList, OutboundOrderDetailsReport, OutboundOrderDetailsReportList]
14
+ export const Types = [
15
+ InboundOrderDetailsReport,
16
+ InboundOrderDetailsReportList,
17
+ OutboundOrderDetailsReport,
18
+ OutboundOrderDetailsReportList,
19
+ ShortageReport,
20
+ ShortageReportList
21
+ ]
@@ -0,0 +1,8 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const ShortageReportList = gql`
4
+ type ShortageReportList {
5
+ items: [ShortageReport]
6
+ total: Int
7
+ }
8
+ `
@@ -0,0 +1,19 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const ShortageReport = gql`
4
+ type ShortageReport {
5
+ bizplaceName: String
6
+ orderNo: String
7
+ refNo: String
8
+ productSku: String
9
+ productName: String
10
+ orderQty: String
11
+ avQty: String
12
+ nettStock: String
13
+ deliveryAddress: String
14
+ state: String
15
+ city: String
16
+ country: String
17
+ createdAt: Date
18
+ }
19
+ `