@things-factory/operato-hub 4.0.21 → 4.0.22

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 (45) hide show
  1. package/dist-server/routers/api/restful-apis/unstable/add-product.js +85 -0
  2. package/dist-server/routers/api/restful-apis/unstable/add-product.js.map +1 -0
  3. package/dist-server/routers/api/restful-apis/unstable/add-replenishment-order.js +98 -0
  4. package/dist-server/routers/api/restful-apis/unstable/add-replenishment-order.js.map +1 -0
  5. package/dist-server/routers/api/restful-apis/unstable/add-transfer-order.js +77 -0
  6. package/dist-server/routers/api/restful-apis/unstable/add-transfer-order.js.map +1 -0
  7. package/dist-server/routers/api/restful-apis/unstable/application.js +28 -0
  8. package/dist-server/routers/api/restful-apis/unstable/application.js.map +1 -0
  9. package/dist-server/routers/api/restful-apis/unstable/cancel-replenishment-order.js +67 -0
  10. package/dist-server/routers/api/restful-apis/unstable/cancel-replenishment-order.js.map +1 -0
  11. package/dist-server/routers/api/restful-apis/unstable/cancel-transfer-order.js +70 -0
  12. package/dist-server/routers/api/restful-apis/unstable/cancel-transfer-order.js.map +1 -0
  13. package/dist-server/routers/api/restful-apis/unstable/confirm-inbound-order.js +98 -0
  14. package/dist-server/routers/api/restful-apis/unstable/confirm-inbound-order.js.map +1 -0
  15. package/dist-server/routers/api/restful-apis/unstable/delete-inbound-order.js +37 -0
  16. package/dist-server/routers/api/restful-apis/unstable/delete-inbound-order.js.map +1 -0
  17. package/dist-server/routers/api/restful-apis/unstable/generate-inbound-order.js +206 -0
  18. package/dist-server/routers/api/restful-apis/unstable/generate-inbound-order.js.map +1 -0
  19. package/dist-server/routers/api/restful-apis/unstable/get-product-detail.js +78 -0
  20. package/dist-server/routers/api/restful-apis/unstable/get-product-detail.js.map +1 -0
  21. package/dist-server/routers/api/restful-apis/unstable/get-product-list.js +114 -0
  22. package/dist-server/routers/api/restful-apis/unstable/get-product-list.js.map +1 -0
  23. package/dist-server/routers/api/restful-apis/unstable/get-transfer-order-detail.js +58 -0
  24. package/dist-server/routers/api/restful-apis/unstable/get-transfer-order-detail.js.map +1 -0
  25. package/dist-server/routers/api/restful-apis/unstable/get-transfer-order-list.js +124 -0
  26. package/dist-server/routers/api/restful-apis/unstable/get-transfer-order-list.js.map +1 -0
  27. package/dist-server/routers/api/restful-apis/unstable/update-replenishment-order-product.js +76 -0
  28. package/dist-server/routers/api/restful-apis/unstable/update-replenishment-order-product.js.map +1 -0
  29. package/dist-server/routers/api/restful-apis/unstable/update-replenishment-order-status.js +73 -0
  30. package/dist-server/routers/api/restful-apis/unstable/update-replenishment-order-status.js.map +1 -0
  31. package/dist-server/routers/api/restful-apis/unstable/update-transfer-order-status.js +76 -0
  32. package/dist-server/routers/api/restful-apis/unstable/update-transfer-order-status.js.map +1 -0
  33. package/dist-server/routers/api/restful-apis/unstable/utils/api-error-message.js +13 -0
  34. package/dist-server/routers/api/restful-apis/unstable/utils/api-error-message.js.map +1 -0
  35. package/dist-server/routers/api/restful-apis/unstable/utils/index.js +14 -0
  36. package/dist-server/routers/api/restful-apis/unstable/utils/index.js.map +1 -0
  37. package/dist-server/routers/api/restful-apis/v1/application.js +28 -0
  38. package/dist-server/routers/api/restful-apis/v1/application.js.map +1 -0
  39. package/dist-server/routers/api/restful-apis/v1/order.js +28 -0
  40. package/dist-server/routers/api/restful-apis/v1/order.js.map +1 -0
  41. package/dist-server/routers/api/restful-apis/v2/application.js +28 -0
  42. package/dist-server/routers/api/restful-apis/v2/application.js.map +1 -0
  43. package/dist-server/routers/api/restful-apis/v2/order.js +28 -0
  44. package/dist-server/routers/api/restful-apis/v2/order.js.map +1 -0
  45. package/package.json +54 -54
@@ -0,0 +1,206 @@
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.checkMandatoryKey = void 0;
7
+ const biz_base_1 = require("@things-factory/biz-base");
8
+ const utils_1 = require("./utils");
9
+ const typeorm_1 = require("typeorm");
10
+ const utils_2 = require("@things-factory/utils");
11
+ const product_base_1 = require("@things-factory/product-base");
12
+ const api_1 = require("@things-factory/api");
13
+ const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
14
+ const business_middleware_1 = require("../../../../middlewares/business-middleware");
15
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
16
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:generate-inbound-order');
17
+ api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/generate-inbound-order', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
18
+ const { client, warehouse: bizplace, domain } = context.state;
19
+ const { warehouseId } = context.params;
20
+ const attachments = undefined;
21
+ let bodyReq = context.request.body;
22
+ if (!warehouseId)
23
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('warehouseId'));
24
+ if (typeof bodyReq === undefined || Object.keys(bodyReq).length === 0) {
25
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('bodyReq'));
26
+ }
27
+ await checkMandatoryKey(context, bodyReq);
28
+ debug('post:/generate-inbound-order request.body', context.request.body);
29
+ //#1 to get all product list
30
+ const products = await typeorm_1.getRepository(product_base_1.Product).find({
31
+ where: {
32
+ bizplace: warehouseId,
33
+ sku: typeorm_1.In(bodyReq.orderProducts.map(orderProduct => orderProduct.product.sku))
34
+ }
35
+ });
36
+ //#2 assign product id found to order product
37
+ bodyReq.orderProducts = bodyReq.orderProducts.map(orderProduct => {
38
+ products.forEach(product => {
39
+ if (orderProduct.product.sku === product.sku) {
40
+ orderProduct.product.id = product.id;
41
+ orderProduct.packingType = product.packingType;
42
+ orderProduct.uom = product.primaryUnit;
43
+ orderProduct.uomValue = product.primaryValue;
44
+ orderProduct.totalUomValue = `${(orderProduct.uomValue * orderProduct.packQty).toFixed(2)} ${orderProduct.uom}`;
45
+ }
46
+ });
47
+ return orderProduct;
48
+ });
49
+ //#3 check if product is not found
50
+ bodyReq.orderProducts.forEach(orderProduct => {
51
+ if (!orderProduct.product.id)
52
+ throw new Error(`SKU '${orderProduct.product.sku}' is not exist`);
53
+ });
54
+ //#4 include supplier id if there's any
55
+ if (bodyReq.supplier) {
56
+ const supplierInfo = bodyReq.supplier;
57
+ const foundSupplier = await typeorm_1.getRepository(biz_base_1.ContactPoint).findOne({
58
+ where: {
59
+ domain,
60
+ bizplace: warehouseId,
61
+ name: supplierInfo.name,
62
+ companyName: supplierInfo.companyName,
63
+ email: supplierInfo.email,
64
+ accountNo: supplierInfo.accountNo
65
+ }
66
+ });
67
+ if (foundSupplier)
68
+ bodyReq.supplier = foundSupplier.id;
69
+ else
70
+ throw new Error(`supplier was not found`);
71
+ }
72
+ const args = {
73
+ arrivalNotice: Object.assign(Object.assign({}, bodyReq), { warehouseId })
74
+ };
75
+ context.body = {
76
+ result: (await client.query({
77
+ query: graphql_tag_1.default `
78
+ mutation($attachments: Upload) {
79
+ generateArrivalNotice(${utils_2.gqlBuilder.buildArgs(args)}, file:$attachments) {
80
+ name
81
+ refNo
82
+ etaDate
83
+ containerNo
84
+ ownTransport
85
+ crossDocking
86
+ releaseGood {
87
+ name
88
+ }
89
+ etaDate
90
+ looseItem
91
+ deliveryOrderNo
92
+ status
93
+ truckNo
94
+ refNo
95
+ importCargo
96
+ orderProducts {
97
+ batchId
98
+ product {
99
+ sku
100
+ name
101
+ description
102
+ packingType
103
+ type
104
+ }
105
+ packingType
106
+ uom
107
+ uomValue
108
+ packQty
109
+ totalUomValue
110
+ palletQty
111
+ }
112
+ orderVass {
113
+ vas {
114
+ name
115
+ operationGuide
116
+ operationGuideType
117
+ }
118
+ set
119
+ targetType
120
+ targetBatchId
121
+ targetProduct {
122
+ name
123
+ description
124
+ }
125
+ packingType
126
+ qty
127
+ uomValue
128
+ otherTarget
129
+ description
130
+ remark
131
+ operationGuide
132
+ }
133
+ supplier {
134
+ companyName
135
+ name
136
+ phone
137
+ email
138
+ address
139
+ }
140
+ }
141
+ }
142
+ `,
143
+ variables: {
144
+ attachments
145
+ },
146
+ context: Object.assign(Object.assign({}, context), { hasUpload: true, state: Object.assign(Object.assign({}, context.state), { bizplace,
147
+ domain, type: 'api' }) })
148
+ })).data
149
+ };
150
+ });
151
+ function checkMandatoryKey(context, params) {
152
+ var noparams = [];
153
+ if ('importCargo' in params) {
154
+ if (params.importCargo === true && params.ownTransport === false) {
155
+ context.throw(400, context.t('ownTransport must be true when importCargo is true'));
156
+ }
157
+ }
158
+ else {
159
+ noparams.push('importCargo');
160
+ }
161
+ if ('ownTransport' in params) {
162
+ if (params.ownTransport === true) {
163
+ // if (!params.hasOwnProperty('deliveryOrderNo')) {
164
+ // noparams.push('deliveryOrderNo')
165
+ // }
166
+ // if (!params.hasOwnProperty('truckNo')) {
167
+ // noparams.push('truckNo')
168
+ // }
169
+ }
170
+ }
171
+ else {
172
+ noparams.push('ownTransport');
173
+ }
174
+ if ('container' in params) {
175
+ if (params.container === true) {
176
+ if (!params.hasOwnProperty('containerNo') || !params.hasOwnProperty('containerSize')) {
177
+ noparams.push('containerInfo');
178
+ }
179
+ }
180
+ }
181
+ if ('orderProducts' in params) {
182
+ if (params.orderProducts.filter(record => !record.batchId || !record.packQty || !record.product || !record.product.sku).length)
183
+ noparams.push('orderProducts');
184
+ }
185
+ if ('etaDate' in params) {
186
+ const etaDate = new Date(params.etaDate);
187
+ if (isNaN(etaDate.getDate()))
188
+ context.throw(400, context.t('etaDate is invalid'));
189
+ }
190
+ if ('supplier' in params) {
191
+ const supplierInfo = params.supplier;
192
+ if (supplierInfo.name == null)
193
+ throw new Error(utils_1.ERROR_MSG.REQUEST.REQUIRED_PARAMS('supplier.name'));
194
+ if (supplierInfo.companyName == null)
195
+ throw new Error(utils_1.ERROR_MSG.REQUEST.REQUIRED_PARAMS('supplier.companyName'));
196
+ if (supplierInfo.email == null)
197
+ throw new Error(utils_1.ERROR_MSG.REQUEST.REQUIRED_PARAMS('supplier.email'));
198
+ if (supplierInfo.accountNo == null)
199
+ throw new Error(utils_1.ERROR_MSG.REQUEST.REQUIRED_PARAMS('supplier.accountNo'));
200
+ }
201
+ if (noparams.length > 0) {
202
+ throw new Error(utils_1.ERROR_MSG.REQUEST.REQUIRED_PARAMS(noparams.join(', ')));
203
+ }
204
+ }
205
+ exports.checkMandatoryKey = checkMandatoryKey;
206
+ //# sourceMappingURL=generate-inbound-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-inbound-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/generate-inbound-order.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,mCAAmC;AACnC,qCAA2C;AAC3C,iDAAkD;AAClD,+DAAsD;AACtD,6CAAgE;AAChE,uFAAkF;AAClF,qFAAgF;AAChF,8DAA6B;AAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wEAAwE,CAAC,CAAA;AAExG,sBAAM,CAAC,IAAI,CAAC,yDAAyD,EAAE,wCAAkB,EAAE,0CAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,WAAW,GAAG,SAAS,CAAA;IAC7B,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAClC,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAE/E,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACrE,MAAM,IAAI,KAAK,CA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,SAAS,IAAI,MAAM,EAAE;QACvB,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAExC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAA;KAClF;IAED,IAAI,UAAU,IAAI,MAAM,EAAE;QACxB,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAA;QACpC,IAAI,YAAY,CAAC,IAAI,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAA;QAClG,IAAI,YAAY,CAAC,WAAW,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAA;QAChH,IAAI,YAAY,CAAC,KAAK,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAA;QACpG,IAAI,YAAY,CAAC,SAAS,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAA;KAC7G;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KACxE;AACH,CAAC;AA1DD,8CA0DC"}
@@ -0,0 +1,78 @@
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
+ const utils_1 = require("./utils");
7
+ const api_1 = require("@things-factory/api");
8
+ const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
9
+ const business_middleware_1 = require("../../../../middlewares/business-middleware");
10
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
11
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-product-detail');
12
+ api_1.restfulApiRouter.get('/unstable/warehouse/:warehouseId/get-product-detail', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
13
+ const { client, warehouse: bizplace, domain } = context.state;
14
+ const { warehouseId } = context.params;
15
+ const { skuId } = context.query;
16
+ if (!warehouseId)
17
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('warehouseId'));
18
+ if (!skuId)
19
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('skuId'));
20
+ let filters = [
21
+ {
22
+ name: 'sku',
23
+ operator: 'i_like',
24
+ value: skuId
25
+ }
26
+ ];
27
+ context.body = {
28
+ result: (await client.query({
29
+ query: graphql_tag_1.default `
30
+ query($filters: [Filter]) {
31
+ products(filters: $filters) {
32
+ items {
33
+ sku
34
+ name
35
+ description
36
+ productRef {
37
+ name
38
+ description
39
+ }
40
+ childProducts {
41
+ name
42
+ description
43
+ }
44
+ bundleQty
45
+ packingType
46
+ type
47
+ expirationPeriod
48
+ weightUnit
49
+ weight
50
+ density
51
+ lengthUnit
52
+ width
53
+ depth
54
+ height
55
+ auxUnit1
56
+ auxValue1
57
+ auxUnit2
58
+ auxValue2
59
+ auxUnit3
60
+ auxValue3
61
+ updater {
62
+ name
63
+ description
64
+ }
65
+ updatedAt
66
+ }
67
+ }
68
+ }
69
+ `,
70
+ variables: {
71
+ filters
72
+ },
73
+ context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { bizplace,
74
+ domain }) })
75
+ })).data
76
+ };
77
+ });
78
+ //# sourceMappingURL=get-product-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-product-detail.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-product-detail.ts"],"names":[],"mappings":";;;;;AAAA,mCAAmC;AACnC,6CAAgE;AAChE,uFAAkF;AAClF,qFAAgF;AAChF,8DAA6B;AAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oEAAoE,CAAC,CAAA;AAEpG,sBAAM,CAAC,GAAG,CAAC,qDAAqD,EAAE,wCAAkB,EAAE,0CAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACjI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE/B,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAC/E,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;IAEnE,IAAI,OAAO,GAAQ;QACjB;YACE,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,KAAK;SACb;KACF,CAAA;IAED,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,CACN,MAAM,MAAM,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,qBAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAwCT;YACD,SAAS,EAAE;gBACT,OAAO;aACR;YACD,OAAO,kCACF,OAAO,KACV,KAAK,kCACA,OAAO,CAAC,KAAK,KAChB,QAAQ;oBACR,MAAM,MAET;SACK,CAAC,CACV,CAAC,IAAI;KACP,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,114 @@
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.validatePagination = exports.validateFilters = void 0;
7
+ const utils_1 = require("./utils");
8
+ const api_1 = require("@things-factory/api");
9
+ const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
10
+ const business_middleware_1 = require("../../../../middlewares/business-middleware");
11
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
12
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-product-list');
13
+ api_1.restfulApiRouter.get('/unstable/warehouse/:warehouseId/get-product-list', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
14
+ const { client, warehouse: bizplace, domain } = context.state;
15
+ const { warehouseId } = context.params;
16
+ let { skuId, name, paginationEntriesPerPage, paginationOffset } = context.query;
17
+ if (!warehouseId)
18
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('warehouseId'));
19
+ let filters = [{ name: 'bizplace_id', operator: 'in', value: [warehouseId] }];
20
+ let pagination = { page: 1, limit: 20 };
21
+ filters = await validateFilters(filters, skuId, name);
22
+ pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset);
23
+ context.body = {
24
+ result: (await client.query({
25
+ query: graphql_tag_1.default `
26
+ query($filters: [Filter], $pagination: Pagination, $sortings: [Sorting]) {
27
+ products(filters: $filters, pagination: $pagination, sortings: $sortings) {
28
+ items {
29
+ sku
30
+ name
31
+ description
32
+ productRef {
33
+ name
34
+ description
35
+ }
36
+ childProducts {
37
+ name
38
+ description
39
+ }
40
+ bundleQty
41
+ packingType
42
+ type
43
+ expirationPeriod
44
+ weightUnit
45
+ weight
46
+ density
47
+ lengthUnit
48
+ width
49
+ depth
50
+ height
51
+ auxUnit1
52
+ auxValue1
53
+ auxUnit2
54
+ auxValue2
55
+ auxUnit3
56
+ auxValue3
57
+ updater {
58
+ name
59
+ description
60
+ }
61
+ updatedAt
62
+ }
63
+ total
64
+ }
65
+ }
66
+ `,
67
+ variables: {
68
+ filters,
69
+ pagination,
70
+ sortings: [{ name: 'sku', desc: false }]
71
+ },
72
+ context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { bizplace,
73
+ domain }) })
74
+ })).data
75
+ };
76
+ });
77
+ async function validateFilters(filters, skuId, name) {
78
+ if (skuId && skuId !== '')
79
+ filters = [...filters, { name: 'sku', operator: 'i_like', value: skuId }];
80
+ if (name && name !== '')
81
+ filters = [...filters, { name: 'name', operator: 'i_like', value: name }];
82
+ return filters;
83
+ }
84
+ exports.validateFilters = validateFilters;
85
+ async function validatePagination(context, pagination, entries, offset) {
86
+ if (!entries)
87
+ entries = '';
88
+ if (!offset)
89
+ offset = '';
90
+ if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {
91
+ entries = parseInt(entries);
92
+ offset = parseInt(offset);
93
+ if (offset < 1)
94
+ context.throw(400, context.t('paginationOffset cannot be less than 1'));
95
+ else if (entries < 1)
96
+ context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'));
97
+ else if (entries > 100)
98
+ context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'));
99
+ else
100
+ pagination = Object.assign(Object.assign({}, pagination), { page: offset, limit: entries });
101
+ }
102
+ else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {
103
+ entries = parseInt(entries);
104
+ if (entries < 1)
105
+ context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'));
106
+ else if (entries > 100)
107
+ context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'));
108
+ else
109
+ pagination = Object.assign(Object.assign({}, pagination), { limit: entries });
110
+ }
111
+ return pagination;
112
+ }
113
+ exports.validatePagination = validatePagination;
114
+ //# sourceMappingURL=get-product-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-product-list.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-product-list.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmC;AACnC,6CAAgE;AAChE,uFAAkF;AAClF,qFAAgF;AAChF,8DAA6B;AAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,kEAAkE,CAAC,CAAA;AAElG,sBAAM,CAAC,GAAG,CAAC,mDAAmD,EAAE,wCAAkB,EAAE,0CAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC/H,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE/E,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAE/E,IAAI,OAAO,GAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAClF,IAAI,UAAU,GAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IAE5C,OAAO,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IACrD,UAAU,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,CAAC,CAAA;IAEtG,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,CACN,M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AG,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC3B,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;QAEzB,IAAI,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAA;aAClF,IAAI,OAAO,GAAG,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAA;aAChG,IAAI,OAAO,GAAG,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAA;;YACpG,UAAU,mCAAQ,UAAU,KAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAE,CAAA;KAClE;SAAM,IAAI,OAAO,KAAK,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE;QACvE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;QAE3B,IAAI,OAAO,GAAG,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAA;aAC3F,IAAI,OAAO,GAAG,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAA;;YACpG,UAAU,mCAAQ,UAAU,KAAE,KAAK,EAAE,OAAO,GAAE,CAAA;KACpD;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AArBD,gDAqBC"}
@@ -0,0 +1,58 @@
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
+ const utils_1 = require("./utils");
7
+ const api_1 = require("@things-factory/api");
8
+ const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
9
+ const business_middleware_1 = require("../../../../middlewares/business-middleware");
10
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
11
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-transfer-order-detail');
12
+ api_1.restfulApiRouter.get('/unstable/warehouse/:warehouseId/get-transfer-order-detail', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
13
+ const { client, warehouse: bizplace, domain } = context.state;
14
+ const { warehouseId } = context.params;
15
+ const { transferOrderNo } = context.query;
16
+ debug('query-params', context.query);
17
+ if (!warehouseId)
18
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('warehouseId'));
19
+ if (!transferOrderNo)
20
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('transferOrderNo'));
21
+ context.body = {
22
+ result: (await client.query({
23
+ query: graphql_tag_1.default `
24
+ query($transferOrderNo: String!) {
25
+ transferOrder(name: $transferOrderNo) {
26
+ name
27
+ bizplace {
28
+ name
29
+ }
30
+ issuedDate
31
+ refNo
32
+ remark
33
+ orderInventories {
34
+ inventory {
35
+ palletId
36
+ }
37
+ product {
38
+ sku
39
+ name
40
+ }
41
+ batchId
42
+ releaseQty
43
+ remark
44
+ status
45
+ }
46
+ status
47
+ }
48
+ }
49
+ `,
50
+ variables: {
51
+ transferOrderNo
52
+ },
53
+ context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { bizplace,
54
+ domain }) })
55
+ })).data
56
+ };
57
+ });
58
+ //# sourceMappingURL=get-transfer-order-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-transfer-order-detail.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-transfer-order-detail.ts"],"names":[],"mappings":";;;;;AAAA,mCAAmC;AACnC,6CAAgE;AAChE,uFAAkF;AAClF,qFAAgF;AAChF,8DAA6B;AAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2EAA2E,CAAC,CAAA;AAE3G,sBAAM,CAAC,GAAG,CAAC,4DAA4D,EAAE,wCAAkB,EAAE,0CAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACxI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAEzC,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IAEpC,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAC/E,IAAI,CAAC,eAAe;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;IAEvF,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,CACN,MAAM,MAAM,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,qBAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;SA0BT;YACD,SAAS,EAAE;gBACT,eAAe;aAChB;YACD,OAAO,kCACF,OAAO,KACV,KAAK,kCACA,OAAO,CAAC,KAAK,KAChB,QAAQ;oBACR,MAAM,MAET;SACK,CAAC,CACV,CAAC,IAAI;KACP,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,124 @@
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.validatePagination = exports.validateFilters = void 0;
7
+ const utils_1 = require("./utils");
8
+ const api_1 = require("@things-factory/api");
9
+ const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
10
+ const business_middleware_1 = require("../../../../middlewares/business-middleware");
11
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
12
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-transfer-order-list');
13
+ api_1.restfulApiRouter.get('/unstable/warehouse/:warehouseId/get-transfer-order-list', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
14
+ const { client, warehouse: bizplace, domain } = context.state;
15
+ const { warehouseId } = context.params;
16
+ let { fromDate, toDate, paginationEntriesPerPage, paginationOffset } = context.query;
17
+ if (!warehouseId)
18
+ throw new Error(utils_1.ERROR_MSG.REQUEST.BAD_REQUEST('warehouseId'));
19
+ let filters = [{ name: 'bizplace', operator: 'in', value: [warehouseId], relation: true }];
20
+ let pagination = { page: 1, limit: 20 };
21
+ filters = await validateFilters(context, filters, fromDate, toDate);
22
+ pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset);
23
+ context.body = {
24
+ result: (await client.query({
25
+ query: graphql_tag_1.default `
26
+ query($filters: [Filter], $pagination: Pagination, $sortings: [Sorting]) {
27
+ transferOrders(filters: $filters, pagination: $pagination, sortings: $sortings) {
28
+ items {
29
+ name
30
+ issuedDate
31
+ status
32
+ refNo
33
+ remark
34
+ ownTransport
35
+ # orderInventories {
36
+ # name
37
+ # inventory {
38
+ # palletId
39
+ # # batchExp
40
+ # }
41
+ # releaseQty
42
+ # releaseUomValue
43
+ # batchId
44
+ # status
45
+ # remark
46
+ # }
47
+ createdAt
48
+ updatedAt
49
+ updater {
50
+ name
51
+ }
52
+ }
53
+ total
54
+ }
55
+ }
56
+ `,
57
+ variables: {
58
+ filters,
59
+ pagination,
60
+ sortings: [{ name: 'createdAt', desc: true }]
61
+ },
62
+ context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { bizplace,
63
+ domain }) })
64
+ })).data
65
+ };
66
+ });
67
+ async function validateFilters(context, filters, fromDate, toDate) {
68
+ if (fromDate && fromDate !== '') {
69
+ fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`);
70
+ if (fromDate instanceof Date && !isNaN(fromDate.getTime()))
71
+ fromDate = fromDate.toLocaleString();
72
+ else
73
+ context.throw(400, context.t('fromDate is invalid'));
74
+ }
75
+ else
76
+ fromDate = '';
77
+ if (toDate && toDate !== '') {
78
+ toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`);
79
+ if (toDate instanceof Date && !isNaN(toDate.getTime()))
80
+ toDate = toDate.toLocaleString();
81
+ else
82
+ context.throw(400, context.t('toDate is invalid'));
83
+ }
84
+ else
85
+ toDate = '';
86
+ if (fromDate !== '' && toDate !== '')
87
+ filters = [...filters, { name: 'createdAt', operator: 'between', value: [fromDate, toDate] }];
88
+ else if (fromDate !== '' && toDate === '')
89
+ filters = [...filters, { name: 'createdAt', operator: 'gte', value: fromDate }];
90
+ else if (fromDate === '' && toDate !== '')
91
+ filters = [...filters, { name: 'createdAt', operator: 'lte', value: toDate }];
92
+ return filters;
93
+ }
94
+ exports.validateFilters = validateFilters;
95
+ async function validatePagination(context, pagination, entries, offset) {
96
+ if (!entries)
97
+ entries = '';
98
+ if (!offset)
99
+ offset = '';
100
+ if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {
101
+ entries = parseInt(entries);
102
+ offset = parseInt(offset);
103
+ if (offset < 1)
104
+ context.throw(400, context.t('paginationOffset cannot be less than 1'));
105
+ else if (entries < 1)
106
+ context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'));
107
+ else if (entries > 100)
108
+ context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'));
109
+ else
110
+ pagination = Object.assign(Object.assign({}, pagination), { page: offset, limit: entries });
111
+ }
112
+ else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {
113
+ entries = parseInt(entries);
114
+ if (entries < 1)
115
+ context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'));
116
+ else if (entries > 100)
117
+ context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'));
118
+ else
119
+ pagination = Object.assign(Object.assign({}, pagination), { limit: entries });
120
+ }
121
+ return pagination;
122
+ }
123
+ exports.validatePagination = validatePagination;
124
+ //# sourceMappingURL=get-transfer-order-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-transfer-order-list.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-transfer-order-list.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmC;AACnC,6CAAgE;AAChE,uFAAkF;AAClF,qFAAgF;AAChF,8DAA6B;AAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,yEAAyE,CAAC,CAAA;AAEzG,sBAAM,CAAC,GAAG,CAAC,0DAA0D,EAAE,wCAAkB,EAAE,0CAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAEpF,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAS,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAE/E,IAAI,OAAO,GAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/F,IAAI,UAAU,GAAQ,EAAE,IAA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