@things-factory/worksheet-base 4.1.30 → 4.1.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/controllers/render-invoices.js +101 -65
- package/dist-server/controllers/render-invoices.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/package.json +7 -7
- package/server/controllers/render-invoices.ts +124 -74
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +1 -3
|
@@ -21,55 +21,91 @@ async function renderInvoices({ req, timezoneOffSet }, context) {
|
|
|
21
21
|
});
|
|
22
22
|
let result = await Promise.all(req.roIds.map(async (roId) => {
|
|
23
23
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
const qb = (0, typeorm_1.getRepository)(sales_base_1.ReleaseGood)
|
|
25
|
+
.createQueryBuilder('rg')
|
|
26
|
+
.innerJoinAndSelect('rg.domain', 'domain')
|
|
27
|
+
.innerJoinAndSelect('rg.bizplace', 'bizplace')
|
|
28
|
+
.innerJoinAndSelect('bizplace.domain', 'bizplace_domain')
|
|
29
|
+
.innerJoinAndSelect('bizplace.company', 'company')
|
|
30
|
+
.innerJoinAndSelect('company.domain', 'company_domain')
|
|
31
|
+
.innerJoinAndSelect('invoices', 'iv', 'rg.id = iv.release_good_id')
|
|
32
|
+
.innerJoinAndSelect('iv.invoiceProducts', 'ip')
|
|
33
|
+
.leftJoinAndSelect('marketplace_orders', 'mo', 'rg.id = mo.release_order_id::uuid')
|
|
34
|
+
.leftJoinAndSelect('mo.marketplaceOrderItems', 'moi')
|
|
35
|
+
.leftJoinAndSelect('marketplace_product_variations', 'mpv', 'moi.marketplace_product_variation_id = mpv.id')
|
|
36
|
+
.leftJoinAndSelect('products', 'p', 'mpv.sku = p.sku and p.domain_id = company.domain_id')
|
|
37
|
+
.leftJoinAndSelect('marketplace_order_shippings', 'mos', 'rg.id = mos.release_order_id::uuid')
|
|
38
|
+
.leftJoinAndSelect('mo.fulfillmentCenter', 'fc')
|
|
39
|
+
.where('rg.id = :roId')
|
|
40
|
+
.andWhere('ip.sku = p.sku')
|
|
41
|
+
.andWhere('rg.domain = :domainId')
|
|
42
|
+
.setParameters({ roId, domainId: domain.id });
|
|
43
|
+
let items = await qb.getRawMany();
|
|
44
|
+
if (items.length) {
|
|
45
|
+
let record = items[0];
|
|
46
|
+
const partnerBiz = {
|
|
47
|
+
id: record.bizplace_id,
|
|
48
|
+
name: record.bizplace_name,
|
|
49
|
+
address: record.bizplace_address
|
|
50
|
+
};
|
|
51
|
+
const partnerCompanyDomain = {
|
|
52
|
+
id: record.company_domain_id,
|
|
53
|
+
name: record.company_domain_name
|
|
54
|
+
};
|
|
35
55
|
const foundTemplate = await (0, typeorm_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
36
56
|
where: { domain: partnerCompanyDomain, category: constants_1.TEMPLATE_TYPE.INVOICE_TEMPLATE }
|
|
37
57
|
});
|
|
38
58
|
const template = await attachment_base_1.STORAGE.readFile(foundTemplate.path, 'utf-8');
|
|
39
59
|
let fullBillingAddress = [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
record.iv_billing_address_1,
|
|
61
|
+
record.iv_billing_address_2,
|
|
62
|
+
record.iv_billing_address_3,
|
|
63
|
+
record.iv_billing_address_4,
|
|
64
|
+
record.iv_billing_address_5
|
|
45
65
|
];
|
|
46
66
|
let fullDeliveryAddress = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
record.iv_delivery_address_1,
|
|
68
|
+
record.iv_delivery_address_2,
|
|
69
|
+
record.iv_delivery_address_3,
|
|
70
|
+
record.iv_delivery_address_4,
|
|
71
|
+
record.iv_delivery_address_5
|
|
52
72
|
];
|
|
53
|
-
|
|
73
|
+
const product_list = items.map((item, idx) => {
|
|
74
|
+
return {
|
|
75
|
+
list_no: idx + 1,
|
|
76
|
+
product_sku: item.ip_sku,
|
|
77
|
+
product_name: item.ip_name,
|
|
78
|
+
product_desc: item.ip_description,
|
|
79
|
+
product_qty: item.ip_qty,
|
|
80
|
+
product_other_charges: item.ip_other_charges,
|
|
81
|
+
product_paid_price: getRoundedValue(item.ip_paid_price || item.ip_unit_price),
|
|
82
|
+
product_unit_price: getRoundedValue(item.ip_unit_price),
|
|
83
|
+
product_total_paid_price: getRoundedValue((item.ip_paid_price || item.ip_unit_price) * parseInt(item.ip_qty || 0)),
|
|
84
|
+
product_total_unit_price: getRoundedValue(item.ip_unit_price * parseInt(item.ip_qty || 0)),
|
|
85
|
+
original_price: getRoundedValue(parseFloat(item.moi_original_price || 0)),
|
|
86
|
+
product_discount: getRoundedValue(parseFloat(item.moi_discount || 0)),
|
|
87
|
+
shipping_fee_paid_by_customer: getRoundedValue(parseFloat(item.moi_shipping_fee_paid_by_customer || 0))
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
const sumProductTotalPaidPrice = product_list.reduce((total, item) => total + item.product_total_paid_price, 0);
|
|
91
|
+
let date = datetime_util_1.DateTimeConverter.date(new Date((record.iv_issued_on || record.iv_created_at) - timezoneOffSet));
|
|
54
92
|
const data = {
|
|
55
|
-
order_no:
|
|
56
|
-
ref_no:
|
|
57
|
-
|
|
58
|
-
deliver_to_phone: foundInvoice.deliverToPhone || '',
|
|
59
|
-
bill_to: foundInvoice.billTo,
|
|
60
|
-
bill_to_phone: foundInvoice.billToPhone || '',
|
|
93
|
+
order_no: record.rg_name,
|
|
94
|
+
ref_no: record.rg_ref_no,
|
|
95
|
+
from: record.iv_from,
|
|
61
96
|
customer_address: partnerBiz.address,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
97
|
+
store_name: record.iv_from,
|
|
98
|
+
bill_to: record.iv_bill_to,
|
|
99
|
+
bill_to_phone: record.iv_bill_to_phone,
|
|
100
|
+
billing_address_1: record.iv_billing_address_1,
|
|
101
|
+
billing_address_2: record.iv_billing_address_2,
|
|
102
|
+
billing_address_3: record.iv_billing_address_3,
|
|
103
|
+
billing_address_4: record.iv_billing_address_4,
|
|
104
|
+
billing_address_5: record.iv_billing_address_5,
|
|
105
|
+
billing_postcode: record.iv_billing_postcode,
|
|
106
|
+
billing_city: record.iv_billing_city,
|
|
107
|
+
billing_state: record.iv_billing_state,
|
|
108
|
+
billing_country: record.iv_billing_country,
|
|
73
109
|
full_billing_address: fullBillingAddress
|
|
74
110
|
.reduce((acc, itm) => {
|
|
75
111
|
if (itm && itm.trim() != '') {
|
|
@@ -78,15 +114,18 @@ async function renderInvoices({ req, timezoneOffSet }, context) {
|
|
|
78
114
|
return acc;
|
|
79
115
|
}, [])
|
|
80
116
|
.join(' '),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
delivery_date: date,
|
|
118
|
+
deliver_to: record.iv_deliver_to,
|
|
119
|
+
deliver_to_phone: record.iv_deliver_to_phone,
|
|
120
|
+
delivery_address_1: record.iv_delivery_address_1,
|
|
121
|
+
delivery_address_2: record.iv_delivery_address_2,
|
|
122
|
+
delivery_address_3: record.iv_delivery_address_3,
|
|
123
|
+
delivery_address_4: record.iv_delivery_address_4,
|
|
124
|
+
delivery_address_5: record.iv_delivery_address_5,
|
|
125
|
+
delivery_postcode: record.iv_delivery_postcode,
|
|
126
|
+
delivery_city: record.iv_delivery_city,
|
|
127
|
+
delivery_state: record.iv_delivery_state,
|
|
128
|
+
delivery_country: record.iv_delivery_country,
|
|
90
129
|
full_delivery_address: fullDeliveryAddress
|
|
91
130
|
.reduce((acc, itm) => {
|
|
92
131
|
if (itm && itm.trim() != '') {
|
|
@@ -95,20 +134,14 @@ async function renderInvoices({ req, timezoneOffSet }, context) {
|
|
|
95
134
|
return acc;
|
|
96
135
|
}, [])
|
|
97
136
|
.join(' '),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
product_paid_price: parseFloat(item.paidPrice || item.unitPrice).toFixed(2),
|
|
107
|
-
product_unit_price: parseFloat(item.unitPrice).toFixed(2),
|
|
108
|
-
product_total_paid_price: (parseFloat(item.paidPrice || item.unitPrice) * parseFloat(item.qty)).toFixed(2),
|
|
109
|
-
product_total_unit_price: (parseFloat(item.unitPrice) * parseFloat(item.qty)).toFixed(2)
|
|
110
|
-
};
|
|
111
|
-
})
|
|
137
|
+
fulfillment_center: record.fc_name,
|
|
138
|
+
voucher_amount: getRoundedValue(parseFloat(record.mo_voucher_amount || 0)),
|
|
139
|
+
actual_shipping_fee: getRoundedValue(parseFloat(record.mos_actual_shipping_fee || 0)),
|
|
140
|
+
sub_total: sumProductTotalPaidPrice,
|
|
141
|
+
grand_total: getRoundedValue(sumProductTotalPaidPrice -
|
|
142
|
+
parseFloat(record.mo_voucher_amount || 0) +
|
|
143
|
+
parseFloat(record.mos_actual_shipping_fee || 0)),
|
|
144
|
+
product_list
|
|
112
145
|
};
|
|
113
146
|
const formData = new form_data_1.default();
|
|
114
147
|
formData.append('template', template);
|
|
@@ -119,13 +152,13 @@ async function renderInvoices({ req, timezoneOffSet }, context) {
|
|
|
119
152
|
});
|
|
120
153
|
return await response.text();
|
|
121
154
|
}
|
|
122
|
-
return
|
|
155
|
+
return null;
|
|
123
156
|
}
|
|
124
157
|
catch (ex) {
|
|
125
|
-
return
|
|
158
|
+
return null;
|
|
126
159
|
}
|
|
127
160
|
}));
|
|
128
|
-
if (result.length <= 0) {
|
|
161
|
+
if (result.filter(x => x != null).length <= 0) {
|
|
129
162
|
throw Error('No invoice found!');
|
|
130
163
|
}
|
|
131
164
|
return result.join();
|
|
@@ -135,4 +168,7 @@ async function renderInvoices({ req, timezoneOffSet }, context) {
|
|
|
135
168
|
}
|
|
136
169
|
}
|
|
137
170
|
exports.renderInvoices = renderInvoices;
|
|
171
|
+
function getRoundedValue(value = 0) {
|
|
172
|
+
return Math.round((value + Number.EPSILON) * 100) / 100;
|
|
173
|
+
}
|
|
138
174
|
//# sourceMappingURL=render-invoices.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-invoices.js","sourceRoot":"","sources":["../../server/controllers/render-invoices.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgC;AAChC,4DAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"render-invoices.js","sourceRoot":"","sources":["../../server/controllers/render-invoices.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgC;AAChC,4DAA8B;AAC9B,qCAGgB;AAEhB,qEAGwC;AAExC,6CAA4C;AAC5C,2DAAwD;AACxD,iDAA8C;AAE9C,4CAA4C;AAC5C,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;IACxE,IAAI;QACF,MAAM,MAAM,GAAW,MAAM,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC;YACzD,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE;SACvC,CAAC,CAAA;QAEF,IAAI,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5B,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;YACzB,IAAI;gBACF,MAAM,EAAE,GA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,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE;YAC7C,MAAM,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACjC;QAED,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;KACrB;IAAC,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,CAAA;KACT;AACH,CAAC;AAlLD,wCAkLC;AAED,SAAS,eAAe,CAAC,KAAK,GAAG,CAAC;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;AACzD,CAAC"}
|
|
@@ -78,7 +78,7 @@ exports.packingWorksheetResolver = {
|
|
|
78
78
|
shippingProvider = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.transporter;
|
|
79
79
|
marketplaceStatus = releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.marketplaceOrderStatus;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
else {
|
|
82
82
|
marketplaceOrder = await tx.getRepository(marketplace_base_1.MarketplaceOrder).findOne({
|
|
83
83
|
where: { orderNo: releaseGood.refNo },
|
|
84
84
|
relations: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packing-worksheet.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/worksheet/packing-worksheet.ts"],"names":[],"mappings":";;;AAGA,qFAAwF;AACxF,uEAKyC;AACzC,2DAA8G;AAE9G,mEAAoE;AAGpE,kDAAmD;AACnD,sDAA4D;AAE5D,0CAAwD;AAE3C,QAAA,wBAAwB,GAAG;IACtC,KAAK,CAAC,gBAAgB,CAAC,CAAM,EAAE,EAAE,aAAa,EAAE,EAAE,OAAY;;QAC5D,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAC7F,IAAI,WAAW,GAAgB,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAW,CAAC,CAAC,O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WAAW,CAAA;gBAC3C,iBAAiB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,sBAAsB,CAAA;aACxD;
|
|
1
|
+
{"version":3,"file":"packing-worksheet.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/worksheet/packing-worksheet.ts"],"names":[],"mappings":";;;AAGA,qFAAwF;AACxF,uEAKyC;AACzC,2DAA8G;AAE9G,mEAAoE;AAGpE,kDAAmD;AACnD,sDAA4D;AAE5D,0CAAwD;AAE3C,QAAA,wBAAwB,GAAG;IACtC,KAAK,CAAC,gBAAgB,CAAC,CAAM,EAAE,EAAE,aAAa,EAAE,EAAE,OAAY;;QAC5D,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAC7F,IAAI,WAAW,GAAgB,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAW,CAAC,CAAC,OAAO,CAAC;YACzE,KAAK,EAAE;gBACL,MAAM;gBACN,IAAI,EAAE,aAAa;aACpB;YACD,SAAS,EAAE,CAAC,UAAU,EAAE,iBAAiB,CAAC;SAC3C,CAAC,CAAA;QAEF,kCAAkC;QAClC,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,WAAW,GAAa,MAAM,EAAE,CAAC,aAAa,CAAC,yBAAQ,CAAC,CAAC,OAAO,CAAC;gBACrE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE;aACvC,CAAC,CAAA;YAEF,MAAM,EAAE,GAAuC,EAAE;iBAC9C,aAAa,CAAC,2BAAc,CAAC;iBAC7B,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;YACvC,EAAE,CAAC,kBAAkB,CAAC,4BAA4B,EAAE,aAAa,CAAC;iBAC/D,kBAAkB,CAAC,sBAAsB,EAAE,UAAU,CAAC;iBACtD,kBAAkB,CAAC,iBAAiB,EAAE,QAAQ,CAAC;iBAC/C,KAAK,CAAC,sCAAsC,EAAE,EAAE,QAA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G,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;iBAC5D;gBACD,IAAI,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAA;gBACnD,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aAC1C;iBAAM;gBACL,UAAU,GAAG,wBAAwB,CAAC,UAAU,CAAA;aACjD;QACH,CAAC,CAAC,CAAA;KACH;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AApCD,sCAoCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.31",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"@things-factory/document-template-base": "^4.1.28",
|
|
30
30
|
"@things-factory/id-rule-base": "^4.1.28",
|
|
31
31
|
"@things-factory/integration-lmd": "^4.1.28",
|
|
32
|
-
"@things-factory/integration-marketplace": "^4.1.
|
|
33
|
-
"@things-factory/integration-sellercraft": "^4.1.
|
|
32
|
+
"@things-factory/integration-marketplace": "^4.1.31",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^4.1.31",
|
|
34
34
|
"@things-factory/integration-sftp": "^4.1.28",
|
|
35
|
-
"@things-factory/marketplace-base": "^4.1.
|
|
35
|
+
"@things-factory/marketplace-base": "^4.1.31",
|
|
36
36
|
"@things-factory/notification": "^4.1.28",
|
|
37
|
-
"@things-factory/sales-base": "^4.1.
|
|
37
|
+
"@things-factory/sales-base": "^4.1.31",
|
|
38
38
|
"@things-factory/setting-base": "^4.1.28",
|
|
39
39
|
"@things-factory/shell": "^4.1.28",
|
|
40
40
|
"@things-factory/transport-base": "^4.1.28",
|
|
41
|
-
"@things-factory/warehouse-base": "^4.1.
|
|
41
|
+
"@things-factory/warehouse-base": "^4.1.31"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "87a1ee9d97613f76b7b06bbbc59a16e1029e4dc9"
|
|
44
44
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import FormData from 'form-data'
|
|
2
2
|
import fetch from 'node-fetch'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
getRepository,
|
|
5
|
+
SelectQueryBuilder
|
|
6
|
+
} from 'typeorm'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Attachment,
|
|
10
|
+
STORAGE
|
|
11
|
+
} from '@things-factory/attachment-base'
|
|
6
12
|
import { Bizplace } from '@things-factory/biz-base'
|
|
7
13
|
import { config } from '@things-factory/env'
|
|
8
|
-
import {
|
|
14
|
+
import { ReleaseGood } from '@things-factory/sales-base'
|
|
9
15
|
import { Domain } from '@things-factory/shell'
|
|
10
16
|
|
|
11
17
|
import { TEMPLATE_TYPE } from '../constants'
|
|
@@ -22,20 +28,41 @@ export async function renderInvoices({ req, timezoneOffSet }, context: any) {
|
|
|
22
28
|
let result = await Promise.all(
|
|
23
29
|
req.roIds.map(async roId => {
|
|
24
30
|
try {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const qb: SelectQueryBuilder<ReleaseGood> = getRepository(ReleaseGood)
|
|
32
|
+
.createQueryBuilder('rg')
|
|
33
|
+
.innerJoinAndSelect('rg.domain', 'domain')
|
|
34
|
+
.innerJoinAndSelect('rg.bizplace', 'bizplace')
|
|
35
|
+
.innerJoinAndSelect('bizplace.domain', 'bizplace_domain')
|
|
36
|
+
.innerJoinAndSelect('bizplace.company', 'company')
|
|
37
|
+
.innerJoinAndSelect('company.domain', 'company_domain')
|
|
38
|
+
.innerJoinAndSelect('invoices', 'iv', 'rg.id = iv.release_good_id')
|
|
39
|
+
.innerJoinAndSelect('iv.invoiceProducts', 'ip')
|
|
40
|
+
.leftJoinAndSelect('marketplace_orders', 'mo', 'rg.id = mo.release_order_id::uuid')
|
|
41
|
+
.leftJoinAndSelect('mo.marketplaceOrderItems', 'moi')
|
|
42
|
+
.leftJoinAndSelect('marketplace_product_variations', 'mpv', 'moi.marketplace_product_variation_id = mpv.id')
|
|
43
|
+
.leftJoinAndSelect('products', 'p', 'mpv.sku = p.sku and p.domain_id = company.domain_id')
|
|
44
|
+
.leftJoinAndSelect('marketplace_order_shippings', 'mos', 'rg.id = mos.release_order_id::uuid')
|
|
45
|
+
.leftJoinAndSelect('mo.fulfillmentCenter', 'fc')
|
|
46
|
+
.where('rg.id = :roId')
|
|
47
|
+
.andWhere('ip.sku = p.sku')
|
|
48
|
+
.andWhere('rg.domain = :domainId')
|
|
49
|
+
.setParameters({ roId, domainId: domain.id })
|
|
50
|
+
|
|
51
|
+
let items: any[] = await qb.getRawMany()
|
|
52
|
+
|
|
53
|
+
if (items.length) {
|
|
54
|
+
let record: any = items[0]
|
|
55
|
+
|
|
56
|
+
const partnerBiz: Partial<Bizplace> = {
|
|
57
|
+
id: record.bizplace_id,
|
|
58
|
+
name: record.bizplace_name,
|
|
59
|
+
address: record.bizplace_address
|
|
60
|
+
}
|
|
37
61
|
|
|
38
|
-
const partnerCompanyDomain: Domain =
|
|
62
|
+
const partnerCompanyDomain: Partial<Domain> = {
|
|
63
|
+
id: record.company_domain_id,
|
|
64
|
+
name: record.company_domain_name
|
|
65
|
+
}
|
|
39
66
|
|
|
40
67
|
const foundTemplate: Attachment = await getRepository(Attachment).findOne({
|
|
41
68
|
where: { domain: partnerCompanyDomain, category: TEMPLATE_TYPE.INVOICE_TEMPLATE }
|
|
@@ -44,43 +71,64 @@ export async function renderInvoices({ req, timezoneOffSet }, context: any) {
|
|
|
44
71
|
const template = await STORAGE.readFile(foundTemplate.path, 'utf-8')
|
|
45
72
|
|
|
46
73
|
let fullBillingAddress = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
record.iv_billing_address_1,
|
|
75
|
+
record.iv_billing_address_2,
|
|
76
|
+
record.iv_billing_address_3,
|
|
77
|
+
record.iv_billing_address_4,
|
|
78
|
+
record.iv_billing_address_5
|
|
52
79
|
]
|
|
53
80
|
|
|
54
81
|
let fullDeliveryAddress = [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
record.iv_delivery_address_1,
|
|
83
|
+
record.iv_delivery_address_2,
|
|
84
|
+
record.iv_delivery_address_3,
|
|
85
|
+
record.iv_delivery_address_4,
|
|
86
|
+
record.iv_delivery_address_5
|
|
60
87
|
]
|
|
61
88
|
|
|
62
|
-
|
|
63
|
-
|
|
89
|
+
const product_list = items.map((item, idx) => {
|
|
90
|
+
return {
|
|
91
|
+
list_no: idx + 1,
|
|
92
|
+
product_sku: item.ip_sku,
|
|
93
|
+
product_name: item.ip_name,
|
|
94
|
+
product_desc: item.ip_description,
|
|
95
|
+
product_qty: item.ip_qty,
|
|
96
|
+
product_other_charges: item.ip_other_charges,
|
|
97
|
+
product_paid_price: getRoundedValue(item.ip_paid_price || item.ip_unit_price),
|
|
98
|
+
product_unit_price: getRoundedValue(item.ip_unit_price),
|
|
99
|
+
product_total_paid_price: getRoundedValue(
|
|
100
|
+
(item.ip_paid_price || item.ip_unit_price) * parseInt(item.ip_qty || 0)
|
|
101
|
+
),
|
|
102
|
+
product_total_unit_price: getRoundedValue(item.ip_unit_price * parseInt(item.ip_qty || 0)),
|
|
103
|
+
original_price: getRoundedValue(parseFloat(item.moi_original_price || 0)),
|
|
104
|
+
product_discount: getRoundedValue(parseFloat(item.moi_discount || 0)),
|
|
105
|
+
shipping_fee_paid_by_customer: getRoundedValue(parseFloat(item.moi_shipping_fee_paid_by_customer || 0))
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const sumProductTotalPaidPrice: number = product_list.reduce(
|
|
110
|
+
(total, item) => total + item.product_total_paid_price,
|
|
111
|
+
0
|
|
64
112
|
)
|
|
113
|
+
|
|
114
|
+
let date = DateTimeConverter.date(new Date((record.iv_issued_on || record.iv_created_at) - timezoneOffSet))
|
|
65
115
|
const data = {
|
|
66
|
-
order_no:
|
|
67
|
-
ref_no:
|
|
68
|
-
|
|
69
|
-
deliver_to_phone: foundInvoice.deliverToPhone || '',
|
|
70
|
-
bill_to: foundInvoice.billTo,
|
|
71
|
-
bill_to_phone: foundInvoice.billToPhone || '',
|
|
116
|
+
order_no: record.rg_name,
|
|
117
|
+
ref_no: record.rg_ref_no,
|
|
118
|
+
from: record.iv_from,
|
|
72
119
|
customer_address: partnerBiz.address,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
120
|
+
store_name: record.iv_from,
|
|
121
|
+
bill_to: record.iv_bill_to,
|
|
122
|
+
bill_to_phone: record.iv_bill_to_phone,
|
|
123
|
+
billing_address_1: record.iv_billing_address_1,
|
|
124
|
+
billing_address_2: record.iv_billing_address_2,
|
|
125
|
+
billing_address_3: record.iv_billing_address_3,
|
|
126
|
+
billing_address_4: record.iv_billing_address_4,
|
|
127
|
+
billing_address_5: record.iv_billing_address_5,
|
|
128
|
+
billing_postcode: record.iv_billing_postcode,
|
|
129
|
+
billing_city: record.iv_billing_city,
|
|
130
|
+
billing_state: record.iv_billing_state,
|
|
131
|
+
billing_country: record.iv_billing_country,
|
|
84
132
|
full_billing_address: fullBillingAddress
|
|
85
133
|
.reduce((acc, itm) => {
|
|
86
134
|
if (itm && itm.trim() != '') {
|
|
@@ -90,15 +138,18 @@ export async function renderInvoices({ req, timezoneOffSet }, context: any) {
|
|
|
90
138
|
return acc
|
|
91
139
|
}, [])
|
|
92
140
|
.join(' '),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
141
|
+
delivery_date: date,
|
|
142
|
+
deliver_to: record.iv_deliver_to,
|
|
143
|
+
deliver_to_phone: record.iv_deliver_to_phone,
|
|
144
|
+
delivery_address_1: record.iv_delivery_address_1,
|
|
145
|
+
delivery_address_2: record.iv_delivery_address_2,
|
|
146
|
+
delivery_address_3: record.iv_delivery_address_3,
|
|
147
|
+
delivery_address_4: record.iv_delivery_address_4,
|
|
148
|
+
delivery_address_5: record.iv_delivery_address_5,
|
|
149
|
+
delivery_postcode: record.iv_delivery_postcode,
|
|
150
|
+
delivery_city: record.iv_delivery_city,
|
|
151
|
+
delivery_state: record.iv_delivery_state,
|
|
152
|
+
delivery_country: record.iv_delivery_country,
|
|
102
153
|
full_delivery_address: fullDeliveryAddress
|
|
103
154
|
.reduce((acc, itm) => {
|
|
104
155
|
if (itm && itm.trim() != '') {
|
|
@@ -108,22 +159,16 @@ export async function renderInvoices({ req, timezoneOffSet }, context: any) {
|
|
|
108
159
|
return acc
|
|
109
160
|
}, [])
|
|
110
161
|
.join(' '),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
product_total_paid_price: (
|
|
122
|
-
parseFloat(item.paidPrice || item.unitPrice) * parseFloat(item.qty)
|
|
123
|
-
).toFixed(2),
|
|
124
|
-
product_total_unit_price: (parseFloat(item.unitPrice) * parseFloat(item.qty)).toFixed(2)
|
|
125
|
-
}
|
|
126
|
-
})
|
|
162
|
+
fulfillment_center: record.fc_name,
|
|
163
|
+
voucher_amount: getRoundedValue(parseFloat(record.mo_voucher_amount || 0)),
|
|
164
|
+
actual_shipping_fee: getRoundedValue(parseFloat(record.mos_actual_shipping_fee || 0)),
|
|
165
|
+
sub_total: sumProductTotalPaidPrice,
|
|
166
|
+
grand_total: getRoundedValue(
|
|
167
|
+
sumProductTotalPaidPrice -
|
|
168
|
+
parseFloat(record.mo_voucher_amount || 0) +
|
|
169
|
+
parseFloat(record.mos_actual_shipping_fee || 0)
|
|
170
|
+
),
|
|
171
|
+
product_list
|
|
127
172
|
}
|
|
128
173
|
|
|
129
174
|
const formData = new FormData()
|
|
@@ -137,18 +182,23 @@ export async function renderInvoices({ req, timezoneOffSet }, context: any) {
|
|
|
137
182
|
|
|
138
183
|
return await response.text()
|
|
139
184
|
}
|
|
140
|
-
return
|
|
185
|
+
return null
|
|
141
186
|
} catch (ex) {
|
|
142
|
-
return
|
|
187
|
+
return null
|
|
143
188
|
}
|
|
144
189
|
})
|
|
145
190
|
)
|
|
146
191
|
|
|
147
|
-
if (result.length <= 0) {
|
|
192
|
+
if (result.filter(x => x != null).length <= 0) {
|
|
148
193
|
throw Error('No invoice found!')
|
|
149
194
|
}
|
|
195
|
+
|
|
150
196
|
return result.join()
|
|
151
197
|
} catch (ex) {
|
|
152
198
|
throw ex
|
|
153
199
|
}
|
|
154
200
|
}
|
|
201
|
+
|
|
202
|
+
function getRoundedValue(value = 0) {
|
|
203
|
+
return Math.round((value + Number.EPSILON) * 100) / 100
|
|
204
|
+
}
|
|
@@ -99,9 +99,7 @@ export const packingWorksheetResolver = {
|
|
|
99
99
|
trackingNo = releaseGood?.trackingNo
|
|
100
100
|
shippingProvider = releaseGood?.transporter
|
|
101
101
|
marketplaceStatus = releaseGood?.marketplaceOrderStatus
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!sellercraft) {
|
|
102
|
+
} else {
|
|
105
103
|
marketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
106
104
|
where: { orderNo: releaseGood.refNo },
|
|
107
105
|
relations: [
|