@things-factory/worksheet-base 3.8.27 → 3.8.31
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/constants/template.js +1 -0
- package/dist-server/constants/template.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +32 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/render-invoices.js +134 -0
- package/dist-server/controllers/render-invoices.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +10 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +91 -84
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/routes.js +8 -0
- package/dist-server/routes.js.map +1 -1
- package/package.json +12 -12
- package/server/constants/template.ts +1 -0
- package/server/controllers/ecommerce/sellercraft-controller.ts +37 -1
- package/server/controllers/render-invoices.ts +148 -0
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +12 -1
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +104 -88
- package/server/routes.ts +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../server/constants/template.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,iBAAiB,EAAE,mBAAmB;IACtC,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE,MAAM;CACb,CAAA"}
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../server/constants/template.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE,MAAM;CACb,CAAA"}
|
|
@@ -6,6 +6,27 @@ const sales_base_1 = require("@things-factory/sales-base");
|
|
|
6
6
|
const warehouse_base_1 = require("@things-factory/warehouse-base");
|
|
7
7
|
const worksheet_controller_1 = require("../worksheet-controller");
|
|
8
8
|
class SellercraftController extends worksheet_controller_1.WorksheetController {
|
|
9
|
+
async packOrder(sellercraft, releaseGood) {
|
|
10
|
+
const orderProducts = releaseGood.orderProducts;
|
|
11
|
+
let sellercraftOPs = [];
|
|
12
|
+
sellercraftOPs = orderProducts.map(orderProduct => {
|
|
13
|
+
const product = orderProduct.product;
|
|
14
|
+
return {
|
|
15
|
+
sku: product.sku,
|
|
16
|
+
releaseQty: orderProduct.releaseQty,
|
|
17
|
+
uom: 'EA'
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
const orderInformation = {
|
|
21
|
+
accountId: sellercraft.accountId,
|
|
22
|
+
orderId: releaseGood.refNo2,
|
|
23
|
+
sellercraftOPs
|
|
24
|
+
};
|
|
25
|
+
const packageId = await integration_sellercraft_1.SellercraftAPI.packMarketplaceOrder(sellercraft, Object.assign({}, orderInformation));
|
|
26
|
+
releaseGood.packageId = packageId;
|
|
27
|
+
releaseGood.updater = this.user;
|
|
28
|
+
return releaseGood;
|
|
29
|
+
}
|
|
9
30
|
async registerProductInbound(sellercraft, arrivalNotice) {
|
|
10
31
|
const orderProducts = arrivalNotice.orderProducts;
|
|
11
32
|
const purchaseOrder = arrivalNotice.purchaseOrder;
|
|
@@ -61,12 +82,20 @@ class SellercraftController extends worksheet_controller_1.WorksheetController {
|
|
|
61
82
|
}
|
|
62
83
|
return {
|
|
63
84
|
sku: product.sku,
|
|
85
|
+
productName: product.name,
|
|
86
|
+
gtin: defaultProductDetail.gtin,
|
|
64
87
|
purchaseOrderQty: orderInventory.returnQty * packingSize,
|
|
65
88
|
receivedQty: orderInventory.returnQty * packingSize,
|
|
66
89
|
uom: 'EA',
|
|
67
90
|
batchId: orderInventory.batchId,
|
|
68
91
|
forceCreateProduct: false,
|
|
69
|
-
expiryTime: 0
|
|
92
|
+
expiryTime: 0,
|
|
93
|
+
weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
94
|
+
packageDimension: {
|
|
95
|
+
length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
96
|
+
width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
97
|
+
height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
98
|
+
}
|
|
70
99
|
};
|
|
71
100
|
}));
|
|
72
101
|
const returnInbound = {
|
|
@@ -131,6 +160,8 @@ class SellercraftController extends worksheet_controller_1.WorksheetController {
|
|
|
131
160
|
await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, { accountId: sellercraft.accountId, sellercraftInv });
|
|
132
161
|
}
|
|
133
162
|
async initiateOrderShipment(sellercraft, releaseGood) {
|
|
163
|
+
if (!(releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.packageId))
|
|
164
|
+
throw new Error('Order package id is not found');
|
|
134
165
|
const orderInformation = {
|
|
135
166
|
accountId: sellercraft.accountId,
|
|
136
167
|
orderId: releaseGood.refNo2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sellercraft-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/sellercraft-controller.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AAErF,2DAOmC;AACnC,mEAA2F;AAE3F,kEAA6D;AAE7D,MAAa,qBAAsB,SAAQ,0CAAmB;IAC5D,KAAK,CAAC,sBAAsB,CAAC,WAAwB,EAAE,aAA4B;QACjF,MAAM,aAAa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,MAAM,mBAAmB,GAAW,cAAc,CAAC,WAAW,CAAA;YAC9D,MAAM,oBAAoB,GAAkB,OAAO,CAAC,cAAc,CAAC,IAAI,CACrE,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,CACzC,CAAA;YAED,IAAI,WAAW,GAAW,CAAC,CAAA;YAC3B,IAAI,mBAAmB,KAAK,oBAAoB,CAAC,WAAW,EAAE;gBAC5D,MAAM,uBAAuB,GAAkB,OAAO,CAAC,cAAc,CAAC,IAAI,CACxE,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,WAAW,KAAK,mBAAmB,CACnE,CAAA;gBAED,WAAW,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,oBAAoB,EAAE,uBAAuB,CAAC,CAAA;aAC5G;YAED,OAAO;gBACL,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,gBAAgB,EAAE,cAAc,CAAC,SAAS,GAAG,WAAW;gBACxD,WAAW,EAAE,cAAc,CAAC,SAAS,GAAG,WAAW;gBACnD,GAAG,EAAE,IAAI;gBACT,OAAO,EAAE,cAAc,CAAC,OAAO;gBAC/B,kBAAkB,EAAE,KAAK;gBACzB,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"sellercraft-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/sellercraft-controller.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AAErF,2DAOmC;AACnC,mEAA2F;AAE3F,kEAA6D;AAE7D,MAAa,qBAAsB,SAAQ,0CAAmB;IAC5D,KAAK,CAAC,SAAS,CAAC,WAAwB,EAAE,WAAwB;QAChE,MAAM,aAAa,GAAmB,WAAW,CAAC,aAAa,CAAA;QAC/D,IAAI,cAAc,GAAU,EAAE,CAAA;QAE9B,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YAChD,MAAM,OAAO,GAAY,YAAY,CAAC,OAAO,CAAA;YAE7C,OAAO;gBACL,GAAG,EA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AAQ;YAC5B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,OAAO,EAAE,WAAW,CAAC,MAAM;YAC3B,SAAS,EAAE,WAAW,CAAC,SAAS;SACjC,CAAA;QACD,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAA6C,MAAM,wCAAc,CAAC,kBAAkB,CACjH,WAAW,oBAEN,gBAAgB,EAEtB,CAAA;QAED,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,EAAE;YACrB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBACvB,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;oBAC/B,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAA;iBAC5C;qBAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa,EAAE;oBAC1C,WAAW,CAAC,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAA;iBAC/C;YACH,CAAC,CAAC,CAAA;YAEF,WAAW,CAAC,UAAU,GAAG,UAAU,CAAA;YACnC,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAA;YAC/B,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,wBAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;SAC7E;QAED,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAnQD,sDAmQC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.renderInvoices = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
|
+
const typeorm_1 = require("typeorm");
|
|
10
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
11
|
+
const env_1 = require("@things-factory/env");
|
|
12
|
+
const sales_base_1 = require("@things-factory/sales-base");
|
|
13
|
+
const shell_1 = require("@things-factory/shell");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const datetime_util_1 = require("../utils/datetime-util");
|
|
16
|
+
const REPORT_API_URL = env_1.config.get('reportApiUrl', 'http://localhost:8888/rest/report/show_html');
|
|
17
|
+
async function renderInvoices({ req, timezoneOffSet }, context) {
|
|
18
|
+
try {
|
|
19
|
+
const domain = await (0, typeorm_1.getRepository)(shell_1.Domain).findOne({
|
|
20
|
+
where: { id: context.state.domain.id }
|
|
21
|
+
});
|
|
22
|
+
let result = await Promise.all(req.roIds.map(async (roId) => {
|
|
23
|
+
try {
|
|
24
|
+
const foundReleaseGoods = await (0, typeorm_1.getRepository)(sales_base_1.ReleaseGood).findOne({
|
|
25
|
+
where: { domain, id: roId },
|
|
26
|
+
relations: ['domain', 'bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
27
|
+
});
|
|
28
|
+
if (foundReleaseGoods) {
|
|
29
|
+
const foundInvoice = await (0, typeorm_1.getRepository)(sales_base_1.Invoice).findOne({
|
|
30
|
+
where: { releaseGood: foundReleaseGoods },
|
|
31
|
+
relations: ['invoiceProducts', 'invoiceProducts.product', 'domain', 'creator', 'updater']
|
|
32
|
+
});
|
|
33
|
+
const partnerBiz = foundReleaseGoods.bizplace;
|
|
34
|
+
const partnerCompanyDomain = foundReleaseGoods.bizplace.company.domain;
|
|
35
|
+
const foundTemplate = await (0, typeorm_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
36
|
+
where: { domain: partnerCompanyDomain, category: constants_1.TEMPLATE_TYPE.INVOICE_TEMPLATE }
|
|
37
|
+
});
|
|
38
|
+
const template = await attachment_base_1.STORAGE.readFile(foundTemplate.path, 'utf-8');
|
|
39
|
+
let fullBillingAddress = [
|
|
40
|
+
foundInvoice.billingAddress1,
|
|
41
|
+
foundInvoice.billingAddress2,
|
|
42
|
+
foundInvoice.billingAddress3,
|
|
43
|
+
foundInvoice.billingAddress4,
|
|
44
|
+
foundInvoice.billingAddress5
|
|
45
|
+
];
|
|
46
|
+
let fullDeliveryAddress = [
|
|
47
|
+
foundInvoice.deliveryAddress1,
|
|
48
|
+
foundInvoice.deliveryAddress2,
|
|
49
|
+
foundInvoice.deliveryAddress3,
|
|
50
|
+
foundInvoice.deliveryAddress4,
|
|
51
|
+
foundInvoice.deliveryAddress5,
|
|
52
|
+
];
|
|
53
|
+
let date = datetime_util_1.DateTimeConverter.date(new Date((foundInvoice.issuedOn || foundInvoice.createdAt) - timezoneOffSet));
|
|
54
|
+
const data = {
|
|
55
|
+
order_no: foundReleaseGoods.name,
|
|
56
|
+
ref_no: foundReleaseGoods.refNo,
|
|
57
|
+
deliver_to: foundInvoice.deliverTo,
|
|
58
|
+
deliver_to_phone: foundInvoice.deliverToPhone || '',
|
|
59
|
+
bill_to: foundInvoice.billTo,
|
|
60
|
+
bill_to_phone: foundInvoice.billToPhone || '',
|
|
61
|
+
customer_address: partnerBiz.address,
|
|
62
|
+
delivery_date: date,
|
|
63
|
+
store_name: foundInvoice.from,
|
|
64
|
+
billing_address_1: foundInvoice.billingAddress1,
|
|
65
|
+
billing_address_2: foundInvoice.billingAddress2,
|
|
66
|
+
billing_address_3: foundInvoice.billingAddress3,
|
|
67
|
+
billing_address_4: foundInvoice.billingAddress4,
|
|
68
|
+
billing_address_5: foundInvoice.billingAddress5,
|
|
69
|
+
billing_postcode: foundInvoice.billingPostcode,
|
|
70
|
+
billing_city: foundInvoice.billingCity,
|
|
71
|
+
billing_state: foundInvoice.billingState,
|
|
72
|
+
billing_country: foundInvoice.billingCountry,
|
|
73
|
+
full_billing_address: fullBillingAddress.reduce((acc, itm) => {
|
|
74
|
+
if (itm && itm.trim() != '') {
|
|
75
|
+
acc.push(itm);
|
|
76
|
+
}
|
|
77
|
+
return acc;
|
|
78
|
+
}, []).join(' '),
|
|
79
|
+
delivery_address_1: foundInvoice.deliveryAddress1,
|
|
80
|
+
delivery_address_2: foundInvoice.deliveryAddress2,
|
|
81
|
+
delivery_address_3: foundInvoice.deliveryAddress3,
|
|
82
|
+
delivery_address_4: foundInvoice.deliveryAddress4,
|
|
83
|
+
delivery_address_5: foundInvoice.deliveryAddress5,
|
|
84
|
+
delivery_postcode: foundInvoice.deliveryPostcode,
|
|
85
|
+
delivery_city: foundInvoice.deliveryCity,
|
|
86
|
+
delivery_state: foundInvoice.deliveryState,
|
|
87
|
+
delivery_country: foundInvoice.deliveryCountry,
|
|
88
|
+
full_delivery_address: fullDeliveryAddress.reduce((acc, itm) => {
|
|
89
|
+
if (itm && itm.trim() != '') {
|
|
90
|
+
acc.push(itm);
|
|
91
|
+
}
|
|
92
|
+
return acc;
|
|
93
|
+
}, []).join(' '),
|
|
94
|
+
product_list: foundInvoice.invoiceProducts.map((item, idx) => {
|
|
95
|
+
return {
|
|
96
|
+
list_no: idx + 1,
|
|
97
|
+
product_sku: item.sku,
|
|
98
|
+
product_name: item.name,
|
|
99
|
+
product_desc: item.description,
|
|
100
|
+
product_qty: item.qty,
|
|
101
|
+
product_other_charges: item.otherCharges,
|
|
102
|
+
product_paid_price: parseFloat(item.paidPrice || item.unitPrice).toFixed(2),
|
|
103
|
+
product_unit_price: parseFloat(item.unitPrice).toFixed(2),
|
|
104
|
+
product_total_paid_price: (parseFloat(item.paidPrice || item.unitPrice) * parseFloat(item.qty)).toFixed(2),
|
|
105
|
+
product_total_unit_price: (parseFloat(item.unitPrice) * parseFloat(item.qty)).toFixed(2)
|
|
106
|
+
};
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
const formData = new form_data_1.default();
|
|
110
|
+
formData.append('template', template);
|
|
111
|
+
formData.append('jsonString', JSON.stringify(data));
|
|
112
|
+
const response = await (0, node_fetch_1.default)(REPORT_API_URL, {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
body: formData
|
|
115
|
+
});
|
|
116
|
+
return await response.text();
|
|
117
|
+
}
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
120
|
+
catch (ex) {
|
|
121
|
+
return '';
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
if (result.length <= 0) {
|
|
125
|
+
throw Error('No invoice found!');
|
|
126
|
+
}
|
|
127
|
+
return result.join();
|
|
128
|
+
}
|
|
129
|
+
catch (ex) {
|
|
130
|
+
throw ex;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.renderInvoices = renderInvoices;
|
|
134
|
+
//# sourceMappingURL=render-invoices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-invoices.js","sourceRoot":"","sources":["../../server/controllers/render-invoices.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgC;AAChC,4DAA8B;AAC9B,qCAAoD;AAEpD,qEAAqE;AAGrE,6CAA4C;AAC5C,2DAA+I;AAC/I,iDAA8C;AAG9C,4CAA4D;AAE5D,0DAA0D;AAE1D,MAAM,cAAc,GAAG,YAAM,CAAC,GAAG,CAAC,cAAc,EAAE,6CAA6C,CAAC,CAAA;AAEzF,KAAK,UAAU,cAAc,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,OAAY;IACtE,IAAI;QACA,MAAM,MAAM,GAAW,MAAM,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE;SACzC,CAAC,CAAA;QAEF,IAAI,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;YACtD,IAAI;gBACA,MAAM,iBAAiB,GAAgB,MAAM,IAAA,uBAAa,EAAC,wBAAW,CAAC,CAAC,OAAO,CAAC;oBAC5E,KAAK,EAAE,EAAE,MAAM,EAAE,EA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,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;gCAC1G,wBAAwB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;6BAC3F,CAAA;wBACL,CAAC,CAAC;qBACL,CAAA;oBAED,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAA;oBAC/B,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;oBACrC,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;oBAEnD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,cAAc,EAAE;wBACzC,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,QAAQ;qBACjB,CAAC,CAAA;oBAEF,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;iBAC/B;gBACD,OAAO,EAAE,CAAA;aACZ;YAAC,OAAO,EAAE,EAAE;gBACT,OAAO,EAAE,CAAA;aACZ;QACL,CAAC,CAAC,CAAC,CAAA;QAGH,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACpB,MAAM,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACnC;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;KACvB;IAAC,OAAO,EAAE,EAAE;QACT,MAAM,EAAE,CAAA;KACX;AACL,CAAC;AAjID,wCAiIC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.completeBatchPicking = exports.completeBatchPickingResolver = void 0;
|
|
4
4
|
const biz_base_1 = require("@things-factory/biz-base");
|
|
5
5
|
const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
|
|
6
|
+
const sales_base_1 = require("@things-factory/sales-base");
|
|
6
7
|
const controllers_1 = require("../../../../controllers/");
|
|
7
8
|
const worksheet_controller_1 = require("../../../../controllers/worksheet-controller");
|
|
8
9
|
exports.completeBatchPickingResolver = {
|
|
@@ -39,7 +40,15 @@ async function completeBatchPicking(tx, domain, user, taskNo) {
|
|
|
39
40
|
}
|
|
40
41
|
await Promise.all(uniqueReleaseGoods.map(async (releaseGood) => {
|
|
41
42
|
const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
|
|
42
|
-
await
|
|
43
|
+
let foundReleaseGood = await tx.getRepository(sales_base_1.ReleaseGood).findOne({
|
|
44
|
+
where: { id: releaseGood.id },
|
|
45
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.product.productDetails']
|
|
46
|
+
});
|
|
47
|
+
if (!(foundReleaseGood === null || foundReleaseGood === void 0 ? void 0 : foundReleaseGood.packageId)) {
|
|
48
|
+
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, foundReleaseGood);
|
|
49
|
+
}
|
|
50
|
+
foundReleaseGood = await sellercraftCtrl.initiateOrderShipment(sellercraft, foundReleaseGood);
|
|
51
|
+
await sellercraftCtrl.initiateOrderDocument(sellercraft, foundReleaseGood);
|
|
43
52
|
}));
|
|
44
53
|
}
|
|
45
54
|
const pickPackTargetInventories = targetInventories
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete-batch-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts"],"names":[],"mappings":";;;AAGA,uDAAkE;AAClE,qFAAwF;
|
|
1
|
+
{"version":3,"file":"complete-batch-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts"],"names":[],"mappings":";;;AAGA,uDAAkE;AAClE,qFAAwF;AACxF,2DAAwE;AAGxE,0DAKiC;AACjC,uFAAkF;AAGrE,QAAA,4BAA4B,GAAG;IAC1C,KAAK,CAAC,oBAAoB,CAAC,CAAM,EAAE,EAAE,MAAM,EAAE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,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAA;SAC5D;KACF;IAED,IAAI,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,MAAM,EAAE;QACrC,MAAM,aAAa,GAA+B,IAAI,wCAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QAClG,MAAM,gBAAgB,GAAc,MAAM,aAAa,CAAC,wBAAwB,CAC9E,SAAS,EACT,yBAAyB,CAC1B,CAAA;QAED,MAAM,aAAa,CAAC,eAAe,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;KAC9F;AACH,CAAC;AAvFD,oDAuFC"}
|
|
@@ -33,15 +33,7 @@ async function completePicking(tx, domain, user, releaseGoodNo) {
|
|
|
33
33
|
const pickingWSCtrl = new controllers_1.PickingWorksheetController(tx, domain, user);
|
|
34
34
|
let releaseGood = await tx.getRepository(sales_base_1.ReleaseGood).findOne({
|
|
35
35
|
where: { domain, name: releaseGoodNo },
|
|
36
|
-
relations: [
|
|
37
|
-
'bizplace',
|
|
38
|
-
'bizplace.domain',
|
|
39
|
-
'bizplace.company',
|
|
40
|
-
'bizplace.company.domain',
|
|
41
|
-
'orderInventories',
|
|
42
|
-
'orderInventories.inventory',
|
|
43
|
-
'orderInventories.product'
|
|
44
|
-
]
|
|
36
|
+
relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
45
37
|
});
|
|
46
38
|
const worksheet = await pickingWSCtrl.findWorksheetByRefOrder(releaseGood, constants_1.WORKSHEET_TYPE.PICKING, [
|
|
47
39
|
'worksheetDetails',
|
|
@@ -63,6 +55,13 @@ async function completePicking(tx, domain, user, releaseGoodNo) {
|
|
|
63
55
|
.findOne({ domain: releaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
|
|
64
56
|
if (sellercraft) {
|
|
65
57
|
const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
|
|
58
|
+
if (!(releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.packageId)) {
|
|
59
|
+
const orderProducts = await tx.getRepository(sales_base_1.OrderProduct).find({
|
|
60
|
+
where: { releaseGood },
|
|
61
|
+
relations: ['product', 'product.productDetails']
|
|
62
|
+
});
|
|
63
|
+
releaseGood = await sellercraftCtrl.packOrder(sellercraft, Object.assign(Object.assign({}, releaseGood), { orderProducts }));
|
|
64
|
+
}
|
|
66
65
|
releaseGood = await sellercraftCtrl.initiateOrderShipment(sellercraft, releaseGood);
|
|
67
66
|
await sellercraftCtrl.initiateOrderDocument(sellercraft, releaseGood);
|
|
68
67
|
}
|
|
@@ -72,84 +71,92 @@ async function completePicking(tx, domain, user, releaseGoodNo) {
|
|
|
72
71
|
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
73
72
|
relations: ['marketplaceStore', 'marketplaceOrderItems', 'marketplaceOrderItems.marketplaceOrderShipping']
|
|
74
73
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
//Get which transporter to use
|
|
98
|
-
const marketplaceTransporter = await tx.getRepository(integration_marketplace_1.MarketplaceTransporter).findOne({
|
|
99
|
-
where: { marketplaceStore: marketplaceOrder.marketplaceStore },
|
|
100
|
-
relations: ['pickupTransporter', 'deliveryTransporter']
|
|
101
|
-
});
|
|
102
|
-
const resp = await integration_lmd_1.LastMileAPI.createShipmentRequest(lmd, {
|
|
103
|
-
orderNo: marketplaceOrder.orderNo,
|
|
104
|
-
clientId: lmd.clientId,
|
|
105
|
-
clientType: lmd.clientType,
|
|
106
|
-
clientName: lmd.clientName,
|
|
107
|
-
transporterId: marketplaceTransporter.pickupTransporter.transporterId,
|
|
108
|
-
pickupName: warehouseContactPoint.name,
|
|
109
|
-
pickupAddress1: warehouseContactPoint.address,
|
|
110
|
-
pickupAddress2: warehouseContactPoint.address2,
|
|
111
|
-
pickupPostcode: warehouseContactPoint.postCode,
|
|
112
|
-
pickupState: warehouseContactPoint.state,
|
|
113
|
-
pickupCity: warehouseContactPoint.city,
|
|
114
|
-
pickupPhone: warehouseContactPoint.phone,
|
|
115
|
-
pickupEmail: warehouseContactPoint.email,
|
|
116
|
-
name: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.attentionTo) ? marketplaceOrderShipping.attentionTo.trim() : '',
|
|
117
|
-
address1: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address1) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address1.trim() : '-',
|
|
118
|
-
address2: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address2) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address2.trim() : '-',
|
|
119
|
-
postCode: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.postCode) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.postCode.trim() : '',
|
|
120
|
-
city: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.city) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.city.trim() : '',
|
|
121
|
-
state: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.state) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.state.trim() : '',
|
|
122
|
-
phone: marketplaceOrderShipping.phone1 || '',
|
|
123
|
-
email: marketplaceOrderShipping.email || '',
|
|
124
|
-
attentionTo: marketplaceOrderShipping.attentionTo,
|
|
125
|
-
quantity: marketplaceOrderItems.length
|
|
126
|
-
});
|
|
127
|
-
const delay = (ms) => {
|
|
128
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
129
|
-
};
|
|
130
|
-
if (resp.Status === 'SUCCESS') {
|
|
131
|
-
//Success
|
|
132
|
-
let awbObtained = false;
|
|
133
|
-
let retry = 0;
|
|
134
|
-
while (!awbObtained) {
|
|
135
|
-
const marketplaceOrder2 = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
136
|
-
where: { releaseOrderId: releaseGood.id },
|
|
137
|
-
relations: ['marketplaceStore', 'marketplaceOrderItems', 'marketplaceOrderItems.marketplaceOrderShipping']
|
|
138
|
-
});
|
|
139
|
-
const orderShipping = marketplaceOrder2.marketplaceOrderItems[0].marketplaceOrderShipping;
|
|
140
|
-
if (orderShipping === null || orderShipping === void 0 ? void 0 : orderShipping.airwayBill) {
|
|
141
|
-
awbObtained = true;
|
|
74
|
+
if (marketplaceOrder) {
|
|
75
|
+
const marketplaceStore = marketplaceOrder.marketplaceStore;
|
|
76
|
+
let eTraxOption;
|
|
77
|
+
if (marketplaceStore.isAutoUpdateShipment) {
|
|
78
|
+
const ecommerceCtrl = new ecommerce_1.EcommerceController(tx, domain, user);
|
|
79
|
+
await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, sales_base_1.ORDER_STATUS.PACKING);
|
|
80
|
+
}
|
|
81
|
+
if (!marketplaceOrder)
|
|
82
|
+
throw new Error('Failed to find ecommerce order, kindly contact our support team regarding this issue');
|
|
83
|
+
eTraxOption = marketplaceOrder === null || marketplaceOrder === void 0 ? void 0 : marketplaceOrder.marketplaceStore.eTrax;
|
|
84
|
+
// if eTrax option is true
|
|
85
|
+
if (eTraxOption) {
|
|
86
|
+
const marketplaceOrderItems = marketplaceOrder.marketplaceOrderItems;
|
|
87
|
+
// access every marketplaceOrderItems for shipping information you need
|
|
88
|
+
// trigger the controller from integration-lmd that trigger the API, build the parameters needed
|
|
89
|
+
// for etrax didn't support multi awb per order
|
|
90
|
+
const marketplaceOrderShipping = marketplaceOrderItems[0].marketplaceOrderShipping;
|
|
91
|
+
const lmd = await tx.getRepository(integration_lmd_1.LastMileDelivery).findOne({
|
|
92
|
+
where: {
|
|
93
|
+
domain,
|
|
94
|
+
platform: 'eTrax'
|
|
142
95
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
96
|
+
});
|
|
97
|
+
//Get which transporter to use
|
|
98
|
+
const marketplaceTransporter = await tx
|
|
99
|
+
.getRepository(integration_marketplace_1.MarketplaceTransporter)
|
|
100
|
+
.findOne({
|
|
101
|
+
where: { marketplaceStore: marketplaceOrder.marketplaceStore },
|
|
102
|
+
relations: ['pickupTransporter', 'deliveryTransporter']
|
|
103
|
+
});
|
|
104
|
+
const resp = await integration_lmd_1.LastMileAPI.createShipmentRequest(lmd, {
|
|
105
|
+
orderNo: marketplaceOrder.orderNo,
|
|
106
|
+
clientId: lmd.clientId,
|
|
107
|
+
clientType: lmd.clientType,
|
|
108
|
+
clientName: lmd.clientName,
|
|
109
|
+
transporterId: marketplaceTransporter.pickupTransporter.transporterId,
|
|
110
|
+
pickupName: warehouseContactPoint.name,
|
|
111
|
+
pickupAddress1: warehouseContactPoint.address,
|
|
112
|
+
pickupAddress2: warehouseContactPoint.address2,
|
|
113
|
+
pickupPostcode: warehouseContactPoint.postCode,
|
|
114
|
+
pickupState: warehouseContactPoint.state,
|
|
115
|
+
pickupCity: warehouseContactPoint.city,
|
|
116
|
+
pickupPhone: warehouseContactPoint.phone,
|
|
117
|
+
pickupEmail: warehouseContactPoint.email,
|
|
118
|
+
name: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.attentionTo) ? marketplaceOrderShipping.attentionTo.trim() : '',
|
|
119
|
+
address1: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address1) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address1.trim() : '-',
|
|
120
|
+
address2: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address2) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.address2.trim() : '-',
|
|
121
|
+
postCode: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.postCode) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.postCode.trim() : '',
|
|
122
|
+
city: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.city) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.city.trim() : '',
|
|
123
|
+
state: (marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.state) ? marketplaceOrderShipping === null || marketplaceOrderShipping === void 0 ? void 0 : marketplaceOrderShipping.state.trim() : '',
|
|
124
|
+
phone: marketplaceOrderShipping.phone1 || '',
|
|
125
|
+
email: marketplaceOrderShipping.email || '',
|
|
126
|
+
attentionTo: marketplaceOrderShipping.attentionTo,
|
|
127
|
+
quantity: marketplaceOrderItems.length
|
|
128
|
+
});
|
|
129
|
+
const delay = (ms) => {
|
|
130
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
131
|
+
};
|
|
132
|
+
if (resp.Status === 'SUCCESS') {
|
|
133
|
+
//Success
|
|
134
|
+
let awbObtained = false;
|
|
135
|
+
let retry = 0;
|
|
136
|
+
while (!awbObtained) {
|
|
137
|
+
const marketplaceOrder2 = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
138
|
+
where: { releaseOrderId: releaseGood.id },
|
|
139
|
+
relations: [
|
|
140
|
+
'marketplaceStore',
|
|
141
|
+
'marketplaceOrderItems',
|
|
142
|
+
'marketplaceOrderItems.marketplaceOrderShipping'
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
const orderShipping = marketplaceOrder2.marketplaceOrderItems[0].marketplaceOrderShipping;
|
|
146
|
+
if (orderShipping === null || orderShipping === void 0 ? void 0 : orderShipping.airwayBill) {
|
|
147
|
+
awbObtained = true;
|
|
148
|
+
}
|
|
149
|
+
await delay(5000);
|
|
150
|
+
//Timeout after 15sec
|
|
151
|
+
if (++retry > 3) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
else {
|
|
157
|
+
throw resp;
|
|
158
|
+
//Failed
|
|
159
|
+
}
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/complete-picking.ts"],"names":[],"mappings":";;;AAGA,uDAAgF;AAChF,qEAA+E;AAC/E,qFAAkG;AAClG,qFAAwF;AACxF,uEAAuF;AACvF,uEAAmH;AACnH,
|
|
1
|
+
{"version":3,"file":"complete-picking.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/worksheet/picking/complete-picking.ts"],"names":[],"mappings":";;;AAGA,uDAAgF;AAChF,qEAA+E;AAC/E,qFAAkG;AAClG,qFAAwF;AACxF,uEAAuF;AACvF,uEAAmH;AACnH,2DAMmC;AACnC,+DAAsE;AAGtE,qDAAwE;AACxE,0DAKiC;AACjC,iEAAuE;AACvE,uFAAkF;AAClF,mDAAiE;AAEpD,QAAA,uBAAuB,GAAG;IACrC,KAAK,CAAC,eAAe,CAAC,CAAM,EAAE,EAAE,aAAa,EAAE,EAAE,OAAY;QAC3D,MAAM,EA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AAI,wCAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;YAClG,IAAI,gBAAgB,GAAc,MAAM,aAAa,CAAC,wBAAwB,CAC5E,aAAa,EACb,uBAAuB,CACxB,CAAA;YAED,IAAI,CAAC,CAAA,MAAA,gBAAgB,CAAC,gBAAgB,0CAAE,MAAM,CAAA,EAAE;gBAC9C,gBAAgB,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAA;aAC9E;YAED,MAAM,uBAAuB,GAAsB,gBAAgB,CAAC,gBAAgB,CAAA;YACpF,MAAM,aAAa,CAAC,eAAe,CAAC,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAA;SACpF;aAAM;YACL,MAAM,aAAa,GAA+B,IAAI,wCAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;YAClG,IAAI,gBAAgB,GAAc,MAAM,aAAa,CAAC,sBAAsB,CAC1E,aAAa,EACb,uBAAuB,EACvB,qBAAqB,CACtB,CAAA;YAED,IAAI,CAAC,CAAA,MAAA,gBAAgB,CAAC,gBAAgB,0CAAE,MAAM,CAAA,EAAE;gBAC9C,gBAAgB,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAA;aAC9E;YAED,MAAM,uBAAuB,GAAsB,gBAAgB,CAAC,gBAAgB,CAAA;YACpF,MAAM,aAAa,CAAC,eAAe,CAAC,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAA;SACpF;KACF;AACH,CAAC;AA5PD,0CA4PC"}
|
package/dist-server/routes.js
CHANGED
|
@@ -10,6 +10,7 @@ const render_orientage_do_1 = require("./controllers/render-orientage-do");
|
|
|
10
10
|
const render_orientage_grn_1 = require("./controllers/render-orientage-grn");
|
|
11
11
|
const render_ro_do_1 = require("./controllers/render-ro-do");
|
|
12
12
|
const render_seebuu_grn_1 = require("./controllers/render-seebuu-grn");
|
|
13
|
+
const render_invoices_1 = require("./controllers/render-invoices");
|
|
13
14
|
process.on('bootstrap-module-domain-private-route', (app, routes) => {
|
|
14
15
|
routes.get('/view_document_ro_do/:doNo', async (context, next) => {
|
|
15
16
|
context.body = await (0, render_ro_do_1.renderRODO)(context.params, context);
|
|
@@ -41,5 +42,12 @@ process.on('bootstrap-module-domain-private-route', (app, routes) => {
|
|
|
41
42
|
routes.get('/view_manifest/:manifestNo', async (context, next) => {
|
|
42
43
|
context.body = await (0, render_manifest_1.renderManifest)(context.params, context);
|
|
43
44
|
});
|
|
45
|
+
routes.post('/view_invoices/:timezoneOffSet', async (context, next) => {
|
|
46
|
+
let req = context.request.body || {};
|
|
47
|
+
let timezoneOffSet = context.params.timezoneOffSet || 0;
|
|
48
|
+
let data = await (0, render_invoices_1.renderInvoices)({ req, timezoneOffSet }, context);
|
|
49
|
+
context.type = 'application/json';
|
|
50
|
+
context.body = data;
|
|
51
|
+
});
|
|
44
52
|
});
|
|
45
53
|
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,qEAA+D;AAC/D,yDAAoD;AACpD,qEAA+D;AAC/D,uEAAiE;AACjE,mEAA8D;AAC9D,qEAA+D;AAC/D,2EAAqE;AACrE,6EAAuE;AACvE,6DAAuD;AACvD,uEAAiE;
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,qEAA+D;AAC/D,yDAAoD;AACpD,qEAA+D;AAC/D,uEAAiE;AACjE,mEAA8D;AAC9D,qEAA+D;AAC/D,2EAAqE;AACrE,6EAAuE;AACvE,6DAAuD;AACvD,uEAAiE;AACjE,mEAA8D;AAE9D,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACzE,MAAM,CAAC,GAA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C,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;IACrB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.31",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@things-factory/auth-base": "^3.8.0",
|
|
28
|
-
"@things-factory/biz-base": "^3.8.
|
|
29
|
-
"@things-factory/document-template-base": "^3.8.
|
|
28
|
+
"@things-factory/biz-base": "^3.8.29",
|
|
29
|
+
"@things-factory/document-template-base": "^3.8.29",
|
|
30
30
|
"@things-factory/id-rule-base": "^3.8.0",
|
|
31
|
-
"@things-factory/integration-lmd": "^3.8.
|
|
32
|
-
"@things-factory/integration-marketplace": "^3.8.
|
|
33
|
-
"@things-factory/integration-sellercraft": "^3.8.
|
|
34
|
-
"@things-factory/integration-sftp": "^3.8.
|
|
35
|
-
"@things-factory/marketplace-base": "^3.8.
|
|
31
|
+
"@things-factory/integration-lmd": "^3.8.29",
|
|
32
|
+
"@things-factory/integration-marketplace": "^3.8.29",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^3.8.29",
|
|
34
|
+
"@things-factory/integration-sftp": "^3.8.29",
|
|
35
|
+
"@things-factory/marketplace-base": "^3.8.31",
|
|
36
36
|
"@things-factory/notification": "^3.8.0",
|
|
37
|
-
"@things-factory/sales-base": "^3.8.
|
|
37
|
+
"@things-factory/sales-base": "^3.8.31",
|
|
38
38
|
"@things-factory/setting-base": "^3.8.0",
|
|
39
39
|
"@things-factory/shell": "^3.8.0",
|
|
40
|
-
"@things-factory/transport-base": "^3.8.
|
|
41
|
-
"@things-factory/warehouse-base": "^3.8.
|
|
40
|
+
"@things-factory/transport-base": "^3.8.29",
|
|
41
|
+
"@things-factory/warehouse-base": "^3.8.31"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "5deb948aa45a0aea4d787b5380667dc0c9d1f889"
|
|
44
44
|
}
|
|
@@ -13,6 +13,32 @@ import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/ware
|
|
|
13
13
|
import { WorksheetController } from '../worksheet-controller'
|
|
14
14
|
|
|
15
15
|
export class SellercraftController extends WorksheetController {
|
|
16
|
+
async packOrder(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<ReleaseGood> {
|
|
17
|
+
const orderProducts: OrderProduct[] = releaseGood.orderProducts
|
|
18
|
+
let sellercraftOPs: any[] = []
|
|
19
|
+
|
|
20
|
+
sellercraftOPs = orderProducts.map(orderProduct => {
|
|
21
|
+
const product: Product = orderProduct.product
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
sku: product.sku,
|
|
25
|
+
releaseQty: orderProduct.releaseQty,
|
|
26
|
+
uom: 'EA'
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const orderInformation: any = {
|
|
31
|
+
accountId: sellercraft.accountId,
|
|
32
|
+
orderId: releaseGood.refNo2,
|
|
33
|
+
sellercraftOPs
|
|
34
|
+
}
|
|
35
|
+
const packageId: string = await SellercraftAPI.packMarketplaceOrder(sellercraft, { ...orderInformation })
|
|
36
|
+
|
|
37
|
+
releaseGood.packageId = packageId
|
|
38
|
+
releaseGood.updater = this.user
|
|
39
|
+
return releaseGood
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
async registerProductInbound(sellercraft: Sellercraft, arrivalNotice: ArrivalNotice): Promise<void> {
|
|
17
43
|
const orderProducts: OrderProduct[] = arrivalNotice.orderProducts
|
|
18
44
|
const purchaseOrder: PurchaseOrder = arrivalNotice.purchaseOrder
|
|
@@ -87,12 +113,20 @@ export class SellercraftController extends WorksheetController {
|
|
|
87
113
|
|
|
88
114
|
return {
|
|
89
115
|
sku: product.sku,
|
|
116
|
+
productName: product.name,
|
|
117
|
+
gtin: defaultProductDetail.gtin,
|
|
90
118
|
purchaseOrderQty: orderInventory.returnQty * packingSize,
|
|
91
119
|
receivedQty: orderInventory.returnQty * packingSize,
|
|
92
120
|
uom: 'EA',
|
|
93
121
|
batchId: orderInventory.batchId,
|
|
94
122
|
forceCreateProduct: false,
|
|
95
|
-
expiryTime: 0
|
|
123
|
+
expiryTime: 0,
|
|
124
|
+
weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
125
|
+
packageDimension: {
|
|
126
|
+
length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
127
|
+
width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
128
|
+
height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
129
|
+
}
|
|
96
130
|
}
|
|
97
131
|
})
|
|
98
132
|
)
|
|
@@ -174,6 +208,8 @@ export class SellercraftController extends WorksheetController {
|
|
|
174
208
|
}
|
|
175
209
|
|
|
176
210
|
async initiateOrderShipment(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<ReleaseGood> {
|
|
211
|
+
if (!releaseGood?.packageId) throw new Error('Order package id is not found')
|
|
212
|
+
|
|
177
213
|
const orderInformation: any = {
|
|
178
214
|
accountId: sellercraft.accountId,
|
|
179
215
|
orderId: releaseGood.refNo2,
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import FormData from 'form-data'
|
|
2
|
+
import fetch from 'node-fetch'
|
|
3
|
+
import { getRepository, IsNull, Not } from 'typeorm'
|
|
4
|
+
|
|
5
|
+
import { Attachment, STORAGE } from '@things-factory/attachment-base'
|
|
6
|
+
import { Partner } from '@things-factory/auth-base'
|
|
7
|
+
import { Bizplace, Company, ContactPoint } from '@things-factory/biz-base'
|
|
8
|
+
import { config } from '@things-factory/env'
|
|
9
|
+
import { ArrivalNotice, GoodsReceivalNote, ORDER_STATUS, OrderProduct, ReleaseGood, Invoice, InvoiceProduct } from '@things-factory/sales-base'
|
|
10
|
+
import { Domain } from '@things-factory/shell'
|
|
11
|
+
import { ReducedInventoryHistory } from '@things-factory/warehouse-base'
|
|
12
|
+
|
|
13
|
+
import { TEMPLATE_TYPE, WORKSHEET_TYPE } from '../constants'
|
|
14
|
+
import { Worksheet } from '../entities'
|
|
15
|
+
import { DateTimeConverter } from '../utils/datetime-util'
|
|
16
|
+
|
|
17
|
+
const REPORT_API_URL = config.get('reportApiUrl', 'http://localhost:8888/rest/report/show_html')
|
|
18
|
+
|
|
19
|
+
export async function renderInvoices({ req, timezoneOffSet }, context: any) {
|
|
20
|
+
try {
|
|
21
|
+
const domain: Domain = await getRepository(Domain).findOne({
|
|
22
|
+
where: { id: context.state.domain.id }
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
let result = await Promise.all(req.roIds.map(async roId => {
|
|
26
|
+
try {
|
|
27
|
+
const foundReleaseGoods: ReleaseGood = await getRepository(ReleaseGood).findOne({
|
|
28
|
+
where: { domain, id: roId },
|
|
29
|
+
relations: ['domain', 'bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
if (foundReleaseGoods) {
|
|
33
|
+
const foundInvoice: Invoice = await getRepository(Invoice).findOne({
|
|
34
|
+
where: { releaseGood: foundReleaseGoods },
|
|
35
|
+
relations: ['invoiceProducts', 'invoiceProducts.product', 'domain', 'creator', 'updater']
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const partnerBiz: Bizplace = foundReleaseGoods.bizplace
|
|
39
|
+
|
|
40
|
+
const partnerCompanyDomain: Domain = foundReleaseGoods.bizplace.company.domain
|
|
41
|
+
|
|
42
|
+
const foundTemplate: Attachment = await getRepository(Attachment).findOne({
|
|
43
|
+
where: { domain: partnerCompanyDomain, category: TEMPLATE_TYPE.INVOICE_TEMPLATE }
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const template = await STORAGE.readFile(foundTemplate.path, 'utf-8')
|
|
47
|
+
|
|
48
|
+
let fullBillingAddress = [
|
|
49
|
+
foundInvoice.billingAddress1,
|
|
50
|
+
foundInvoice.billingAddress2,
|
|
51
|
+
foundInvoice.billingAddress3,
|
|
52
|
+
foundInvoice.billingAddress4,
|
|
53
|
+
foundInvoice.billingAddress5
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
let fullDeliveryAddress = [
|
|
57
|
+
foundInvoice.deliveryAddress1,
|
|
58
|
+
foundInvoice.deliveryAddress2,
|
|
59
|
+
foundInvoice.deliveryAddress3,
|
|
60
|
+
foundInvoice.deliveryAddress4,
|
|
61
|
+
foundInvoice.deliveryAddress5,
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
let date = DateTimeConverter.date(new Date((foundInvoice.issuedOn || foundInvoice.createdAt) - timezoneOffSet))
|
|
65
|
+
const data = {
|
|
66
|
+
order_no: foundReleaseGoods.name,
|
|
67
|
+
ref_no: foundReleaseGoods.refNo,
|
|
68
|
+
deliver_to: foundInvoice.deliverTo,
|
|
69
|
+
deliver_to_phone: foundInvoice.deliverToPhone || '',
|
|
70
|
+
bill_to: foundInvoice.billTo,
|
|
71
|
+
bill_to_phone: foundInvoice.billToPhone || '',
|
|
72
|
+
customer_address: partnerBiz.address,
|
|
73
|
+
delivery_date: date,
|
|
74
|
+
store_name: foundInvoice.from,
|
|
75
|
+
billing_address_1: foundInvoice.billingAddress1,
|
|
76
|
+
billing_address_2: foundInvoice.billingAddress2,
|
|
77
|
+
billing_address_3: foundInvoice.billingAddress3,
|
|
78
|
+
billing_address_4: foundInvoice.billingAddress4,
|
|
79
|
+
billing_address_5: foundInvoice.billingAddress5,
|
|
80
|
+
billing_postcode: foundInvoice.billingPostcode,
|
|
81
|
+
billing_city: foundInvoice.billingCity,
|
|
82
|
+
billing_state: foundInvoice.billingState,
|
|
83
|
+
billing_country: foundInvoice.billingCountry,
|
|
84
|
+
full_billing_address: fullBillingAddress.reduce((acc, itm) => {
|
|
85
|
+
if (itm && itm.trim() != '') {
|
|
86
|
+
acc.push(itm)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return acc
|
|
90
|
+
}, []).join(' '),
|
|
91
|
+
delivery_address_1: foundInvoice.deliveryAddress1,
|
|
92
|
+
delivery_address_2: foundInvoice.deliveryAddress2,
|
|
93
|
+
delivery_address_3: foundInvoice.deliveryAddress3,
|
|
94
|
+
delivery_address_4: foundInvoice.deliveryAddress4,
|
|
95
|
+
delivery_address_5: foundInvoice.deliveryAddress5,
|
|
96
|
+
delivery_postcode: foundInvoice.deliveryPostcode,
|
|
97
|
+
delivery_city: foundInvoice.deliveryCity,
|
|
98
|
+
delivery_state: foundInvoice.deliveryState,
|
|
99
|
+
delivery_country: foundInvoice.deliveryCountry,
|
|
100
|
+
full_delivery_address: fullDeliveryAddress.reduce((acc, itm) => {
|
|
101
|
+
if (itm && itm.trim() != '') {
|
|
102
|
+
acc.push(itm)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return acc
|
|
106
|
+
}, []).join(' '),
|
|
107
|
+
product_list: foundInvoice.invoiceProducts.map((item, idx) => {
|
|
108
|
+
return {
|
|
109
|
+
list_no: idx + 1,
|
|
110
|
+
product_sku: item.sku,
|
|
111
|
+
product_name: item.name,
|
|
112
|
+
product_desc: item.description,
|
|
113
|
+
product_qty: item.qty,
|
|
114
|
+
product_other_charges: item.otherCharges,
|
|
115
|
+
product_paid_price: parseFloat(item.paidPrice || item.unitPrice).toFixed(2),
|
|
116
|
+
product_unit_price: parseFloat(item.unitPrice).toFixed(2),
|
|
117
|
+
product_total_paid_price: (parseFloat(item.paidPrice || item.unitPrice) * parseFloat(item.qty)).toFixed(2),
|
|
118
|
+
product_total_unit_price: (parseFloat(item.unitPrice) * parseFloat(item.qty)).toFixed(2)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const formData = new FormData()
|
|
124
|
+
formData.append('template', template)
|
|
125
|
+
formData.append('jsonString', JSON.stringify(data))
|
|
126
|
+
|
|
127
|
+
const response = await fetch(REPORT_API_URL, {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
body: formData
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
return await response.text()
|
|
133
|
+
}
|
|
134
|
+
return ''
|
|
135
|
+
} catch (ex) {
|
|
136
|
+
return ''
|
|
137
|
+
}
|
|
138
|
+
}))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if (result.length <= 0) {
|
|
142
|
+
throw Error('No invoice found!')
|
|
143
|
+
}
|
|
144
|
+
return result.join()
|
|
145
|
+
} catch (ex) {
|
|
146
|
+
throw ex
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -64,7 +64,18 @@ export async function completeBatchPicking(
|
|
|
64
64
|
await Promise.all(
|
|
65
65
|
uniqueReleaseGoods.map(async releaseGood => {
|
|
66
66
|
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
let foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
69
|
+
where: { id: releaseGood.id },
|
|
70
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.product.productDetails']
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
if (!foundReleaseGood?.packageId) {
|
|
74
|
+
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, foundReleaseGood)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
foundReleaseGood = await sellercraftCtrl.initiateOrderShipment(sellercraft, foundReleaseGood)
|
|
78
|
+
await sellercraftCtrl.initiateOrderDocument(sellercraft, foundReleaseGood)
|
|
68
79
|
})
|
|
69
80
|
)
|
|
70
81
|
}
|
|
@@ -7,7 +7,13 @@ import { MarketplaceStore, MarketplaceTransporter } from '@things-factory/integr
|
|
|
7
7
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
8
8
|
import { COMPLETEDATAPATH, generateFile, Sftp } from '@things-factory/integration-sftp'
|
|
9
9
|
import { MarketplaceOrder, MarketplaceOrderItem, MarketplaceOrderShipping } from '@things-factory/marketplace-base'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ORDER_INVENTORY_STATUS,
|
|
12
|
+
ORDER_STATUS,
|
|
13
|
+
OrderInventory,
|
|
14
|
+
OrderProduct,
|
|
15
|
+
ReleaseGood
|
|
16
|
+
} from '@things-factory/sales-base'
|
|
11
17
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
12
18
|
import { Domain } from '@things-factory/shell'
|
|
13
19
|
|
|
@@ -48,15 +54,7 @@ export async function completePicking(
|
|
|
48
54
|
const pickingWSCtrl: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
|
|
49
55
|
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
50
56
|
where: { domain, name: releaseGoodNo },
|
|
51
|
-
relations: [
|
|
52
|
-
'bizplace',
|
|
53
|
-
'bizplace.domain',
|
|
54
|
-
'bizplace.company',
|
|
55
|
-
'bizplace.company.domain',
|
|
56
|
-
'orderInventories',
|
|
57
|
-
'orderInventories.inventory',
|
|
58
|
-
'orderInventories.product'
|
|
59
|
-
]
|
|
57
|
+
relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
60
58
|
})
|
|
61
59
|
|
|
62
60
|
const worksheet: Worksheet = await pickingWSCtrl.findWorksheetByRefOrder(releaseGood, WORKSHEET_TYPE.PICKING, [
|
|
@@ -86,6 +84,15 @@ export async function completePicking(
|
|
|
86
84
|
|
|
87
85
|
if (sellercraft) {
|
|
88
86
|
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
87
|
+
|
|
88
|
+
if (!releaseGood?.packageId) {
|
|
89
|
+
const orderProducts: OrderProduct[] = await tx.getRepository(OrderProduct).find({
|
|
90
|
+
where: { releaseGood },
|
|
91
|
+
relations: ['product', 'product.productDetails']
|
|
92
|
+
})
|
|
93
|
+
releaseGood = await sellercraftCtrl.packOrder(sellercraft, { ...releaseGood, orderProducts })
|
|
94
|
+
}
|
|
95
|
+
|
|
89
96
|
releaseGood = await sellercraftCtrl.initiateOrderShipment(sellercraft, releaseGood)
|
|
90
97
|
await sellercraftCtrl.initiateOrderDocument(sellercraft, releaseGood)
|
|
91
98
|
} else {
|
|
@@ -94,91 +101,100 @@ export async function completePicking(
|
|
|
94
101
|
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
95
102
|
relations: ['marketplaceStore', 'marketplaceOrderItems', 'marketplaceOrderItems.marketplaceOrderShipping']
|
|
96
103
|
})
|
|
97
|
-
const marketplaceStore: MarketplaceStore = marketplaceOrder.marketplaceStore
|
|
98
|
-
let eTraxOption: boolean
|
|
99
|
-
|
|
100
|
-
if (marketplaceStore.isAutoUpdateShipment) {
|
|
101
|
-
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
102
|
-
await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, ORDER_STATUS.PACKING)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!marketplaceOrder)
|
|
106
|
-
throw new Error('Failed to find ecommerce order, kindly contact our support team regarding this issue')
|
|
107
|
-
eTraxOption = marketplaceOrder?.marketplaceStore.eTrax
|
|
108
|
-
|
|
109
|
-
// if eTrax option is true
|
|
110
|
-
if (eTraxOption) {
|
|
111
|
-
const marketplaceOrderItems: MarketplaceOrderItem[] = marketplaceOrder.marketplaceOrderItems
|
|
112
|
-
|
|
113
|
-
// access every marketplaceOrderItems for shipping information you need
|
|
114
|
-
// trigger the controller from integration-lmd that trigger the API, build the parameters needed
|
|
115
|
-
// for etrax didn't support multi awb per order
|
|
116
|
-
const marketplaceOrderShipping: MarketplaceOrderShipping = marketplaceOrderItems[0].marketplaceOrderShipping
|
|
117
|
-
const lmd: LastMileDelivery = await tx.getRepository(LastMileDelivery).findOne({
|
|
118
|
-
where: {
|
|
119
|
-
domain,
|
|
120
|
-
platform: 'eTrax'
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
104
|
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
relations: ['pickupTransporter', 'deliveryTransporter']
|
|
128
|
-
})
|
|
105
|
+
if (marketplaceOrder) {
|
|
106
|
+
const marketplaceStore: MarketplaceStore = marketplaceOrder.marketplaceStore
|
|
107
|
+
let eTraxOption: boolean
|
|
129
108
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
clientType: lmd.clientType,
|
|
134
|
-
clientName: lmd.clientName,
|
|
135
|
-
transporterId: marketplaceTransporter.pickupTransporter.transporterId,
|
|
136
|
-
pickupName: warehouseContactPoint.name,
|
|
137
|
-
pickupAddress1: warehouseContactPoint.address,
|
|
138
|
-
pickupAddress2: warehouseContactPoint.address2,
|
|
139
|
-
pickupPostcode: warehouseContactPoint.postCode,
|
|
140
|
-
pickupState: warehouseContactPoint.state,
|
|
141
|
-
pickupCity: warehouseContactPoint.city,
|
|
142
|
-
pickupPhone: warehouseContactPoint.phone,
|
|
143
|
-
pickupEmail: warehouseContactPoint.email,
|
|
144
|
-
name: marketplaceOrderShipping?.attentionTo ? marketplaceOrderShipping.attentionTo.trim() : '',
|
|
145
|
-
address1: marketplaceOrderShipping?.address1 ? marketplaceOrderShipping?.address1.trim() : '-',
|
|
146
|
-
address2: marketplaceOrderShipping?.address2 ? marketplaceOrderShipping?.address2.trim() : '-',
|
|
147
|
-
postCode: marketplaceOrderShipping?.postCode ? marketplaceOrderShipping?.postCode.trim() : '',
|
|
148
|
-
city: marketplaceOrderShipping?.city ? marketplaceOrderShipping?.city.trim() : '',
|
|
149
|
-
state: marketplaceOrderShipping?.state ? marketplaceOrderShipping?.state.trim() : '',
|
|
150
|
-
phone: marketplaceOrderShipping.phone1 || '',
|
|
151
|
-
email: marketplaceOrderShipping.email || '',
|
|
152
|
-
attentionTo: marketplaceOrderShipping.attentionTo,
|
|
153
|
-
quantity: marketplaceOrderItems.length
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
const delay = (ms: number) => {
|
|
157
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
109
|
+
if (marketplaceStore.isAutoUpdateShipment) {
|
|
110
|
+
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
111
|
+
await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, ORDER_STATUS.PACKING)
|
|
158
112
|
}
|
|
159
113
|
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
114
|
+
if (!marketplaceOrder)
|
|
115
|
+
throw new Error('Failed to find ecommerce order, kindly contact our support team regarding this issue')
|
|
116
|
+
eTraxOption = marketplaceOrder?.marketplaceStore.eTrax
|
|
117
|
+
|
|
118
|
+
// if eTrax option is true
|
|
119
|
+
if (eTraxOption) {
|
|
120
|
+
const marketplaceOrderItems: MarketplaceOrderItem[] = marketplaceOrder.marketplaceOrderItems
|
|
121
|
+
|
|
122
|
+
// access every marketplaceOrderItems for shipping information you need
|
|
123
|
+
// trigger the controller from integration-lmd that trigger the API, build the parameters needed
|
|
124
|
+
// for etrax didn't support multi awb per order
|
|
125
|
+
const marketplaceOrderShipping: MarketplaceOrderShipping = marketplaceOrderItems[0].marketplaceOrderShipping
|
|
126
|
+
const lmd: LastMileDelivery = await tx.getRepository(LastMileDelivery).findOne({
|
|
127
|
+
where: {
|
|
128
|
+
domain,
|
|
129
|
+
platform: 'eTrax'
|
|
172
130
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
//Get which transporter to use
|
|
134
|
+
const marketplaceTransporter: MarketplaceTransporter = await tx
|
|
135
|
+
.getRepository(MarketplaceTransporter)
|
|
136
|
+
.findOne({
|
|
137
|
+
where: { marketplaceStore: marketplaceOrder.marketplaceStore },
|
|
138
|
+
relations: ['pickupTransporter', 'deliveryTransporter']
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const resp = await LastMileAPI.createShipmentRequest(lmd, {
|
|
142
|
+
orderNo: marketplaceOrder.orderNo,
|
|
143
|
+
clientId: lmd.clientId,
|
|
144
|
+
clientType: lmd.clientType,
|
|
145
|
+
clientName: lmd.clientName,
|
|
146
|
+
transporterId: marketplaceTransporter.pickupTransporter.transporterId,
|
|
147
|
+
pickupName: warehouseContactPoint.name,
|
|
148
|
+
pickupAddress1: warehouseContactPoint.address,
|
|
149
|
+
pickupAddress2: warehouseContactPoint.address2,
|
|
150
|
+
pickupPostcode: warehouseContactPoint.postCode,
|
|
151
|
+
pickupState: warehouseContactPoint.state,
|
|
152
|
+
pickupCity: warehouseContactPoint.city,
|
|
153
|
+
pickupPhone: warehouseContactPoint.phone,
|
|
154
|
+
pickupEmail: warehouseContactPoint.email,
|
|
155
|
+
name: marketplaceOrderShipping?.attentionTo ? marketplaceOrderShipping.attentionTo.trim() : '',
|
|
156
|
+
address1: marketplaceOrderShipping?.address1 ? marketplaceOrderShipping?.address1.trim() : '-',
|
|
157
|
+
address2: marketplaceOrderShipping?.address2 ? marketplaceOrderShipping?.address2.trim() : '-',
|
|
158
|
+
postCode: marketplaceOrderShipping?.postCode ? marketplaceOrderShipping?.postCode.trim() : '',
|
|
159
|
+
city: marketplaceOrderShipping?.city ? marketplaceOrderShipping?.city.trim() : '',
|
|
160
|
+
state: marketplaceOrderShipping?.state ? marketplaceOrderShipping?.state.trim() : '',
|
|
161
|
+
phone: marketplaceOrderShipping.phone1 || '',
|
|
162
|
+
email: marketplaceOrderShipping.email || '',
|
|
163
|
+
attentionTo: marketplaceOrderShipping.attentionTo,
|
|
164
|
+
quantity: marketplaceOrderItems.length
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const delay = (ms: number) => {
|
|
168
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (resp.Status === 'SUCCESS') {
|
|
172
|
+
//Success
|
|
173
|
+
let awbObtained = false
|
|
174
|
+
let retry = 0
|
|
175
|
+
while (!awbObtained) {
|
|
176
|
+
const marketplaceOrder2: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
177
|
+
where: { releaseOrderId: releaseGood.id },
|
|
178
|
+
relations: [
|
|
179
|
+
'marketplaceStore',
|
|
180
|
+
'marketplaceOrderItems',
|
|
181
|
+
'marketplaceOrderItems.marketplaceOrderShipping'
|
|
182
|
+
]
|
|
183
|
+
})
|
|
184
|
+
const orderShipping = marketplaceOrder2.marketplaceOrderItems[0].marketplaceOrderShipping
|
|
185
|
+
if (orderShipping?.airwayBill) {
|
|
186
|
+
awbObtained = true
|
|
187
|
+
}
|
|
188
|
+
await delay(5000)
|
|
189
|
+
//Timeout after 15sec
|
|
190
|
+
if (++retry > 3) {
|
|
191
|
+
break
|
|
192
|
+
}
|
|
177
193
|
}
|
|
194
|
+
} else {
|
|
195
|
+
throw resp
|
|
196
|
+
//Failed
|
|
178
197
|
}
|
|
179
|
-
} else {
|
|
180
|
-
throw resp
|
|
181
|
-
//Failed
|
|
182
198
|
}
|
|
183
199
|
}
|
|
184
200
|
}
|
package/server/routes.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { renderOrientageDO } from './controllers/render-orientage-do'
|
|
|
8
8
|
import { renderOrientageGRN } from './controllers/render-orientage-grn'
|
|
9
9
|
import { renderRODO } from './controllers/render-ro-do'
|
|
10
10
|
import { renderSeebuuGRN } from './controllers/render-seebuu-grn'
|
|
11
|
+
import { renderInvoices } from './controllers/render-invoices'
|
|
11
12
|
|
|
12
13
|
process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {
|
|
13
14
|
routes.get('/view_document_ro_do/:doNo', async (context, next) => {
|
|
@@ -49,4 +50,14 @@ process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {
|
|
|
49
50
|
routes.get('/view_manifest/:manifestNo', async (context, next) => {
|
|
50
51
|
context.body = await renderManifest(context.params, context)
|
|
51
52
|
})
|
|
53
|
+
|
|
54
|
+
routes.post('/view_invoices/:timezoneOffSet', async (context, next) => {
|
|
55
|
+
let req = context.request.body || {}
|
|
56
|
+
let timezoneOffSet = context.params.timezoneOffSet || 0
|
|
57
|
+
|
|
58
|
+
let data = await renderInvoices({ req, timezoneOffSet }, context)
|
|
59
|
+
|
|
60
|
+
context.type = 'application/json'
|
|
61
|
+
context.body = data
|
|
62
|
+
})
|
|
52
63
|
})
|