@things-factory/operato-hub 4.3.2 → 4.4.0-alpha.0
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.
- package/client/pages/constants/setting.js +0 -1
- package/config.development.js +49 -0
- package/dist-server/controllers/bizplace-initializer/dataset/codes.js +0 -9
- package/dist-server/controllers/bizplace-initializer/dataset/codes.js.map +1 -1
- package/dist-server/controllers/bizplace-initializer/dataset/index.js +5 -1
- package/dist-server/controllers/bizplace-initializer/dataset/index.js.map +1 -1
- package/dist-server/controllers/bizplace-initializer/dataset/settings.js +0 -10
- package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +1 -1
- package/dist-server/controllers/bizplace-initializer/index.js +5 -1
- package/dist-server/controllers/bizplace-initializer/index.js.map +1 -1
- package/dist-server/controllers/company-initializer/index.js +5 -1
- package/dist-server/controllers/company-initializer/index.js.map +1 -1
- package/dist-server/graphql/index.js +5 -1
- package/dist-server/graphql/index.js.map +1 -1
- package/dist-server/graphql/resolvers/index.js +5 -1
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/types/index.js +5 -1
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/index.js +5 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js +75 -85
- package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +35 -147
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/index.js +0 -1
- package/dist-server/routers/api/restful-apis/unstable/index.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js +75 -85
- package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/add-release-order.js +34 -146
- package/dist-server/routers/api/restful-apis/v1/add-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/index.js +0 -1
- package/dist-server/routers/api/restful-apis/v1/index.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js +75 -85
- package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v2/add-release-order.js +34 -149
- package/dist-server/routers/api/restful-apis/v2/add-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v2/index.js +0 -1
- package/dist-server/routers/api/restful-apis/v2/index.js.map +1 -1
- package/dist-server/routers/business/index.js +5 -1
- package/dist-server/routers/business/index.js.map +1 -1
- package/dist-server/utils/index.js +5 -1
- package/dist-server/utils/index.js.map +1 -1
- package/package.json +54 -54
- package/server/controllers/bizplace-initializer/dataset/codes.ts +0 -9
- package/server/controllers/bizplace-initializer/dataset/settings.ts +0 -10
- package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +85 -97
- package/server/routers/api/restful-apis/unstable/add-release-order.ts +28 -211
- package/server/routers/api/restful-apis/unstable/index.ts +0 -1
- package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +85 -97
- package/server/routers/api/restful-apis/v1/add-release-order.ts +26 -209
- package/server/routers/api/restful-apis/v1/index.ts +0 -1
- package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +85 -97
- package/server/routers/api/restful-apis/v2/add-release-order.ts +26 -212
- package/server/routers/api/restful-apis/v2/index.ts +0 -1
- package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js +0 -171
- package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v1/add-draft-release-order.js +0 -171
- package/dist-server/routers/api/restful-apis/v1/add-draft-release-order.js.map +0 -1
- package/dist-server/routers/api/restful-apis/v2/add-draft-release-order.js +0 -171
- package/dist-server/routers/api/restful-apis/v2/add-draft-release-order.js.map +0 -1
- package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +0 -196
- package/server/routers/api/restful-apis/v1/add-draft-release-order.ts +0 -196
- package/server/routers/api/restful-apis/v2/add-draft-release-order.ts +0 -196
|
@@ -1,171 +0,0 @@
|
|
|
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 graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const typeorm_1 = require("typeorm");
|
|
9
|
-
const api_1 = require("@things-factory/api");
|
|
10
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
11
|
-
const business_middleware_1 = require("../../../../middlewares/business-middleware");
|
|
12
|
-
const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
|
|
13
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-draft-release-order');
|
|
14
|
-
api_1.restfulApiRouter.post('/v1/warehouse/:warehouseId/add-draft-release-order', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
|
|
15
|
-
return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
17
|
-
const { client, domain } = context.state;
|
|
18
|
-
const { warehouseId: customerBizplaceId } = context.params;
|
|
19
|
-
const { t } = context;
|
|
20
|
-
if (!customerBizplaceId)
|
|
21
|
-
context.throw(404, t('error.warehouse id not found'));
|
|
22
|
-
let bodyReq = context.request.body;
|
|
23
|
-
if (typeof bodyReq === undefined || !((_a = Object.keys(bodyReq)) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
24
|
-
context.throw(400, t('error.invalid body request format'));
|
|
25
|
-
}
|
|
26
|
-
debug('post:/add-draft-release-order request.body', bodyReq);
|
|
27
|
-
await checkMandatoryKey(context, bodyReq);
|
|
28
|
-
// get customer company's bizplace
|
|
29
|
-
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
30
|
-
where: { id: customerBizplaceId }
|
|
31
|
-
});
|
|
32
|
-
const orderInventories = bodyReq.orderInventories;
|
|
33
|
-
context.body = {
|
|
34
|
-
result: (await client.mutate({
|
|
35
|
-
mutation: (0, graphql_tag_1.default) `
|
|
36
|
-
mutation upsertDraftReleaseGood(
|
|
37
|
-
$draftReleaseGood: DraftReleaseGoodPatch!
|
|
38
|
-
$orderProducts: [OrderProductPatch!]!
|
|
39
|
-
$files: [Upload!]
|
|
40
|
-
) {
|
|
41
|
-
upsertDraftReleaseGood(
|
|
42
|
-
draftReleaseGood: $draftReleaseGood
|
|
43
|
-
orderProducts: $orderProducts
|
|
44
|
-
files: $files
|
|
45
|
-
) {
|
|
46
|
-
id
|
|
47
|
-
name
|
|
48
|
-
refNo
|
|
49
|
-
refNo2
|
|
50
|
-
refNo3
|
|
51
|
-
status
|
|
52
|
-
truckNo
|
|
53
|
-
ownTransport
|
|
54
|
-
marketplaceOrderStatus
|
|
55
|
-
billingAddress
|
|
56
|
-
deliveryAddress1
|
|
57
|
-
deliveryAddress2
|
|
58
|
-
deliveryAddress3
|
|
59
|
-
deliveryAddress4
|
|
60
|
-
deliveryAddress5
|
|
61
|
-
attentionTo
|
|
62
|
-
attentionCompany
|
|
63
|
-
city
|
|
64
|
-
state
|
|
65
|
-
postalCode
|
|
66
|
-
country
|
|
67
|
-
phone1
|
|
68
|
-
phone2
|
|
69
|
-
email
|
|
70
|
-
type
|
|
71
|
-
exportOption
|
|
72
|
-
releaseDate
|
|
73
|
-
collectionOrderNo
|
|
74
|
-
bizplace {
|
|
75
|
-
name
|
|
76
|
-
}
|
|
77
|
-
orderProducts {
|
|
78
|
-
product {
|
|
79
|
-
sku
|
|
80
|
-
name
|
|
81
|
-
description
|
|
82
|
-
}
|
|
83
|
-
packingType
|
|
84
|
-
packingSize
|
|
85
|
-
releaseQty
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`,
|
|
90
|
-
variables: {
|
|
91
|
-
draftReleaseGood: {
|
|
92
|
-
bizplace: {
|
|
93
|
-
id: customerBizplace.id
|
|
94
|
-
},
|
|
95
|
-
courierOption: bodyReq.courierOption,
|
|
96
|
-
collectionOrderNo: bodyReq.collectionOrderNo,
|
|
97
|
-
exportOption: bodyReq.exportOption,
|
|
98
|
-
ownTransport: bodyReq.ownTransport,
|
|
99
|
-
packingOption: bodyReq.packingOption,
|
|
100
|
-
refNo: bodyReq.refNo,
|
|
101
|
-
refNo2: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo2,
|
|
102
|
-
refNo3: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo3,
|
|
103
|
-
releaseDate: bodyReq.releaseDate,
|
|
104
|
-
type: bodyReq.type,
|
|
105
|
-
marketplaceOrderStatus: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.marketplaceOrderStatus,
|
|
106
|
-
remark: (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.remark) || null,
|
|
107
|
-
billingAddress: ((_b = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.billTo) === null || _b === void 0 ? void 0 : _b.billingAddress) || null,
|
|
108
|
-
deliveryAddress1: ((_c = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _c === void 0 ? void 0 : _c.deliveryAddress1) || null,
|
|
109
|
-
deliveryAddress2: ((_d = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _d === void 0 ? void 0 : _d.deliveryAddress2) || null,
|
|
110
|
-
deliveryAddress3: ((_e = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _e === void 0 ? void 0 : _e.deliveryAddress3) || null,
|
|
111
|
-
deliveryAddress4: ((_f = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _f === void 0 ? void 0 : _f.deliveryAddress4) || null,
|
|
112
|
-
deliveryAddress5: ((_g = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _g === void 0 ? void 0 : _g.deliveryAddress5) || null,
|
|
113
|
-
attentionTo: ((_h = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _h === void 0 ? void 0 : _h.attentionTo) || null,
|
|
114
|
-
attentionCompany: ((_j = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _j === void 0 ? void 0 : _j.attentionCompany) || null,
|
|
115
|
-
city: ((_k = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _k === void 0 ? void 0 : _k.city) || null,
|
|
116
|
-
state: ((_l = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _l === void 0 ? void 0 : _l.state) || null,
|
|
117
|
-
postalCode: ((_m = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _m === void 0 ? void 0 : _m.postalCode) || null,
|
|
118
|
-
country: ((_o = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _o === void 0 ? void 0 : _o.country) || null,
|
|
119
|
-
phone1: ((_p = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _p === void 0 ? void 0 : _p.phone1) || null,
|
|
120
|
-
phone2: ((_q = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _q === void 0 ? void 0 : _q.phone2) || null,
|
|
121
|
-
email: ((_r = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _r === void 0 ? void 0 : _r.email) || null
|
|
122
|
-
},
|
|
123
|
-
orderProducts: orderInventories,
|
|
124
|
-
files: []
|
|
125
|
-
},
|
|
126
|
-
context: Object.assign(Object.assign({}, context), { hasUpload: true, state: Object.assign(Object.assign({}, context.state), { customerBizplace,
|
|
127
|
-
domain, type: 'api' }) })
|
|
128
|
-
})).data
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
async function checkMandatoryKey(context, params) {
|
|
133
|
-
let noparams = ['releaseDate', 'exportOption'].filter(param => !(param in params));
|
|
134
|
-
if ('ownTransport' in params) {
|
|
135
|
-
if (params.ownTransport == true) {
|
|
136
|
-
if (!params.hasOwnProperty('collectionOrderNo')) {
|
|
137
|
-
noparams.push('collectionOrderNo');
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
noparams.push('ownTransport');
|
|
143
|
-
}
|
|
144
|
-
if ('exportOption' in params) {
|
|
145
|
-
if (params.exportOption === true) {
|
|
146
|
-
if (params.exportOption.filter(record => !record.containerNo || !record.containerArrivalDate || !record.containerLeavingDate || !record.shipName).length) {
|
|
147
|
-
noparams.push('exportOption');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if ('orderInventories' in params) {
|
|
152
|
-
params.orderInventories.forEach((param, key) => {
|
|
153
|
-
let noSubParams = [];
|
|
154
|
-
if (!(param === null || param === void 0 ? void 0 : param.releaseQty))
|
|
155
|
-
noSubParams.push('releaseQty');
|
|
156
|
-
if (!(param === null || param === void 0 ? void 0 : param.product))
|
|
157
|
-
noSubParams.push('product');
|
|
158
|
-
if (noSubParams === null || noSubParams === void 0 ? void 0 : noSubParams.length)
|
|
159
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }));
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
noparams.push('orderInventories');
|
|
164
|
-
}
|
|
165
|
-
if (noparams === null || noparams === void 0 ? void 0 : noparams.length) {
|
|
166
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }));
|
|
167
|
-
}
|
|
168
|
-
return params;
|
|
169
|
-
}
|
|
170
|
-
exports.checkMandatoryKey = checkMandatoryKey;
|
|
171
|
-
//# sourceMappingURL=add-draft-release-order.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-draft-release-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-draft-release-order.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAC7B,qCAAsD;AAEtD,6CAAgE;AAChE,uDAAmD;AAGnD,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,yEAAyE,CAAC,CAAA;AAEzG,sBAAM,CAAC,IAAI,CACT,oDAAoD,EACpD,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,OAAO,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;;QACnE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QACxC,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;QAC1D,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;QAErB,IAAI,CAAC,kBAAkB;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAA;QAE9E,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;QAClC,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;YACjE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;SAC3D;QACD,KAAK,CAAC,4CAA4C,EAAE,OAAO,CAAC,CAAA;QAC5D,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAEzC,kCAAkC;QAClC,MAAM,gBAAgB,GAAa,M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AAc,CAAC,CAAA;aAC9B;SACF;KACF;IAED,IAAI,kBAAkB,IAAI,MAAM,EAAE;QAChC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7C,IAAI,WAAW,GAAG,EAAE,CAAA;YAEpB,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,CAAA;gBAAE,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAEtD,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAA;gBAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAEhD,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM;gBACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QACzG,CAAC,CAAC,CAAA;KACH;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;KAClC;IAED,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AA9CD,8CA8CC"}
|
|
@@ -1,171 +0,0 @@
|
|
|
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 graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const typeorm_1 = require("typeorm");
|
|
9
|
-
const api_1 = require("@things-factory/api");
|
|
10
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
11
|
-
const business_middleware_1 = require("../../../../middlewares/business-middleware");
|
|
12
|
-
const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
|
|
13
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-draft-release-order');
|
|
14
|
-
api_1.restfulApiRouter.post('/v2/warehouse/:warehouseId/add-draft-release-order', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
|
|
15
|
-
return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
17
|
-
const { client, domain } = context.state;
|
|
18
|
-
const { warehouseId: customerBizplaceId } = context.params;
|
|
19
|
-
const { t } = context;
|
|
20
|
-
if (!customerBizplaceId)
|
|
21
|
-
context.throw(404, t('error.warehouse id not found'));
|
|
22
|
-
let bodyReq = context.request.body;
|
|
23
|
-
if (typeof bodyReq === undefined || !((_a = Object.keys(bodyReq)) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
24
|
-
context.throw(400, t('error.invalid body request format'));
|
|
25
|
-
}
|
|
26
|
-
debug('post:/add-draft-release-order request.body', bodyReq);
|
|
27
|
-
await checkMandatoryKey(context, bodyReq);
|
|
28
|
-
// get customer company's bizplace
|
|
29
|
-
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
30
|
-
where: { id: customerBizplaceId }
|
|
31
|
-
});
|
|
32
|
-
const orderInventories = bodyReq.orderInventories;
|
|
33
|
-
context.body = {
|
|
34
|
-
result: (await client.mutate({
|
|
35
|
-
mutation: (0, graphql_tag_1.default) `
|
|
36
|
-
mutation upsertDraftReleaseGood(
|
|
37
|
-
$draftReleaseGood: DraftReleaseGoodPatch!
|
|
38
|
-
$orderProducts: [OrderProductPatch!]!
|
|
39
|
-
$files: [Upload!]
|
|
40
|
-
) {
|
|
41
|
-
upsertDraftReleaseGood(
|
|
42
|
-
draftReleaseGood: $draftReleaseGood
|
|
43
|
-
orderProducts: $orderProducts
|
|
44
|
-
files: $files
|
|
45
|
-
) {
|
|
46
|
-
id
|
|
47
|
-
name
|
|
48
|
-
refNo
|
|
49
|
-
refNo2
|
|
50
|
-
refNo3
|
|
51
|
-
status
|
|
52
|
-
truckNo
|
|
53
|
-
ownTransport
|
|
54
|
-
marketplaceOrderStatus
|
|
55
|
-
billingAddress
|
|
56
|
-
deliveryAddress1
|
|
57
|
-
deliveryAddress2
|
|
58
|
-
deliveryAddress3
|
|
59
|
-
deliveryAddress4
|
|
60
|
-
deliveryAddress5
|
|
61
|
-
attentionTo
|
|
62
|
-
attentionCompany
|
|
63
|
-
city
|
|
64
|
-
state
|
|
65
|
-
postalCode
|
|
66
|
-
country
|
|
67
|
-
phone1
|
|
68
|
-
phone2
|
|
69
|
-
email
|
|
70
|
-
type
|
|
71
|
-
exportOption
|
|
72
|
-
releaseDate
|
|
73
|
-
collectionOrderNo
|
|
74
|
-
bizplace {
|
|
75
|
-
name
|
|
76
|
-
}
|
|
77
|
-
orderProducts {
|
|
78
|
-
product {
|
|
79
|
-
sku
|
|
80
|
-
name
|
|
81
|
-
description
|
|
82
|
-
}
|
|
83
|
-
packingType
|
|
84
|
-
packingSize
|
|
85
|
-
releaseQty
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`,
|
|
90
|
-
variables: {
|
|
91
|
-
draftReleaseGood: {
|
|
92
|
-
bizplace: {
|
|
93
|
-
id: customerBizplace.id
|
|
94
|
-
},
|
|
95
|
-
courierOption: bodyReq.courierOption,
|
|
96
|
-
collectionOrderNo: bodyReq.collectionOrderNo,
|
|
97
|
-
exportOption: bodyReq.exportOption,
|
|
98
|
-
ownTransport: bodyReq.ownTransport,
|
|
99
|
-
packingOption: bodyReq.packingOption,
|
|
100
|
-
refNo: bodyReq.refNo,
|
|
101
|
-
refNo2: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo2,
|
|
102
|
-
refNo3: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo3,
|
|
103
|
-
releaseDate: bodyReq.releaseDate,
|
|
104
|
-
type: bodyReq.type,
|
|
105
|
-
marketplaceOrderStatus: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.marketplaceOrderStatus,
|
|
106
|
-
remark: (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.remark) || null,
|
|
107
|
-
billingAddress: ((_b = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.billTo) === null || _b === void 0 ? void 0 : _b.billingAddress) || null,
|
|
108
|
-
deliveryAddress1: ((_c = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _c === void 0 ? void 0 : _c.deliveryAddress1) || null,
|
|
109
|
-
deliveryAddress2: ((_d = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _d === void 0 ? void 0 : _d.deliveryAddress2) || null,
|
|
110
|
-
deliveryAddress3: ((_e = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _e === void 0 ? void 0 : _e.deliveryAddress3) || null,
|
|
111
|
-
deliveryAddress4: ((_f = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _f === void 0 ? void 0 : _f.deliveryAddress4) || null,
|
|
112
|
-
deliveryAddress5: ((_g = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _g === void 0 ? void 0 : _g.deliveryAddress5) || null,
|
|
113
|
-
attentionTo: ((_h = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _h === void 0 ? void 0 : _h.attentionTo) || null,
|
|
114
|
-
attentionCompany: ((_j = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _j === void 0 ? void 0 : _j.attentionCompany) || null,
|
|
115
|
-
city: ((_k = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _k === void 0 ? void 0 : _k.city) || null,
|
|
116
|
-
state: ((_l = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _l === void 0 ? void 0 : _l.state) || null,
|
|
117
|
-
postalCode: ((_m = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _m === void 0 ? void 0 : _m.postalCode) || null,
|
|
118
|
-
country: ((_o = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _o === void 0 ? void 0 : _o.country) || null,
|
|
119
|
-
phone1: ((_p = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _p === void 0 ? void 0 : _p.phone1) || null,
|
|
120
|
-
phone2: ((_q = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _q === void 0 ? void 0 : _q.phone2) || null,
|
|
121
|
-
email: ((_r = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _r === void 0 ? void 0 : _r.email) || null
|
|
122
|
-
},
|
|
123
|
-
orderProducts: orderInventories,
|
|
124
|
-
files: []
|
|
125
|
-
},
|
|
126
|
-
context: Object.assign(Object.assign({}, context), { hasUpload: true, state: Object.assign(Object.assign({}, context.state), { customerBizplace,
|
|
127
|
-
domain, type: 'api' }) })
|
|
128
|
-
})).data
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
async function checkMandatoryKey(context, params) {
|
|
133
|
-
let noparams = ['releaseDate', 'exportOption'].filter(param => !(param in params));
|
|
134
|
-
if ('ownTransport' in params) {
|
|
135
|
-
if (params.ownTransport == true) {
|
|
136
|
-
if (!params.hasOwnProperty('collectionOrderNo')) {
|
|
137
|
-
noparams.push('collectionOrderNo');
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
noparams.push('ownTransport');
|
|
143
|
-
}
|
|
144
|
-
if ('exportOption' in params) {
|
|
145
|
-
if (params.exportOption === true) {
|
|
146
|
-
if (params.exportOption.filter(record => !record.containerNo || !record.containerArrivalDate || !record.containerLeavingDate || !record.shipName).length) {
|
|
147
|
-
noparams.push('exportOption');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if ('orderInventories' in params) {
|
|
152
|
-
params.orderInventories.forEach((param, key) => {
|
|
153
|
-
let noSubParams = [];
|
|
154
|
-
if (!(param === null || param === void 0 ? void 0 : param.releaseQty))
|
|
155
|
-
noSubParams.push('releaseQty');
|
|
156
|
-
if (!(param === null || param === void 0 ? void 0 : param.product))
|
|
157
|
-
noSubParams.push('product');
|
|
158
|
-
if (noSubParams === null || noSubParams === void 0 ? void 0 : noSubParams.length)
|
|
159
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }));
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
noparams.push('orderInventories');
|
|
164
|
-
}
|
|
165
|
-
if (noparams === null || noparams === void 0 ? void 0 : noparams.length) {
|
|
166
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }));
|
|
167
|
-
}
|
|
168
|
-
return params;
|
|
169
|
-
}
|
|
170
|
-
exports.checkMandatoryKey = checkMandatoryKey;
|
|
171
|
-
//# sourceMappingURL=add-draft-release-order.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-draft-release-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v2/add-draft-release-order.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAC7B,qCAAsD;AAEtD,6CAAgE;AAChE,uDAAmD;AAGnD,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GA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E,UAAU,CAAA;gBAAE,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAEtD,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAA;gBAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAEhD,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM;gBACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QACzG,CAAC,CAAC,CAAA;KACH;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;KAClC;IAED,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AA9CD,8CA8CC"}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
import { EntityManager, getConnection } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
5
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
6
|
-
import { OrderInventory } from '@things-factory/sales-base'
|
|
7
|
-
|
|
8
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
9
|
-
import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
|
|
10
|
-
|
|
11
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-draft-release-order')
|
|
12
|
-
|
|
13
|
-
router.post(
|
|
14
|
-
'/unstable/warehouse/:warehouseId/add-draft-release-order',
|
|
15
|
-
businessMiddleware,
|
|
16
|
-
warehouseMiddleware,
|
|
17
|
-
async (context, next) => {
|
|
18
|
-
return await getConnection().transaction(async (tx: EntityManager) => {
|
|
19
|
-
const { client, domain } = context.state
|
|
20
|
-
const { warehouseId: customerBizplaceId } = context.params
|
|
21
|
-
const { t } = context
|
|
22
|
-
|
|
23
|
-
if (!customerBizplaceId) context.throw(404, t('error.warehouse id not found'))
|
|
24
|
-
|
|
25
|
-
let bodyReq = context.request.body
|
|
26
|
-
if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
|
|
27
|
-
context.throw(400, t('error.invalid body request format'))
|
|
28
|
-
}
|
|
29
|
-
debug('post:/add-draft-release-order request.body', bodyReq)
|
|
30
|
-
await checkMandatoryKey(context, bodyReq)
|
|
31
|
-
|
|
32
|
-
// get customer company's bizplace
|
|
33
|
-
const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
34
|
-
where: { id: customerBizplaceId }
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const orderInventories: OrderInventory[] = bodyReq.orderInventories
|
|
38
|
-
|
|
39
|
-
context.body = {
|
|
40
|
-
result: (
|
|
41
|
-
await client.mutate({
|
|
42
|
-
mutation: gql`
|
|
43
|
-
mutation upsertDraftReleaseGood(
|
|
44
|
-
$draftReleaseGood: DraftReleaseGoodPatch!
|
|
45
|
-
$orderProducts: [OrderProductPatch!]!
|
|
46
|
-
$files: [Upload!]
|
|
47
|
-
) {
|
|
48
|
-
upsertDraftReleaseGood(
|
|
49
|
-
draftReleaseGood: $draftReleaseGood
|
|
50
|
-
orderProducts: $orderProducts
|
|
51
|
-
files: $files
|
|
52
|
-
) {
|
|
53
|
-
id
|
|
54
|
-
name
|
|
55
|
-
refNo
|
|
56
|
-
refNo2
|
|
57
|
-
refNo3
|
|
58
|
-
status
|
|
59
|
-
truckNo
|
|
60
|
-
ownTransport
|
|
61
|
-
marketplaceOrderStatus
|
|
62
|
-
billingAddress
|
|
63
|
-
deliveryAddress1
|
|
64
|
-
deliveryAddress2
|
|
65
|
-
deliveryAddress3
|
|
66
|
-
deliveryAddress4
|
|
67
|
-
deliveryAddress5
|
|
68
|
-
attentionTo
|
|
69
|
-
attentionCompany
|
|
70
|
-
city
|
|
71
|
-
state
|
|
72
|
-
postalCode
|
|
73
|
-
country
|
|
74
|
-
phone1
|
|
75
|
-
phone2
|
|
76
|
-
email
|
|
77
|
-
type
|
|
78
|
-
exportOption
|
|
79
|
-
releaseDate
|
|
80
|
-
collectionOrderNo
|
|
81
|
-
bizplace {
|
|
82
|
-
name
|
|
83
|
-
}
|
|
84
|
-
orderProducts {
|
|
85
|
-
product {
|
|
86
|
-
sku
|
|
87
|
-
name
|
|
88
|
-
description
|
|
89
|
-
}
|
|
90
|
-
packingType
|
|
91
|
-
packingSize
|
|
92
|
-
releaseQty
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
`,
|
|
97
|
-
variables: {
|
|
98
|
-
draftReleaseGood: {
|
|
99
|
-
bizplace: {
|
|
100
|
-
id: customerBizplace.id
|
|
101
|
-
},
|
|
102
|
-
courierOption: bodyReq.courierOption,
|
|
103
|
-
collectionOrderNo: bodyReq.collectionOrderNo,
|
|
104
|
-
exportOption: bodyReq.exportOption,
|
|
105
|
-
ownTransport: bodyReq.ownTransport,
|
|
106
|
-
packingOption: bodyReq.packingOption,
|
|
107
|
-
refNo: bodyReq.refNo,
|
|
108
|
-
refNo2: bodyReq?.refNo2,
|
|
109
|
-
refNo3: bodyReq?.refNo3,
|
|
110
|
-
releaseDate: bodyReq.releaseDate,
|
|
111
|
-
type: bodyReq.type,
|
|
112
|
-
marketplaceOrderStatus: bodyReq?.marketplaceOrderStatus,
|
|
113
|
-
remark: bodyReq?.remark || null,
|
|
114
|
-
billingAddress: bodyReq?.billTo?.billingAddress || null,
|
|
115
|
-
deliveryAddress1: bodyReq?.deliverTo?.deliveryAddress1 || null,
|
|
116
|
-
deliveryAddress2: bodyReq?.deliverTo?.deliveryAddress2 || null,
|
|
117
|
-
deliveryAddress3: bodyReq?.deliverTo?.deliveryAddress3 || null,
|
|
118
|
-
deliveryAddress4: bodyReq?.deliverTo?.deliveryAddress4 || null,
|
|
119
|
-
deliveryAddress5: bodyReq?.deliverTo?.deliveryAddress5 || null,
|
|
120
|
-
attentionTo: bodyReq?.deliverTo?.attentionTo || null,
|
|
121
|
-
attentionCompany: bodyReq?.deliverTo?.attentionCompany || null,
|
|
122
|
-
city: bodyReq?.deliverTo?.city || null,
|
|
123
|
-
state: bodyReq?.deliverTo?.state || null,
|
|
124
|
-
postalCode: bodyReq?.deliverTo?.postalCode || null,
|
|
125
|
-
country: bodyReq?.deliverTo?.country || null,
|
|
126
|
-
phone1: bodyReq?.deliverTo?.phone1 || null,
|
|
127
|
-
phone2: bodyReq?.deliverTo?.phone2 || null,
|
|
128
|
-
email: bodyReq?.deliverTo?.email || null
|
|
129
|
-
},
|
|
130
|
-
orderProducts: orderInventories,
|
|
131
|
-
files: []
|
|
132
|
-
},
|
|
133
|
-
context: {
|
|
134
|
-
...context,
|
|
135
|
-
hasUpload: true,
|
|
136
|
-
state: {
|
|
137
|
-
...context.state,
|
|
138
|
-
customerBizplace,
|
|
139
|
-
domain,
|
|
140
|
-
type: 'api'
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
} as any)
|
|
144
|
-
).data
|
|
145
|
-
}
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
export async function checkMandatoryKey(context, params) {
|
|
151
|
-
let noparams = ['releaseDate', 'exportOption'].filter(param => !(param in params))
|
|
152
|
-
|
|
153
|
-
if ('ownTransport' in params) {
|
|
154
|
-
if (params.ownTransport == true) {
|
|
155
|
-
if (!params.hasOwnProperty('collectionOrderNo')) {
|
|
156
|
-
noparams.push('collectionOrderNo')
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
noparams.push('ownTransport')
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if ('exportOption' in params) {
|
|
164
|
-
if (params.exportOption === true) {
|
|
165
|
-
if (
|
|
166
|
-
params.exportOption.filter(
|
|
167
|
-
record =>
|
|
168
|
-
!record.containerNo || !record.containerArrivalDate || !record.containerLeavingDate || !record.shipName
|
|
169
|
-
).length
|
|
170
|
-
) {
|
|
171
|
-
noparams.push('exportOption')
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if ('orderInventories' in params) {
|
|
177
|
-
params.orderInventories.forEach((param, key) => {
|
|
178
|
-
let noSubParams = []
|
|
179
|
-
|
|
180
|
-
if (!param?.releaseQty) noSubParams.push('releaseQty')
|
|
181
|
-
|
|
182
|
-
if (!param?.product) noSubParams.push('product')
|
|
183
|
-
|
|
184
|
-
if (noSubParams?.length)
|
|
185
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
|
|
186
|
-
})
|
|
187
|
-
} else {
|
|
188
|
-
noparams.push('orderInventories')
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (noparams?.length) {
|
|
192
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return params
|
|
196
|
-
}
|