@things-factory/sales-base 4.0.24 → 4.0.25
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/dist-server/controllers/ecommerce/ecommerce-controller.js +7 -4
- package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +59 -0
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/order-controller.js +40 -1
- package/dist-server/controllers/order-controller.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js +180 -0
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +193 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-types.js +160 -2
- package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order-types.js +1 -1
- package/dist-server/service/delivery-order/delivery-order-types.js.map +1 -1
- package/dist-server/service/goods-receival-note/goods-receival-note.js +5 -0
- package/dist-server/service/goods-receival-note/goods-receival-note.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +22 -1
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +242 -81
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +8 -0
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +4 -0
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/return-order/return-order-mutation.js +1 -1
- package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
- package/dist-server/utils/inventory-util.js +89 -1
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +12 -12
- package/server/controllers/ecommerce/ecommerce-controller.ts +15 -6
- package/server/controllers/ecommerce/sellercraft-controller.ts +77 -1
- package/server/controllers/order-controller.ts +55 -2
- package/server/service/arrival-notice/arrival-notice-mutation.ts +237 -1
- package/server/service/arrival-notice/arrival-notice-query.ts +214 -4
- package/server/service/arrival-notice/arrival-notice-types.ts +120 -1
- package/server/service/delivery-order/delivery-order-types.ts +1 -1
- package/server/service/goods-receival-note/goods-receival-note.ts +4 -0
- package/server/service/order-inventory/order-inventory.ts +17 -1
- package/server/service/release-good/release-good-mutation.ts +310 -119
- package/server/service/release-good/release-good-types.ts +6 -0
- package/server/service/release-good/release-good.ts +3 -0
- package/server/service/return-order/return-order-mutation.ts +1 -1
- package/server/utils/index.ts +1 -1
- package/server/utils/inventory-util.ts +129 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-inventory.js","sourceRoot":"","sources":["../../../server/service/order-inventory/order-inventory.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,uDAAmD;AACnD,+DAAsD;AACtD,iDAA8C;AAC9C,mEAAoE;AAEpE,2BAQY;AA+BZ,IAAa,cAAc,GAA3B,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"order-inventory.js","sourceRoot":"","sources":["../../../server/service/order-inventory/order-inventory.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,uDAAmD;AACnD,+DAAsD;AACtD,iDAA8C;AAC9C,mEAAoE;AAEpE,2BAQY;AA+BZ,IAAa,cAAc,GAA3B,MAAa,cAAc;CA6Q1B,CAAA;AA1QC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;0CACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,E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kDAC/B,gBAAI,oBAAJ,gBAAI;+CAAA;AAGb;IADC,IAAA,oBAAU,EAAC,CAAC,cAA8B,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC;;iDACtD;AA5QN,cAAc;IA7B1B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,sBAAsB,EAAE,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE;QAC/G,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC;QAClC,cAAc,CAAC,QAAQ;QACvB,cAAc,CAAC,cAAc;QAC7B,cAAc,CAAC,SAAS;KACzB,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,aAAa,EAAE,cAAc,CAAC,SAAS,CAAC,EACrH,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC;QAClC,cAAc,CAAC,QAAQ;QACvB,cAAc,CAAC,aAAa;QAC5B,cAAc,CAAC,aAAa;QAC5B,cAAc,CAAC,SAAS;KACzB,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,GAAE;GACA,cAAc,CA6Q1B;AA7QY,wCAAc"}
|
|
@@ -13,7 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
var _a;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.bulkConfirmReleaseGoods = exports.bulkGenerateReleaseGoods = exports.rejectReleaseGood = exports.receiveReleaseGood = exports.confirmReleaseGood = exports.bulkReleaseGoodsAvailableItemsFunction = exports.generateReleaseGoodFunction = exports.deleteReleaseGood = exports.ReleaseGoodMutation = void 0;
|
|
17
17
|
const graphql_upload_1 = require("graphql-upload");
|
|
18
18
|
const type_graphql_1 = require("type-graphql");
|
|
19
19
|
const typeorm_1 = require("typeorm");
|
|
@@ -23,6 +23,7 @@ const biz_base_1 = require("@things-factory/biz-base");
|
|
|
23
23
|
const id_rule_base_1 = require("@things-factory/id-rule-base");
|
|
24
24
|
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
|
25
25
|
const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
|
|
26
|
+
const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
26
27
|
const notification_1 = require("@things-factory/notification");
|
|
27
28
|
const product_base_1 = require("@things-factory/product-base");
|
|
28
29
|
const setting_base_1 = require("@things-factory/setting-base");
|
|
@@ -35,6 +36,53 @@ const utils_1 = require("../../utils");
|
|
|
35
36
|
const arrival_notice_mutation_1 = require("../arrival-notice/arrival-notice-mutation");
|
|
36
37
|
const release_good_1 = require("./release-good");
|
|
37
38
|
let ReleaseGoodMutation = class ReleaseGoodMutation {
|
|
39
|
+
async bulkAddReleaseGoods(context, rawReleaseGoods, bizplaceId) {
|
|
40
|
+
const { domain, user, tx } = context.state;
|
|
41
|
+
if (!bizplaceId)
|
|
42
|
+
throw new Error('company ID is not provided');
|
|
43
|
+
let createdReleaseGoods = [];
|
|
44
|
+
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
45
|
+
const roNoSetting = await settingRepo.findOne({
|
|
46
|
+
where: {
|
|
47
|
+
domain,
|
|
48
|
+
name: constants_1.ORDER_NUMBER_SETTING_KEY.RO_NUMBER_RULE
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
let releaseGoods = extractRawReleaseGoods(rawReleaseGoods);
|
|
52
|
+
let errorsFound = [];
|
|
53
|
+
for (let i = 0, l = releaseGoods.length; i < l; i++) {
|
|
54
|
+
// generate release good by group to avoid duplication
|
|
55
|
+
// if this function is called simultaneously by different users
|
|
56
|
+
try {
|
|
57
|
+
await (0, typeorm_1.getConnection)().transaction(async (childTx) => {
|
|
58
|
+
const existingReleaseGood = await childTx.getRepository(release_good_1.ReleaseGood).findOne({
|
|
59
|
+
where: Object.assign(Object.assign({}, Object.fromEntries(Object.entries(releaseGoods[i]).filter(([_, val]) => !/^\s*$/.test(val) && _ != 'orderInventories'))), { domain })
|
|
60
|
+
});
|
|
61
|
+
if (existingReleaseGood)
|
|
62
|
+
throw new Error('release good order is already exist in the system');
|
|
63
|
+
let availableItems = await bulkReleaseGoodsAvailableItemsFunction([...releaseGoods[i].orderInventories], bizplaceId, context, childTx);
|
|
64
|
+
if (availableItems.some(item => !item.releaseQty || item.releaseQty > item.assignedQty))
|
|
65
|
+
throw new errors_1.ValidationError(Object.assign(Object.assign({}, errors_1.ValidationError.ERROR_CODES.INSUFFICIENT_STOCK), { detail: { data: JSON.stringify(availableItems) } }));
|
|
66
|
+
// update orderInventories if availableItems are valid
|
|
67
|
+
releaseGoods[i].orderInventories = availableItems;
|
|
68
|
+
const createdReleaseGood = await bulkGenerateReleaseGoods(releaseGoods[i], bizplaceId, roNoSetting, domain, user, childTx);
|
|
69
|
+
createdReleaseGoods.push(createdReleaseGood);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
errorsFound.push(e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let confirmedReleaseGoods = [];
|
|
77
|
+
try {
|
|
78
|
+
confirmedReleaseGoods = await bulkConfirmReleaseGoods(createdReleaseGoods.map(rg => rg.name), domain, user, context, tx);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
errorsFound.push(e);
|
|
82
|
+
}
|
|
83
|
+
// if (errorsFound.length) { then ?? }
|
|
84
|
+
return confirmedReleaseGoods;
|
|
85
|
+
}
|
|
38
86
|
async deleteReleaseGood(name, context) {
|
|
39
87
|
const { tx, user, domain } = context.state;
|
|
40
88
|
return await deleteReleaseGood(tx, name, user, domain);
|
|
@@ -104,34 +152,18 @@ let ReleaseGoodMutation = class ReleaseGoodMutation {
|
|
|
104
152
|
const receivedRO = await receiveReleaseGood(confirmedRO.name, context, tx);
|
|
105
153
|
return receivedRO;
|
|
106
154
|
}
|
|
107
|
-
async bulkAddReleaseGoods(context, rawReleaseGoods, bizplaceId) {
|
|
108
|
-
const { domain, user, tx } = context.state;
|
|
109
|
-
if (!bizplaceId)
|
|
110
|
-
throw new Error('company ID is not provided');
|
|
111
|
-
let createdReleaseGoods = [];
|
|
112
|
-
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
113
|
-
const roNoSetting = await settingRepo.findOne({
|
|
114
|
-
where: {
|
|
115
|
-
domain,
|
|
116
|
-
name: constants_1.ORDER_NUMBER_SETTING_KEY.RO_NUMBER_RULE
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
let releaseGoods = extractRawReleaseGoods(rawReleaseGoods);
|
|
120
|
-
for (let i = 0, l = releaseGoods.length; i < l; i++) {
|
|
121
|
-
// generate release good by group to avoid duplication
|
|
122
|
-
// if this function is called simultaneously by different users
|
|
123
|
-
let availableItems = await bulkReleaseGoodsAvailableItemsFunction([...releaseGoods[i].orderInventories], bizplaceId, context, tx);
|
|
124
|
-
if (availableItems.some(item => !item.releaseQty || item.releaseQty > item.assignedQty))
|
|
125
|
-
throw new errors_1.ValidationError(Object.assign(Object.assign({}, errors_1.ValidationError.ERROR_CODES.INSUFFICIENT_STOCK), { detail: { data: JSON.stringify(availableItems) } }));
|
|
126
|
-
// update orderInventories if availableItems are valid
|
|
127
|
-
releaseGoods[i].orderInventories = availableItems;
|
|
128
|
-
const createdReleaseGood = await bulkGenerateReleaseGoods(releaseGoods[i], bizplaceId, roNoSetting, domain, user, tx);
|
|
129
|
-
createdReleaseGoods.push(createdReleaseGood);
|
|
130
|
-
}
|
|
131
|
-
let confirmedReleaseGoods = await bulkConfirmReleaseGoods(createdReleaseGoods.map(rg => rg.name), domain, user, context, tx);
|
|
132
|
-
return confirmedReleaseGoods;
|
|
133
|
-
}
|
|
134
155
|
};
|
|
156
|
+
__decorate([
|
|
157
|
+
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
158
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
159
|
+
(0, type_graphql_1.Mutation)(returns => [release_good_1.ReleaseGood]),
|
|
160
|
+
__param(0, (0, type_graphql_1.Ctx)()),
|
|
161
|
+
__param(1, (0, type_graphql_1.Arg)('rawReleaseGoods', type => [__1.NewReleaseGood], { nullable: true })),
|
|
162
|
+
__param(2, (0, type_graphql_1.Arg)('bizplaceId', type => String)),
|
|
163
|
+
__metadata("design:type", Function),
|
|
164
|
+
__metadata("design:paramtypes", [Object, Array, String]),
|
|
165
|
+
__metadata("design:returntype", Promise)
|
|
166
|
+
], ReleaseGoodMutation.prototype, "bulkAddReleaseGoods", null);
|
|
135
167
|
__decorate([
|
|
136
168
|
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
137
169
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
@@ -220,16 +252,6 @@ __decorate([
|
|
|
220
252
|
__1.ShippingOrderPatch, typeof (_a = typeof graphql_upload_1.FileUpload !== "undefined" && graphql_upload_1.FileUpload) === "function" ? _a : Object]),
|
|
221
253
|
__metadata("design:returntype", Promise)
|
|
222
254
|
], ReleaseGoodMutation.prototype, "addReleaseGood", null);
|
|
223
|
-
__decorate([
|
|
224
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
225
|
-
(0, type_graphql_1.Mutation)(returns => [release_good_1.ReleaseGood]),
|
|
226
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
227
|
-
__param(1, (0, type_graphql_1.Arg)('rawReleaseGoods', type => [__1.NewReleaseGood], { nullable: true })),
|
|
228
|
-
__param(2, (0, type_graphql_1.Arg)('bizplaceId', type => String)),
|
|
229
|
-
__metadata("design:type", Function),
|
|
230
|
-
__metadata("design:paramtypes", [Object, Array, String]),
|
|
231
|
-
__metadata("design:returntype", Promise)
|
|
232
|
-
], ReleaseGoodMutation.prototype, "bulkAddReleaseGoods", null);
|
|
233
255
|
ReleaseGoodMutation = __decorate([
|
|
234
256
|
(0, type_graphql_1.Resolver)(release_good_1.ReleaseGood)
|
|
235
257
|
], ReleaseGoodMutation);
|
|
@@ -368,10 +390,32 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, attach
|
|
|
368
390
|
domain: warehouseDomain,
|
|
369
391
|
refNo,
|
|
370
392
|
status: (0, typeorm_1.Not)((0, typeorm_1.In)([constants_1.ORDER_STATUS.CANCELLED, constants_1.ORDER_STATUS.PENDING_CANCEL]))
|
|
371
|
-
}
|
|
393
|
+
},
|
|
394
|
+
relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
372
395
|
});
|
|
373
|
-
if (foundReleaseGood)
|
|
374
|
-
|
|
396
|
+
if (foundReleaseGood) {
|
|
397
|
+
const customerCompanyDomain = foundReleaseGood.bizplace.company.domain;
|
|
398
|
+
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
399
|
+
where: { orderNo: refNo, domain: customerCompanyDomain }
|
|
400
|
+
});
|
|
401
|
+
// Need to restructure the validation
|
|
402
|
+
if (marketplaceOrder.isSplitted) {
|
|
403
|
+
const refNo2 = releaseGood.refNo2;
|
|
404
|
+
const foundSplittedReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).findOne({
|
|
405
|
+
where: {
|
|
406
|
+
domain: warehouseDomain,
|
|
407
|
+
refNo2,
|
|
408
|
+
status: (0, typeorm_1.Not)((0, typeorm_1.In)([constants_1.ORDER_STATUS.CANCELLED, constants_1.ORDER_STATUS.PENDING_CANCEL]))
|
|
409
|
+
},
|
|
410
|
+
relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
411
|
+
});
|
|
412
|
+
if (foundSplittedReleaseGood)
|
|
413
|
+
throw new Error('Existing release order found');
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
throw new Error('Existing release order found');
|
|
417
|
+
}
|
|
418
|
+
}
|
|
375
419
|
}
|
|
376
420
|
}
|
|
377
421
|
let newReleaseGood = new release_good_1.ReleaseGood();
|
|
@@ -391,7 +435,7 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, attach
|
|
|
391
435
|
});
|
|
392
436
|
newReleaseGood = Object.assign(Object.assign({}, newReleaseGood), { name: roNoSetting
|
|
393
437
|
? await (0, id_rule_base_1.generateId)({ domain, type: constants_1.ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
|
|
394
|
-
: utils_1.OrderNoGenerator.releaseGood(), domain: warehouseDomain, bizplace: bizplace, collectionOrderNo: releaseGood.collectionOrderNo, courierOption: releaseGood.courierOption, exportOption: releaseGood.exportOption, ownTransport: releaseGood.ownTransport, packingOption: releaseGood.packingOption, marketplaceOrderStatus: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.marketplaceOrderStatus) || null, billingAddress: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.billingAddress) || null, deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null, deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null, deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null, deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null, deliveryAddress5: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress5) || null, attentionTo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionTo) || null, attentionCompany: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionCompany) || null, city: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.city) || null, state: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.state) || null, postalCode: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode) || null, country: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) || null, phone1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone1) || null, phone2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone2) || null, email: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.email) || null, transporter: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.transporter, trackingNo: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.trackingNo, airwayBill: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.airwayBill, invoice: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.invoice, refNo: releaseGood.refNo, refNo2: releaseGood.refNo2, refNo3: releaseGood.refNo3, releaseDate: releaseGood.releaseDate, truckNo: releaseGood.truckNo, orderInventories: releaseGood.orderInventories, type: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.type) ? releaseGood.type : 'b2b', status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user });
|
|
438
|
+
: utils_1.OrderNoGenerator.releaseGood(), domain: warehouseDomain, bizplace: bizplace, collectionOrderNo: releaseGood.collectionOrderNo, courierOption: releaseGood.courierOption, exportOption: releaseGood.exportOption, ownTransport: releaseGood.ownTransport, packingOption: releaseGood.packingOption, marketplaceOrderStatus: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.marketplaceOrderStatus) || null, billingAddress: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.billingAddress) || null, deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null, deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null, deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null, deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null, deliveryAddress5: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress5) || null, attentionTo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionTo) || null, attentionCompany: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionCompany) || null, city: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.city) || null, state: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.state) || null, postalCode: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode) || null, country: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) || null, phone1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone1) || null, phone2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone2) || null, email: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.email) || null, transporter: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.transporter, trackingNo: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.trackingNo, airwayBill: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.airwayBill, invoice: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.invoice, refNo: releaseGood.refNo, refNo2: releaseGood.refNo2, refNo3: releaseGood.refNo3, releaseDate: releaseGood.releaseDate, truckNo: releaseGood.truckNo, bundleInfo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.bundleInfo) || [], orderInventories: releaseGood.orderInventories, type: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.type) ? releaseGood.type : 'b2b', status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user });
|
|
395
439
|
// Make relation with GAN for cross docking
|
|
396
440
|
let crossDockingGAN = undefined;
|
|
397
441
|
if (releaseGood.crossDocking && releaseGood.ganNo) {
|
|
@@ -402,7 +446,6 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, attach
|
|
|
402
446
|
throw new Error(`Failed to find GAN (${releaseGood.ganNo}) for cross docking`);
|
|
403
447
|
newReleaseGood.arrivalNotice = crossDockingGAN;
|
|
404
448
|
}
|
|
405
|
-
newReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(newReleaseGood);
|
|
406
449
|
// Make relation with RO for cross docking
|
|
407
450
|
if (newReleaseGood.crossDocking) {
|
|
408
451
|
crossDockingGAN.releaseGood = newReleaseGood;
|
|
@@ -431,6 +474,8 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, attach
|
|
|
431
474
|
}));
|
|
432
475
|
}
|
|
433
476
|
orderInventories = [...singleProductOIs, ...splitBundleOIs];
|
|
477
|
+
newReleaseGood.noOfItems = orderInventories.length;
|
|
478
|
+
newReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(newReleaseGood);
|
|
434
479
|
for (let oi of orderInventories) {
|
|
435
480
|
let newOrderInv = Object.assign({}, oi);
|
|
436
481
|
newOrderInv = Object.assign(Object.assign({}, newOrderInv), { domain: warehouseDomain, bizplace: bizplace, status: constants_1.ORDER_INVENTORY_STATUS.PENDING, name: utils_1.OrderNoGenerator.orderInventory(), releaseGood: newReleaseGood, product: await tx.getRepository(product_base_1.Product).findOne(oi.product.id), creator: user, updater: user });
|
|
@@ -514,6 +559,7 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
514
559
|
CREATE TEMP TABLE temp_order_products(
|
|
515
560
|
product_id VARCHAR(50),
|
|
516
561
|
sku VARCHAR(150),
|
|
562
|
+
product_info VARCHAR(250),
|
|
517
563
|
packing_type VARCHAR(50),
|
|
518
564
|
packing_size INT,
|
|
519
565
|
uom VARCHAR(10),
|
|
@@ -523,6 +569,8 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
523
569
|
await tx.query(`
|
|
524
570
|
INSERT INTO temp_order_products
|
|
525
571
|
SELECT p.id AS product_id, js.sku,
|
|
572
|
+
CASE WHEN p.description NOT IN (NULL, '', '-') THEN CONCAT(p.name, '(', p.description, ')')
|
|
573
|
+
ELSE p.name END AS product_info,
|
|
526
574
|
CASE WHEN js.packing_type NOTNULL AND js.packing_size NOTNULL THEN js.packing_type ELSE pd.packing_type END,
|
|
527
575
|
CASE WHEN js.packing_type NOTNULL AND js.packing_size NOTNULL THEN js.packing_size ELSE pd.packing_size END,
|
|
528
576
|
CASE WHEN js.uom NOTNULL THEN js.uom ELSE pd.uom END,
|
|
@@ -532,16 +580,12 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
532
580
|
LEFT JOIN product_details pd ON p.id = pd.product_id AND pd.is_default = TRUE;
|
|
533
581
|
`, [companyBizplaceId.id]);
|
|
534
582
|
let availableItems = await tx.query(`
|
|
535
|
-
|
|
583
|
+
WITH inv AS (
|
|
584
|
+
SELECT i.product_id, foo.sku, foo.product_info, i.batch_id, i.packing_type, i.packing_size, i.uom,
|
|
536
585
|
SUM(i.qty - COALESCE(i.locked_qty, 0)) - COALESCE(
|
|
537
586
|
(
|
|
538
587
|
SELECT SUM(oi.release_qty) FROM order_inventories oi
|
|
539
|
-
WHERE (
|
|
540
|
-
oi.status = 'PENDING'
|
|
541
|
-
OR oi.status = 'PENDING_RECEIVE'
|
|
542
|
-
OR oi.status = 'PENDING_WORKSHEET'
|
|
543
|
-
OR oi.status = 'PENDING_SPLIT'
|
|
544
|
-
)
|
|
588
|
+
WHERE oi.status IN ('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'PENDING_SPLIT')
|
|
545
589
|
AND oi.inventory_id IS null
|
|
546
590
|
AND oi.product_id = i.product_id::uuid
|
|
547
591
|
AND oi.packing_type = i.packing_type
|
|
@@ -552,12 +596,7 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
552
596
|
SUM(i.uom_value - COALESCE(i.locked_uom_value, 0)) - COALESCE(
|
|
553
597
|
(
|
|
554
598
|
SELECT SUM(oi.release_uom_value) FROM order_inventories oi
|
|
555
|
-
WHERE (
|
|
556
|
-
oi.status = 'PENDING'
|
|
557
|
-
OR oi.status = 'PENDING_RECEIVE'
|
|
558
|
-
OR oi.status = 'PENDING_WORKSHEET'
|
|
559
|
-
OR oi.status = 'PENDING_SPLIT'
|
|
560
|
-
)
|
|
599
|
+
WHERE oi.status IN ('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'PENDING_SPLIT')
|
|
561
600
|
AND oi.inventory_id IS null
|
|
562
601
|
AND oi.product_id = i.product_id::uuid
|
|
563
602
|
AND oi.packing_type = i.packing_type
|
|
@@ -566,10 +605,12 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
566
605
|
AND oi.bizplace_id = $2
|
|
567
606
|
), 0) as "remain_uom_value"
|
|
568
607
|
FROM inventories i
|
|
608
|
+
LEFT JOIN locations l
|
|
609
|
+
ON i.location_id = l.id
|
|
569
610
|
INNER JOIN (
|
|
570
|
-
SELECT top.product_id, top.sku, top.packing_type, top.packing_size, top.uom
|
|
611
|
+
SELECT top.product_id, top.sku, top.product_info, top.packing_type, top.packing_size, top.uom
|
|
571
612
|
FROM temp_order_products top
|
|
572
|
-
GROUP BY top.product_id, top.sku, top.packing_type, top.packing_size, top.uom
|
|
613
|
+
GROUP BY top.product_id, top.sku, top.product_info, top.packing_type, top.packing_size, top.uom
|
|
573
614
|
) AS foo
|
|
574
615
|
ON i.product_id = foo.product_id::uuid
|
|
575
616
|
AND i.packing_type = foo.packing_type
|
|
@@ -577,13 +618,16 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
577
618
|
AND i.uom = foo.uom
|
|
578
619
|
AND i.domain_id = $1
|
|
579
620
|
AND i.bizplace_id = $2
|
|
580
|
-
|
|
621
|
+
WHERE l.type NOT IN ($3, $4)
|
|
622
|
+
GROUP BY i.product_id, foo.sku,foo.product_info, i.batch_id, i.packing_type, i.packing_size, i.uom
|
|
581
623
|
ORDER BY foo.sku, remain_qty
|
|
582
|
-
|
|
624
|
+
) SELECT * FROM inv WHERE remain_qty > 0
|
|
625
|
+
`, [domain.id, bizplaceId, warehouse_base_1.LOCATION_TYPE.QUARANTINE, warehouse_base_1.LOCATION_TYPE.RESERVE]);
|
|
583
626
|
await tx.query('DROP TABLE temp_order_products');
|
|
584
627
|
availableItems = availableItems.map(item => {
|
|
585
628
|
return {
|
|
586
629
|
productId: item.product_id,
|
|
630
|
+
productInfo: item.product_info,
|
|
587
631
|
sku: item.sku,
|
|
588
632
|
batchId: item.batch_id,
|
|
589
633
|
packingType: item.packing_type,
|
|
@@ -598,7 +642,6 @@ async function bulkReleaseGoodsAvailableItemsFunction(rawReleaseGoods, bizplaceI
|
|
|
598
642
|
exports.bulkReleaseGoodsAvailableItemsFunction = bulkReleaseGoodsAvailableItemsFunction;
|
|
599
643
|
function _extractData(rawData, validatedData) {
|
|
600
644
|
return rawData.map(raw => {
|
|
601
|
-
var _a, _b;
|
|
602
645
|
const idx = validatedData.findIndex(val => {
|
|
603
646
|
const comparison = ['packingType', 'packingSize', 'uom'];
|
|
604
647
|
let a = {}, b = {};
|
|
@@ -615,25 +658,31 @@ function _extractData(rawData, validatedData) {
|
|
|
615
658
|
let releaseUomValue = 0;
|
|
616
659
|
// if sku is matched, assign qty and product id
|
|
617
660
|
if (idx >= 0) {
|
|
661
|
+
const uomValuePerQty = Math.round((validatedData[idx].remainUomValue / validatedData[idx].remainQty) * 100) / 100;
|
|
662
|
+
// use Math.round again because 4.2 * 6 = 25.200000000000003
|
|
663
|
+
releaseUomValue = Math.round(uomValuePerQty * raw.releaseQty * 100) / 100;
|
|
618
664
|
// assign qty to rawData as much as possible
|
|
619
|
-
releaseUomValue =
|
|
620
|
-
(Math.round((((_a = validatedData[idx]) === null || _a === void 0 ? void 0 : _a.remainUomValue) / ((_b = validatedData[idx]) === null || _b === void 0 ? void 0 : _b.remainQty)) * 100) / 100) * raw.releaseQty;
|
|
621
665
|
raw.assignedQty =
|
|
622
666
|
validatedData[idx].remainQty >= raw.releaseQty
|
|
623
667
|
? raw.releaseQty > 0
|
|
624
668
|
? raw.releaseQty
|
|
625
669
|
: 0
|
|
626
|
-
: validatedData[idx].remainQty
|
|
670
|
+
: validatedData[idx].remainQty > 0
|
|
671
|
+
? validatedData[idx].remainQty
|
|
672
|
+
: 0;
|
|
627
673
|
raw.assignedUomValue =
|
|
628
674
|
validatedData[idx].remainUomValue >= releaseUomValue
|
|
629
675
|
? releaseUomValue > 0
|
|
630
676
|
? releaseUomValue
|
|
631
677
|
: 0
|
|
632
|
-
: validatedData[idx].remainUomValue
|
|
678
|
+
: validatedData[idx].remainUomValue > 0
|
|
679
|
+
? validatedData[idx].remainUomValue
|
|
680
|
+
: 0;
|
|
633
681
|
// deduct qty & uomValue from validateData
|
|
634
682
|
validatedData[idx].remainQty -= raw.assignedQty;
|
|
635
683
|
validatedData[idx].remainUomValue -= raw.assignedUomValue;
|
|
636
684
|
raw.productId = validatedData[idx].productId;
|
|
685
|
+
raw.productInfo = validatedData[idx].productInfo;
|
|
637
686
|
raw.packingType = validatedData[idx].packingType;
|
|
638
687
|
raw.packingSize = validatedData[idx].packingSize;
|
|
639
688
|
raw.uom = validatedData[idx].uom;
|
|
@@ -660,6 +709,7 @@ async function confirmReleaseGood(name, context, tx) {
|
|
|
660
709
|
'bizplace.company.domain',
|
|
661
710
|
'orderProducts',
|
|
662
711
|
'orderProducts.product',
|
|
712
|
+
'orderProducts.product.productDetails',
|
|
663
713
|
'orderInventories',
|
|
664
714
|
'orderInventories.product',
|
|
665
715
|
'orderVass'
|
|
@@ -668,24 +718,65 @@ async function confirmReleaseGood(name, context, tx) {
|
|
|
668
718
|
if (!foundReleaseGood)
|
|
669
719
|
throw new Error(`Release good order doesn't exists.`);
|
|
670
720
|
let foundOIs = foundReleaseGood.orderInventories;
|
|
721
|
+
let foundBundleInfo = JSON.parse(foundReleaseGood.bundleInfo);
|
|
671
722
|
let foundOVs = foundReleaseGood.orderVass;
|
|
723
|
+
let foundOPs = foundReleaseGood.orderProducts;
|
|
672
724
|
let customerBizplace = foundReleaseGood.bizplace;
|
|
673
725
|
const companyDomain = customerBizplace === null || customerBizplace === void 0 ? void 0 : customerBizplace.company.domain;
|
|
726
|
+
const sellercraft = await tx
|
|
727
|
+
.getRepository(integration_sellercraft_1.Sellercraft)
|
|
728
|
+
.findOne({ domain: foundReleaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
|
|
674
729
|
if (foundReleaseGood.type == 'b2c') {
|
|
675
|
-
const sellercraft = await tx
|
|
676
|
-
.getRepository(integration_sellercraft_1.Sellercraft)
|
|
677
|
-
.findOne({ domain: foundReleaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
|
|
678
730
|
if (sellercraft) {
|
|
679
731
|
const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
|
|
680
732
|
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, foundReleaseGood);
|
|
681
733
|
}
|
|
682
734
|
else {
|
|
683
735
|
// find for any existing marketplace store connections
|
|
684
|
-
|
|
685
|
-
where: { domain: companyDomain, status: 'ACTIVE'
|
|
736
|
+
let marketplaceStores = await tx.getRepository(integration_marketplace_1.MarketplaceStore).find({
|
|
737
|
+
where: { domain: companyDomain, status: 'ACTIVE' },
|
|
686
738
|
relations: ['marketplaceDistributors']
|
|
687
739
|
});
|
|
740
|
+
const foundMarketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
741
|
+
where: { domain: companyDomain, orderNo: foundReleaseGood.refNo },
|
|
742
|
+
relations: ['marketplaceStore']
|
|
743
|
+
});
|
|
744
|
+
let matchedMarketplaceStore;
|
|
745
|
+
if (foundMarketplaceOrder) {
|
|
746
|
+
matchedMarketplaceStore = marketplaceStores.filter(marketplaceStore => marketplaceStore.id != foundMarketplaceOrder.marketplaceStore.id)[0];
|
|
747
|
+
}
|
|
748
|
+
let combinedOrderInventories = foundOIs.map(oi => {
|
|
749
|
+
return {
|
|
750
|
+
sku: oi.product.sku,
|
|
751
|
+
releaseQty: oi.releaseQty
|
|
752
|
+
};
|
|
753
|
+
});
|
|
754
|
+
if (foundBundleInfo === null || foundBundleInfo === void 0 ? void 0 : foundBundleInfo.length) {
|
|
755
|
+
foundBundleInfo.map(bundle => {
|
|
756
|
+
combinedOrderInventories.push({
|
|
757
|
+
sku: bundle.sku,
|
|
758
|
+
releaseQty: bundle.releaseQty
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
for (let oi of combinedOrderInventories) {
|
|
763
|
+
let foundMarketplaceProductVariations = await tx
|
|
764
|
+
.getRepository(marketplace_base_1.MarketplaceProductVariation)
|
|
765
|
+
.find({
|
|
766
|
+
where: { domain: companyDomain, sku: oi.sku },
|
|
767
|
+
relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
768
|
+
});
|
|
769
|
+
if (foundMarketplaceProductVariations) {
|
|
770
|
+
await Promise.all(foundMarketplaceProductVariations.map(async (variation) => {
|
|
771
|
+
if (variation.marketplaceProduct.marketplaceStore.id != matchedMarketplaceStore.id) {
|
|
772
|
+
variation.reserveQty -= oi.releaseQty;
|
|
773
|
+
await tx.getRepository(marketplace_base_1.MarketplaceProductVariation).save(variation);
|
|
774
|
+
}
|
|
775
|
+
}));
|
|
776
|
+
}
|
|
777
|
+
}
|
|
688
778
|
if ((marketplaceStores === null || marketplaceStores === void 0 ? void 0 : marketplaceStores.length) && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
779
|
+
marketplaceStores = marketplaceStores.filter(marketplaceStore => marketplaceStore.isAutoUpdateStockQty);
|
|
689
780
|
let productIds = foundOIs.map(oi => oi.product.id);
|
|
690
781
|
productIds = Array.from(new Set([...productIds]));
|
|
691
782
|
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
@@ -693,6 +784,12 @@ async function confirmReleaseGood(name, context, tx) {
|
|
|
693
784
|
}
|
|
694
785
|
}
|
|
695
786
|
}
|
|
787
|
+
if (foundReleaseGood.type == 'b2b') {
|
|
788
|
+
if (sellercraft) {
|
|
789
|
+
const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
|
|
790
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER');
|
|
791
|
+
}
|
|
792
|
+
}
|
|
696
793
|
// 1. RO Status change (PENDING => PENDING_RECEIVE)
|
|
697
794
|
const releaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(Object.assign(Object.assign({}, foundReleaseGood), { status: constants_1.ORDER_STATUS.PENDING_RECEIVE, updater: user }));
|
|
698
795
|
// 1. Update status of order inventories
|
|
@@ -809,7 +906,17 @@ async function rejectReleaseGood(tx, context, name, remark) {
|
|
|
809
906
|
const { domain, user } = context.state;
|
|
810
907
|
const releaseGood = await tx.getRepository(release_good_1.ReleaseGood).findOne({
|
|
811
908
|
where: { domain, name, status: constants_1.ORDER_STATUS.PENDING_RECEIVE },
|
|
812
|
-
relations: [
|
|
909
|
+
relations: [
|
|
910
|
+
'bizplace',
|
|
911
|
+
'bizplace.domain',
|
|
912
|
+
'orderProducts',
|
|
913
|
+
'orderProducts.product',
|
|
914
|
+
'orderProducts.product.productDetails',
|
|
915
|
+
'orderInventories',
|
|
916
|
+
'orderInventories.inventory',
|
|
917
|
+
'orderVass',
|
|
918
|
+
'shippingOrder'
|
|
919
|
+
]
|
|
813
920
|
});
|
|
814
921
|
if (!releaseGood)
|
|
815
922
|
throw new Error(`Release good doesn't exists.`);
|
|
@@ -817,6 +924,7 @@ async function rejectReleaseGood(tx, context, name, remark) {
|
|
|
817
924
|
throw new Error('Remark is not exist.');
|
|
818
925
|
let foundOIs = releaseGood.orderInventories;
|
|
819
926
|
let foundOVs = releaseGood.orderVass;
|
|
927
|
+
let foundOPs = releaseGood.orderProducts;
|
|
820
928
|
// 1. Update status of order products (PENDING_RECEIVE => REJECTED)
|
|
821
929
|
if (foundOIs && foundOIs.length) {
|
|
822
930
|
await tx.getRepository(__1.OrderInventory).save(await Promise.all(foundOIs.map(async (oi) => {
|
|
@@ -830,6 +938,20 @@ async function rejectReleaseGood(tx, context, name, remark) {
|
|
|
830
938
|
return oi;
|
|
831
939
|
})));
|
|
832
940
|
}
|
|
941
|
+
if (foundOPs && foundOPs.length) {
|
|
942
|
+
const sellercraft = await tx
|
|
943
|
+
.getRepository(integration_sellercraft_1.Sellercraft)
|
|
944
|
+
.findOne({ domain: releaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
|
|
945
|
+
if (sellercraft) {
|
|
946
|
+
const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
|
|
947
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER');
|
|
948
|
+
}
|
|
949
|
+
await tx.getRepository(__1.OrderProduct).save(await Promise.all(foundOPs.map(async (op) => {
|
|
950
|
+
op.status = constants_1.ORDER_PRODUCT_STATUS.REJECTED;
|
|
951
|
+
op.updater = user;
|
|
952
|
+
return op;
|
|
953
|
+
})));
|
|
954
|
+
}
|
|
833
955
|
// 2. Update status of order vass if it exists (PENDING_RECEIVE => REJECTED)
|
|
834
956
|
if (foundOVs && foundOVs.length) {
|
|
835
957
|
foundOVs = foundOVs.map((ov) => {
|
|
@@ -871,24 +993,63 @@ async function rejectReleaseGood(tx, context, name, remark) {
|
|
|
871
993
|
}
|
|
872
994
|
exports.rejectReleaseGood = rejectReleaseGood;
|
|
873
995
|
async function bulkGenerateReleaseGoods(releaseGood, bizplaceId, roNoSetting, domain, user, tx) {
|
|
996
|
+
var _a, _b;
|
|
874
997
|
try {
|
|
875
998
|
let warehouseDomain = domain;
|
|
876
999
|
let { orderInventories } = releaseGood;
|
|
877
1000
|
let bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(bizplaceId);
|
|
878
1001
|
let newReleaseGood = Object.assign(Object.assign({}, releaseGood), { name: roNoSetting
|
|
879
1002
|
? await (0, id_rule_base_1.generateId)({ domain, type: constants_1.ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
|
|
880
|
-
: utils_1.OrderNoGenerator.releaseGood(), domain: warehouseDomain, bizplace: bizplace, deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null, deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null, deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null, deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null,
|
|
1003
|
+
: utils_1.OrderNoGenerator.releaseGood(), domain: warehouseDomain, bizplace: bizplace, deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null, deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null, deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null, deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null, attentionTo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionTo) || null, attentionCompany: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionCompany) || null, city: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.city) || null, state: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.state) || null, postalCode: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode) || null, country: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) || null, phone1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone1) || null, phone2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone2) || null, email: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.email) || null, airwayBill: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.airwayBill, refNo: releaseGood.refNo, refNo2: releaseGood.refNo2, refNo3: releaseGood.refNo3, releaseDate: releaseGood.releaseDate, ownTransport: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.ownTransport) || false, status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user });
|
|
881
1004
|
newReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(newReleaseGood);
|
|
1005
|
+
let finalOrderInventories = [];
|
|
1006
|
+
// pre assign inventory to orderInventories
|
|
882
1007
|
for (let oi of orderInventories) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
let
|
|
887
|
-
|
|
1008
|
+
const pickingProductSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
1009
|
+
where: { domain, name: 'rule-for-picking-product' }
|
|
1010
|
+
});
|
|
1011
|
+
let locationSortingRules = [];
|
|
1012
|
+
if (pickingProductSetting) {
|
|
1013
|
+
let locationSetting = JSON.parse(pickingProductSetting.value);
|
|
1014
|
+
for (const key in locationSetting) {
|
|
1015
|
+
locationSortingRules.push({ name: key, desc: locationSetting[key] == 'ASC' ? false : true });
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
const product = await tx.getRepository(product_base_1.Product).findOne(oi.productId);
|
|
1019
|
+
finalOrderInventories.push(...(await utils_1.InventoryUtil.autoAssignInventoryForRelease(product, oi, oi.packingType, locationSortingRules, bizplace, warehouseDomain, tx)));
|
|
1020
|
+
}
|
|
1021
|
+
for (let oi of finalOrderInventories) {
|
|
1022
|
+
let generatedOI = Object.assign(new __1.OrderInventory(), oi);
|
|
1023
|
+
generatedOI = Object.assign(Object.assign({}, generatedOI), { domain: warehouseDomain, bizplace, status: constants_1.ORDER_INVENTORY_STATUS.PENDING, name: utils_1.OrderNoGenerator.orderInventory(), releaseGood: newReleaseGood, creator: user, updater: user });
|
|
1024
|
+
let newOrderProduct = {
|
|
1025
|
+
name: generatedOI.name,
|
|
1026
|
+
product: generatedOI.product,
|
|
1027
|
+
batchId: generatedOI.batchId,
|
|
1028
|
+
packingType: generatedOI.packingType,
|
|
1029
|
+
packingSize: generatedOI.packingSize,
|
|
1030
|
+
uom: generatedOI.uom,
|
|
1031
|
+
domain: warehouseDomain,
|
|
1032
|
+
bizplace,
|
|
1033
|
+
releaseQty: generatedOI.releaseQty,
|
|
1034
|
+
releaseUomValue: generatedOI.releaseUomValue,
|
|
1035
|
+
packQty: 0,
|
|
1036
|
+
actualPackQty: 0,
|
|
1037
|
+
palletQty: 0,
|
|
1038
|
+
actualPalletQty: 0,
|
|
1039
|
+
status: constants_1.ORDER_PRODUCT_STATUS.PENDING_ASSIGN,
|
|
1040
|
+
releaseGood: newReleaseGood,
|
|
1041
|
+
creator: user,
|
|
1042
|
+
updater: user
|
|
1043
|
+
};
|
|
888
1044
|
newOrderProduct = await tx.getRepository(__1.OrderProduct).save(newOrderProduct);
|
|
889
|
-
await tx.getRepository(__1.OrderInventory).save(Object.assign(Object.assign({},
|
|
1045
|
+
await tx.getRepository(__1.OrderInventory).save(Object.assign(Object.assign({}, generatedOI), { orderProduct: newOrderProduct }));
|
|
1046
|
+
// update inventory locked qty and uom value
|
|
1047
|
+
await tx.getRepository(warehouse_base_1.Inventory).update(oi.inventory.id, {
|
|
1048
|
+
lockedQty: (((_a = oi.inventory) === null || _a === void 0 ? void 0 : _a.lockedQty) || 0) + generatedOI.releaseQty,
|
|
1049
|
+
lockedUomValue: (((_b = oi.inventory) === null || _b === void 0 ? void 0 : _b.lockedUomValue) || 0) + generatedOI.releaseUomValue,
|
|
1050
|
+
updater: user
|
|
1051
|
+
});
|
|
890
1052
|
}
|
|
891
|
-
// Change the status to PENDING_RECEIVE
|
|
892
1053
|
return newReleaseGood;
|
|
893
1054
|
}
|
|
894
1055
|
catch (error) {
|
|
@@ -914,7 +1075,7 @@ async function bulkConfirmReleaseGoods(releaseGoodsNo, domain, user, context, tx
|
|
|
914
1075
|
]
|
|
915
1076
|
});
|
|
916
1077
|
if (!foundReleaseGoods.length)
|
|
917
|
-
throw new Error(`
|
|
1078
|
+
throw new Error(`release good order doesn't exists.`);
|
|
918
1079
|
let customerBizplace = foundReleaseGoods[0].bizplace;
|
|
919
1080
|
let foundOrderInventories = foundReleaseGoods
|
|
920
1081
|
.map((releaseGood) => releaseGood.orderInventories)
|
|
@@ -992,6 +1153,7 @@ function extractRawReleaseGoods(rawReleaseGoods) {
|
|
|
992
1153
|
});
|
|
993
1154
|
if (idx >= 0) {
|
|
994
1155
|
const duplicateSkuIdx = releaseGoods[idx].orderInventories.findIndex(oi => oi.sku === item.sku && oi.packingType === item.packingType && oi.packingSize === item.packingSize);
|
|
1156
|
+
// if there is duplicated SKU, merge them and sum up the releaseQty
|
|
995
1157
|
if (duplicateSkuIdx >= 0) {
|
|
996
1158
|
releaseGoods[idx].orderInventories[duplicateSkuIdx].releaseQty += item.releaseQty;
|
|
997
1159
|
}
|
|
@@ -1039,5 +1201,4 @@ function extractRawReleaseGoods(rawReleaseGoods) {
|
|
|
1039
1201
|
return releaseGoods;
|
|
1040
1202
|
}, []);
|
|
1041
1203
|
}
|
|
1042
|
-
exports.extractRawReleaseGoods = extractRawReleaseGoods;
|
|
1043
1204
|
//# sourceMappingURL=release-good-mutation.js.map
|