@things-factory/worksheet-base 4.3.394 → 4.3.396
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/outbound/index.js +3 -0
- package/dist-server/controllers/outbound/index.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +119 -15
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-batch-picking.js +71 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +21 -28
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/bulk-activate-picking.js +21 -4
- package/dist-server/graphql/resolvers/worksheet/picking/bulk-activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +96 -130
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +22 -56
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/index.js +3 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/utils/lmd-util.js +190 -162
- package/dist-server/utils/lmd-util.js.map +1 -1
- package/package.json +9 -9
- package/server/controllers/outbound/index.ts +2 -0
- package/server/controllers/outbound/picking-worksheet-controller.ts +127 -17
- package/server/graphql/resolvers/worksheet/picking/activate-batch-picking.ts +107 -6
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +73 -65
- package/server/graphql/resolvers/worksheet/picking/bulk-activate-picking.ts +30 -5
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +34 -56
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +4 -36
- package/server/index.ts +2 -0
- package/server/utils/lmd-util.ts +220 -202
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.activateBatchPicking = exports.activateBatchPickingResolver = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
6
|
+
const env_1 = require("@things-factory/env");
|
|
5
7
|
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
|
8
|
+
const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
9
|
+
const sales_base_1 = require("@things-factory/sales-base");
|
|
6
10
|
const controllers_1 = require("../../../../controllers");
|
|
7
|
-
const
|
|
11
|
+
const utils_1 = require("../../../../utils");
|
|
8
12
|
exports.activateBatchPickingResolver = {
|
|
9
13
|
async activateBatchPicking(_, { worksheetNo }, context) {
|
|
10
14
|
const { tx, domain, user } = context.state;
|
|
@@ -12,11 +16,14 @@ exports.activateBatchPickingResolver = {
|
|
|
12
16
|
}
|
|
13
17
|
};
|
|
14
18
|
async function activateBatchPicking(tx, domain, user, worksheetNo) {
|
|
19
|
+
var _a, _b;
|
|
15
20
|
try {
|
|
16
21
|
const worksheetController = new controllers_1.PickingWorksheetController(tx, domain, user);
|
|
22
|
+
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
17
23
|
const worksheet = await worksheetController.activateBatchPicking(worksheetNo);
|
|
18
24
|
const worksheetDetails = worksheet.worksheetDetails;
|
|
19
25
|
const companyDomain = worksheet === null || worksheet === void 0 ? void 0 : worksheet.bizplace.company.domain;
|
|
26
|
+
let orderInventories = worksheetDetails.map(wsd => wsd.targetInventory);
|
|
20
27
|
// find for any existing marketplace store connections
|
|
21
28
|
const marketplaceStores = await tx.getRepository(integration_marketplace_1.MarketplaceStore).find({
|
|
22
29
|
where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
|
|
@@ -37,6 +44,69 @@ async function activateBatchPicking(tx, domain, user, worksheetNo) {
|
|
|
37
44
|
if ((marketplaceStores === null || marketplaceStores === void 0 ? void 0 : marketplaceStores.length) && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
38
45
|
updateMarketplaceProductVariationStock(worksheetDetails, domain, user, marketplaceStores, companyDomain);
|
|
39
46
|
}
|
|
47
|
+
try {
|
|
48
|
+
let releaseGoods = [];
|
|
49
|
+
let releaseGoodIds = orderInventories.reduce((data, orderInventory) => {
|
|
50
|
+
if (!data.find(x => x.id == orderInventory.releaseGood.id)) {
|
|
51
|
+
data.push(orderInventory.releaseGood.id);
|
|
52
|
+
}
|
|
53
|
+
return data;
|
|
54
|
+
}, []);
|
|
55
|
+
releaseGoods = await tx.getRepository(sales_base_1.ReleaseGood).find({
|
|
56
|
+
where: { id: (0, typeorm_1.In)(releaseGoodIds) },
|
|
57
|
+
relations: [
|
|
58
|
+
'domain',
|
|
59
|
+
'lastMileDelivery',
|
|
60
|
+
'bizplace',
|
|
61
|
+
'bizplace.domain',
|
|
62
|
+
'orderPackages',
|
|
63
|
+
'orderPackages.orderPackageItems',
|
|
64
|
+
'orderPackages.orderPackageItems.orderProduct',
|
|
65
|
+
'orderPackages.orderPackageItems.orderProduct.product',
|
|
66
|
+
'orderPackages.orderPackageItems.orderProduct.productDetail',
|
|
67
|
+
'orderProducts',
|
|
68
|
+
'orderProducts.productDetail',
|
|
69
|
+
'orderProducts.product'
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
if (releaseGoods === null || releaseGoods === void 0 ? void 0 : releaseGoods.length) {
|
|
73
|
+
for (const releaseGood of releaseGoods) {
|
|
74
|
+
const orderSource = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.source;
|
|
75
|
+
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
76
|
+
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
77
|
+
relations: ['marketplaceStore']
|
|
78
|
+
});
|
|
79
|
+
switch (orderSource) {
|
|
80
|
+
case auth_base_1.ApplicationType.MMS:
|
|
81
|
+
if (marketplaceStores === null || marketplaceStores === void 0 ? void 0 : marketplaceStores.length) {
|
|
82
|
+
if (marketplaceOrder) {
|
|
83
|
+
const marketplaceStore = marketplaceOrder.marketplaceStore;
|
|
84
|
+
await ecommerceCtrl.createOrderPackage(tx, marketplaceOrder, companyDomain, marketplaceStore, releaseGood);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
if (((_a = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.orderPackages) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
92
|
+
releaseGood.lmdOption &&
|
|
93
|
+
releaseGood.lastMileDelivery &&
|
|
94
|
+
((_b = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.orderPackages) === null || _b === void 0 ? void 0 : _b.some(op => op.parcelId == null))) {
|
|
95
|
+
await (0, utils_1.createLmdParcel)([releaseGood], tx, domain, user, marketplaceOrder);
|
|
96
|
+
//where to trigger update parcel count
|
|
97
|
+
let countParcel = (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.countParcel) ? releaseGood.countParcel : 0;
|
|
98
|
+
const releaseGoodId = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.id;
|
|
99
|
+
await tx.getRepository(sales_base_1.ReleaseGood).update({ id: releaseGoodId }, {
|
|
100
|
+
countParcel: countParcel + 1,
|
|
101
|
+
updater: user.id
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
env_1.logger.error(e);
|
|
109
|
+
}
|
|
40
110
|
return worksheet;
|
|
41
111
|
}
|
|
42
112
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activate-batch-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/activate-batch-picking.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"activate-batch-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/activate-batch-picking.ts"],"names":[],"mappings":";;;AAAA,qCAIgB;AAEhB,yDAGkC;AAClC,6CAA4C;AAC5C,qFAA0E;AAC1E,uEAAmE;AACnE,2DAAwD;AAGxD,yDAGgC;AAEhC,6CAAmD;AAEtC,QAAA,4BAA4B,GAAG;IAC1C,KAAK,CAAC,oBAAoB,CAAC,CAAM,EAAE,EAAE,WAAW,EAAE,EAAE,OAAY;QAC9D,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAC7F,OAAO,MAAM,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IAClE,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,oBAAoB,CACxC,EAAiB,EACjB,MAAc,EACd,IAAU,EACV,WAAmB;;IAEnB,IAAI;QACF,MAAM,mBAAmB,GAA+B,IAAI,wCAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QACxG,MAAM,aAAa,GAAwB,IAAI,iCAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QACpF,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAA;QAC7E,MAAM,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAA;QACnD,MAAM,aAAa,GAAW,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAA;QAEhE,IAAI,gBAAgB,GAAU,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAE9E,sDAAsD;QACtD,MAAM,iBAAiB,GAAuB,MAAM,EAAE,CAAC,aAAa,CAAC,0CAAgB,CAAC,CAAC,IAAI,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E,CAAC,CAAA;QAC1F,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;KACjE;AACH,CAAC;AAhID,oDAgIC"}
|
|
@@ -7,6 +7,7 @@ const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
|
7
7
|
const sales_base_1 = require("@things-factory/sales-base");
|
|
8
8
|
const controllers_1 = require("../../../../controllers");
|
|
9
9
|
const entities_1 = require("../../../../entities");
|
|
10
|
+
const utils_1 = require("../../../../utils");
|
|
10
11
|
exports.activatePickingResolver = {
|
|
11
12
|
async activatePicking(_, { worksheetNo }, context) {
|
|
12
13
|
const { tx, domain, user } = context.state;
|
|
@@ -14,12 +15,18 @@ exports.activatePickingResolver = {
|
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
async function activatePicking(tx, domain, user, worksheetNo) {
|
|
18
|
+
var _a, _b;
|
|
17
19
|
try {
|
|
18
20
|
const worksheetController = new controllers_1.PickingWorksheetController(tx, domain, user);
|
|
21
|
+
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
19
22
|
const worksheet = await worksheetController.activatePicking(worksheetNo);
|
|
20
23
|
const companyDomain = worksheet === null || worksheet === void 0 ? void 0 : worksheet.bizplace.company.domain;
|
|
21
24
|
let releaseGood = worksheet.releaseGood;
|
|
22
25
|
const orderSource = releaseGood.source;
|
|
26
|
+
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
27
|
+
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
28
|
+
relations: ['marketplaceStore']
|
|
29
|
+
});
|
|
23
30
|
switch (orderSource) {
|
|
24
31
|
case auth_base_1.ApplicationType.MMS:
|
|
25
32
|
// find for any existing marketplace store connections
|
|
@@ -34,46 +41,32 @@ async function activatePicking(tx, domain, user, worksheetNo) {
|
|
|
34
41
|
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
35
42
|
await ecommerceCtrl.updateProductVariationStock(marketplaceStores, orderInventories, companyDomain);
|
|
36
43
|
}
|
|
37
|
-
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
38
|
-
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
39
|
-
relations: ['marketplaceStore']
|
|
40
|
-
});
|
|
41
44
|
if (marketplaceOrder) {
|
|
42
45
|
const marketplaceStore = marketplaceOrder.marketplaceStore;
|
|
43
46
|
if (marketplaceStore.isAutoUpdateShipment) {
|
|
44
47
|
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
45
48
|
await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, sales_base_1.ORDER_STATUS.PICKING);
|
|
46
49
|
}
|
|
50
|
+
await ecommerceCtrl.createOrderPackage(tx, marketplaceOrder, companyDomain, marketplaceStore, releaseGood);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
break;
|
|
50
54
|
default:
|
|
51
55
|
break;
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// relations: ['marketplaceStore']
|
|
67
|
-
// })
|
|
68
|
-
// if (marketplaceOrder) {
|
|
69
|
-
// const marketplaceStore: MarketplaceStore = marketplaceOrder.marketplaceStore
|
|
70
|
-
// if (marketplaceStore.isAutoUpdateShipment) {
|
|
71
|
-
// const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
72
|
-
// await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, ORDER_STATUS.PICKING)
|
|
73
|
-
// }
|
|
74
|
-
// }
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
57
|
+
if (((_a = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.orderPackages) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
58
|
+
releaseGood.lmdOption &&
|
|
59
|
+
releaseGood.lastMileDelivery &&
|
|
60
|
+
((_b = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.orderPackages) === null || _b === void 0 ? void 0 : _b.some(op => op.parcelId == null))) {
|
|
61
|
+
await (0, utils_1.createLmdParcel)([releaseGood], tx, domain, user, marketplaceOrder);
|
|
62
|
+
//where to trigger update parcel count
|
|
63
|
+
let countParcel = (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.countParcel) ? releaseGood.countParcel : 0;
|
|
64
|
+
const releaseGoodId = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.id;
|
|
65
|
+
await tx.getRepository(sales_base_1.ReleaseGood).update({ id: releaseGoodId }, {
|
|
66
|
+
countParcel: countParcel + 1,
|
|
67
|
+
updater: user.id
|
|
68
|
+
});
|
|
69
|
+
}
|
|
77
70
|
return worksheet;
|
|
78
71
|
}
|
|
79
72
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activate-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/activate-picking.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"activate-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/activate-picking.ts"],"names":[],"mappings":";;;AAEA,yDAGkC;AAClC,qFAA0E;AAC1E,uEAAmE;AACnE,2DAGmC;AAGnC,yDAGgC;AAChC,mDAG6B;AAC7B,6CAAmD;AAEtC,QAAA,uBAAuB,GAAG;IACrC,KAAK,CAAC,eAAe,CAAC,CAAM,EAAE,EAAE,WAAW,EAAE,EAAE,OAAY;QACzD,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAC7F,OAAO,MAAM,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IAC7D,CAAC;CACF,CAAA;AAEM,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AAgB,CAAC,CAAA;YAExE,sCAAsC;YACtC,IAAI,WAAW,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;YACxE,MAAM,aAAa,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,EAAE,CAAA;YAErC,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAW,CAAC,CAAC,MAAM,CACxC,EAAE,EAAE,EAAE,aAAa,EAAE,EACrB;gBACE,WAAW,EAAE,WAAW,GAAC,CAAC;gBAC1B,OAAO,EAAE,IAAI,CAAC,EAAE;aACjB,CACF,CAAA;SACF;QAED,OAAO,SAAS,CAAA;KACjB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,KAAK,CAAA;KACZ;YAAS;QACR,qCAA0B,CAAC,WAAW,EAAE,CAAA;KACzC;AACD,CAAC;AAhFD,0CAgFC"}
|
|
@@ -6,6 +6,7 @@ const integration_marketplace_1 = require("@things-factory/integration-marketpla
|
|
|
6
6
|
const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
7
7
|
const sales_base_1 = require("@things-factory/sales-base");
|
|
8
8
|
const controllers_1 = require("../../../../controllers");
|
|
9
|
+
const utils_1 = require("../../../../utils");
|
|
9
10
|
exports.activateBulkPickingResolver = {
|
|
10
11
|
async activateBulkPicking(_, { worksheetNo }, context) {
|
|
11
12
|
const { tx, domain, user } = context.state;
|
|
@@ -13,12 +14,18 @@ exports.activateBulkPickingResolver = {
|
|
|
13
14
|
}
|
|
14
15
|
};
|
|
15
16
|
async function activateBulkPicking(tx, domain, user, worksheetNo) {
|
|
17
|
+
var _a, _b;
|
|
16
18
|
const worksheetController = new controllers_1.PickingWorksheetController(tx, domain, user);
|
|
19
|
+
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
17
20
|
const worksheets = await worksheetController.activateBulkPicking(worksheetNo);
|
|
18
21
|
for (const worksheet of worksheets) {
|
|
19
22
|
const companyDomain = worksheet === null || worksheet === void 0 ? void 0 : worksheet.bizplace.company.domain;
|
|
20
23
|
let releaseGood = worksheet.releaseGood;
|
|
21
24
|
const orderSource = releaseGood.source;
|
|
25
|
+
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
26
|
+
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
27
|
+
relations: ['marketplaceStore']
|
|
28
|
+
});
|
|
22
29
|
switch (orderSource) {
|
|
23
30
|
case auth_base_1.ApplicationType.MMS:
|
|
24
31
|
// find for any existing marketplace store connections
|
|
@@ -33,22 +40,32 @@ async function activateBulkPicking(tx, domain, user, worksheetNo) {
|
|
|
33
40
|
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
34
41
|
await ecommerceCtrl.updateProductVariationStock(marketplaceStores, orderInventories, companyDomain);
|
|
35
42
|
}
|
|
36
|
-
const marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
37
|
-
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
38
|
-
relations: ['marketplaceStore']
|
|
39
|
-
});
|
|
40
43
|
if (marketplaceOrder) {
|
|
41
44
|
const marketplaceStore = marketplaceOrder.marketplaceStore;
|
|
42
45
|
if (marketplaceStore.isAutoUpdateShipment) {
|
|
43
46
|
const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
|
|
44
47
|
await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, sales_base_1.ORDER_STATUS.PICKING);
|
|
45
48
|
}
|
|
49
|
+
await ecommerceCtrl.createOrderPackage(tx, marketplaceOrder, companyDomain, marketplaceStore, releaseGood);
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
break;
|
|
49
53
|
default:
|
|
50
54
|
break;
|
|
51
55
|
}
|
|
56
|
+
if (((_a = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.orderPackages) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
57
|
+
releaseGood.lmdOption &&
|
|
58
|
+
releaseGood.lastMileDelivery &&
|
|
59
|
+
((_b = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.orderPackages) === null || _b === void 0 ? void 0 : _b.some(op => op.parcelId == null))) {
|
|
60
|
+
await (0, utils_1.createLmdParcel)([releaseGood], tx, domain, user, marketplaceOrder);
|
|
61
|
+
//where to trigger update parcel count
|
|
62
|
+
let countParcel = (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.countParcel) ? releaseGood.countParcel : 0;
|
|
63
|
+
const releaseGoodId = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.id;
|
|
64
|
+
await tx.getRepository(sales_base_1.ReleaseGood).update({ id: releaseGoodId }, {
|
|
65
|
+
countParcel: countParcel + 1,
|
|
66
|
+
updater: user.id
|
|
67
|
+
});
|
|
68
|
+
}
|
|
52
69
|
}
|
|
53
70
|
return worksheets;
|
|
54
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-activate-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/bulk-activate-picking.ts"],"names":[],"mappings":";;;AAEA,yDAGkC;AAClC,qFAA0E;AAC1E,uEAAmE;AACnE,2DAGmC;AAGnC,yDAGgC;
|
|
1
|
+
{"version":3,"file":"bulk-activate-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/bulk-activate-picking.ts"],"names":[],"mappings":";;;AAEA,yDAGkC;AAClC,qFAA0E;AAC1E,uEAAmE;AACnE,2DAGmC;AAGnC,yDAGgC;AAEhC,6CAAmD;AAEtC,QAAA,2BAA2B,GAAG;IACzC,KAAK,CAAC,mBAAmB,CAAC,CAAM,EAAE,EAAE,WAAW,EAAE,EAAE,OAAY;QAC7D,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAE7F,OAA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CAAC,QAAQ,IAAI,IAAI,CAAC,CAAA,EAC3D;YACA,MAAM,IAAA,uBAAe,EAAC,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAA;YAExE,sCAAsC;YACtC,IAAI,WAAW,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;YACxE,MAAM,aAAa,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,EAAE,CAAA;YAErC,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAW,CAAC,CAAC,MAAM,CACxC,EAAE,EAAE,EAAE,aAAa,EAAE,EACrB;gBACE,WAAW,EAAE,WAAW,GAAC,CAAC;gBAC1B,OAAO,EAAE,IAAI,CAAC,EAAE;aACjB,CACF,CAAA;SACF;KACF;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AA1ED,kDA0EC"}
|
|
@@ -15,7 +15,6 @@ const warehouse_base_1 = require("@things-factory/warehouse-base");
|
|
|
15
15
|
const controllers_1 = require("../../../../controllers/");
|
|
16
16
|
const ecommerce_1 = require("../../../../controllers/ecommerce");
|
|
17
17
|
const entities_1 = require("../../../../entities");
|
|
18
|
-
const utils_1 = require("../../../../utils");
|
|
19
18
|
exports.completeBatchPickingResolver = {
|
|
20
19
|
async completeBatchPicking(_, { taskNo }, context) {
|
|
21
20
|
const { tx, domain, user } = context.state;
|
|
@@ -35,7 +34,7 @@ exports.completeBatchPickingResolver = {
|
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
36
|
async function completeBatchPicking(tx, domain, user, taskNo) {
|
|
38
|
-
var _a, _b;
|
|
37
|
+
var _a, _b, _c;
|
|
39
38
|
try {
|
|
40
39
|
console.time(`complete-batch-picking[completeBatchPicking]: {domain:${domain.id}, taskNo:${taskNo}}`);
|
|
41
40
|
const pickingWSCtrl = new controllers_1.PickingWorksheetController(tx, domain, user);
|
|
@@ -154,143 +153,110 @@ async function completeBatchPicking(tx, domain, user, taskNo) {
|
|
|
154
153
|
foundReleaseGood = await ecommerceCtrl.createOrderPackage(tx, marketplaceOrder, companyDomain, marketplaceStore, foundReleaseGood);
|
|
155
154
|
break;
|
|
156
155
|
default:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
156
|
+
if (!((_a = foundReleaseGood === null || foundReleaseGood === void 0 ? void 0 : foundReleaseGood.orderPackages) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
157
|
+
let orderPackage = {
|
|
158
|
+
name: sales_base_1.OrderNoGenerator.orderPackage(),
|
|
159
|
+
packageId: null,
|
|
160
|
+
trackingNo: null,
|
|
161
|
+
transporter: null,
|
|
162
|
+
airwayBill: null,
|
|
163
|
+
status: sales_base_1.ORDER_STATUS.PROCESSING,
|
|
164
|
+
releaseGood: foundReleaseGood,
|
|
165
|
+
domain: foundReleaseGood.domain,
|
|
166
|
+
bizplace: foundReleaseGood.bizplace,
|
|
167
|
+
creator: foundReleaseGood.creator,
|
|
168
|
+
updater: foundReleaseGood.updater
|
|
169
|
+
};
|
|
170
|
+
await (0, controllers_1.createOrderPackageAndItems)(tx, foundReleaseGood, orderPackage);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
const account = await tx
|
|
174
|
+
.getRepository(integration_accounting_1.Account)
|
|
175
|
+
.findOne({ where: { domain: foundReleaseGood.bizplace.domain, status: 'active' }, relations: ['domain'] });
|
|
176
|
+
// Xilnex Create Sales Order and Post Sales Order to Sales Invoice
|
|
177
|
+
const createSalesOrder = async (account, releaseGood, tx) => {
|
|
178
|
+
if (account) {
|
|
179
|
+
if (account.platform == 'xilnex') {
|
|
180
|
+
try {
|
|
181
|
+
delete releaseGood.orderPackages;
|
|
182
|
+
delete releaseGood.creator;
|
|
183
|
+
delete releaseGood.updater;
|
|
184
|
+
const body = {
|
|
185
|
+
accessToken: account.accessToken,
|
|
186
|
+
appId: account.accountId,
|
|
187
|
+
accountInfo: account.accountInfo,
|
|
188
|
+
req: JSON.stringify({
|
|
189
|
+
releaseGood,
|
|
190
|
+
orderProducts: releaseGood.orderProducts
|
|
191
|
+
})
|
|
192
|
+
};
|
|
193
|
+
await (0, integration_base_1.sqsSendMessage)({
|
|
194
|
+
body,
|
|
195
|
+
deduplicationId: releaseGood.refNo,
|
|
196
|
+
groupId: releaseGood.refNo,
|
|
197
|
+
queueName: 'prototypeQueue.fifo'
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
throw new Error(e);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
200
204
|
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const createSalesOrder = async (account, releaseGood, tx) => {
|
|
212
|
-
if (account) {
|
|
213
|
-
if (account.platform == 'xilnex') {
|
|
205
|
+
};
|
|
206
|
+
if (foundReleaseGood.type == 'b2c') {
|
|
207
|
+
createSalesOrder(account, foundReleaseGood, tx);
|
|
208
|
+
}
|
|
209
|
+
// trigger LMD API to create parcel
|
|
210
|
+
if (((_b = foundReleaseGood === null || foundReleaseGood === void 0 ? void 0 : foundReleaseGood.orderPackages) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
211
|
+
foundReleaseGood.lmdOption &&
|
|
212
|
+
foundReleaseGood.lastMileDelivery &&
|
|
213
|
+
((_c = foundReleaseGood === null || foundReleaseGood === void 0 ? void 0 : foundReleaseGood.orderPackages) === null || _c === void 0 ? void 0 : _c.some(op => op.parcelId == null))) {
|
|
214
|
+
// trigger RTS
|
|
214
215
|
try {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
queueName: 'prototypeQueue.fifo'
|
|
232
|
-
});
|
|
216
|
+
const orderSource = foundReleaseGood.source;
|
|
217
|
+
if (orderSource == auth_base_1.ApplicationType.SELLERCRAFT) {
|
|
218
|
+
const sellercraft = await tx.getRepository(integration_sellercraft_1.Sellercraft).findOne({
|
|
219
|
+
domain: foundReleaseGood.bizplace.domain,
|
|
220
|
+
status: integration_sellercraft_1.SellercraftStatus.ACTIVE
|
|
221
|
+
});
|
|
222
|
+
if (sellercraft) {
|
|
223
|
+
const sellercraftCtrl = new controllers_1.SellercraftController(tx, null, null);
|
|
224
|
+
const rtsTriggerLevel = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
225
|
+
where: { domain: foundReleaseGood.domain, category: 'id-rule', name: 'rts-trigger-level' }
|
|
226
|
+
});
|
|
227
|
+
if (rtsTriggerLevel && parseInt((rtsTriggerLevel === null || rtsTriggerLevel === void 0 ? void 0 : rtsTriggerLevel.value) || 0) == 1) {
|
|
228
|
+
sellercraftCtrl.initiateOrderShipment(sellercraft, foundReleaseGood);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
233
232
|
}
|
|
234
233
|
catch (e) {
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
if (foundReleaseGood.type == 'b2c') {
|
|
241
|
-
createSalesOrder(account, foundReleaseGood, tx);
|
|
242
|
-
}
|
|
243
|
-
// trigger LMD API to create parcel
|
|
244
|
-
if (((_a = foundReleaseGood === null || foundReleaseGood === void 0 ? void 0 : foundReleaseGood.orderPackages) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
245
|
-
foundReleaseGood.lmdOption &&
|
|
246
|
-
foundReleaseGood.lastMileDelivery &&
|
|
247
|
-
((_b = foundReleaseGood === null || foundReleaseGood === void 0 ? void 0 : foundReleaseGood.orderPackages) === null || _b === void 0 ? void 0 : _b.some(op => op.parcelId == null))) {
|
|
248
|
-
await (0, utils_1.createLmdParcel)([foundReleaseGood], tx, domain, user, marketplaceOrder);
|
|
249
|
-
// trigger RTS
|
|
250
|
-
try {
|
|
251
|
-
const orderSource = foundReleaseGood.source;
|
|
252
|
-
if (orderSource == auth_base_1.ApplicationType.SELLERCRAFT) {
|
|
253
|
-
const sellercraft = await tx.getRepository(integration_sellercraft_1.Sellercraft).findOne({
|
|
254
|
-
domain: foundReleaseGood.bizplace.domain,
|
|
255
|
-
status: integration_sellercraft_1.SellercraftStatus.ACTIVE
|
|
256
|
-
});
|
|
257
|
-
if (sellercraft) {
|
|
258
|
-
const sellercraftCtrl = new controllers_1.SellercraftController(tx, null, null);
|
|
259
|
-
const rtsTriggerLevel = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
260
|
-
where: { domain: foundReleaseGood.domain, category: 'id-rule', name: 'rts-trigger-level' }
|
|
261
|
-
});
|
|
262
|
-
if (rtsTriggerLevel && parseInt((rtsTriggerLevel === null || rtsTriggerLevel === void 0 ? void 0 : rtsTriggerLevel.value) || 0) == 1) {
|
|
263
|
-
sellercraftCtrl.initiateOrderShipment(sellercraft, foundReleaseGood);
|
|
264
|
-
}
|
|
234
|
+
env_1.logger.error(`[get-lmd-awb-sof-trigger]: ${e}`);
|
|
265
235
|
}
|
|
236
|
+
//
|
|
266
237
|
}
|
|
267
|
-
}
|
|
268
|
-
catch (e) {
|
|
269
|
-
env_1.logger.error(`[get-lmd-awb-sof-trigger]: ${e}`);
|
|
270
|
-
}
|
|
271
238
|
//
|
|
272
239
|
}
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
240
|
+
// generate packing worksheet based on orders WITH packing option
|
|
241
|
+
const pickPackOrders = uniqueReleaseGoods.filter(rg => rg.packingOption);
|
|
242
|
+
if (pickPackOrders === null || pickPackOrders === void 0 ? void 0 : pickPackOrders.length) {
|
|
243
|
+
const roNoList = pickPackOrders.map((rg) => rg.name);
|
|
244
|
+
const packingWSCtrl = new controllers_1.PackingWorksheetController(tx, domain, user);
|
|
245
|
+
await packingWSCtrl.generatePackingWorksheetByBulk(roNoList);
|
|
246
|
+
}
|
|
247
|
+
// generate packing worksheet with orderInventory based on orders WITHOUT packing option
|
|
248
|
+
const pickSortTargetInventories = targetInventories
|
|
249
|
+
.filter(targetInventory => !targetInventory.releaseGood.packingOption)
|
|
250
|
+
.map((pickSortTargetInventory) => {
|
|
251
|
+
return pickSortTargetInventory;
|
|
252
|
+
});
|
|
253
|
+
// loop to generate sorting worksheet
|
|
254
|
+
if (pickSortTargetInventories === null || pickSortTargetInventories === void 0 ? void 0 : pickSortTargetInventories.length) {
|
|
255
|
+
const sortingWSCtrl = new controllers_1.SortingWorksheetController(tx, domain, user);
|
|
256
|
+
await sortingWSCtrl.generateSortingWorksheet(worksheet, pickSortTargetInventories);
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
292
259
|
}
|
|
293
|
-
return false;
|
|
294
260
|
}
|
|
295
261
|
else {
|
|
296
262
|
let foundObsoleteInventories = worksheet;
|