cloudcommerce 0.0.97 → 0.0.98
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/tiny-erp/lib/event-to-tiny.js +94 -94
- package/packages/apps/tiny-erp/lib/index.js +1 -1
- package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +74 -71
- package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +73 -70
- package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +53 -49
- package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +3 -3
- package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +75 -76
- package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +140 -137
- package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +39 -40
- package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +178 -173
- package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +171 -173
- package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +127 -123
- package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +32 -32
- package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +37 -37
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +43 -42
- package/packages/apps/tiny-erp/lib/tiny-erp.js +6 -8
- package/packages/apps/tiny-erp/lib/tiny-webhook.js +73 -76
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/firebase/lib/config.js +27 -25
- package/packages/firebase/lib/const.js +3 -2
- package/packages/firebase/lib/env.js +2 -1
- package/packages/firebase/lib/handlers/check-store-events.js +146 -145
- package/packages/firebase/lib/helpers/pubsub.js +20 -18
- package/packages/firebase/lib/helpers/update-app-data.js +38 -38
- package/packages/firebase/lib/index.js +9 -7
- package/packages/firebase/lib/init.js +2 -1
- package/packages/firebase/package.json +1 -1
- package/packages/modules/lib/firebase/ajv.js +19 -24
- package/packages/modules/lib/firebase/call-app-module.js +116 -110
- package/packages/modules/lib/firebase/checkout.js +151 -152
- package/packages/modules/lib/firebase/functions-checkout/fix-items.js +194 -187
- package/packages/modules/lib/firebase/functions-checkout/get-custumerId.js +25 -26
- package/packages/modules/lib/firebase/functions-checkout/handle-order-transaction.js +110 -109
- package/packages/modules/lib/firebase/functions-checkout/new-order.js +177 -177
- package/packages/modules/lib/firebase/functions-checkout/request-to-module.js +59 -59
- package/packages/modules/lib/firebase/functions-checkout/utils.js +195 -197
- package/packages/modules/lib/firebase/handle-module.js +144 -146
- package/packages/modules/lib/firebase/proxy-apps.js +2 -1
- package/packages/modules/lib/firebase/serve-modules-api.js +52 -53
- package/packages/modules/lib/firebase.js +4 -6
- package/packages/modules/lib/index.js +12 -15
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/dist/client/LoginOffcanvas.daf3f717.js +1 -0
- package/packages/storefront/dist/client/admin/config.json +1 -0
- package/packages/storefront/dist/client/assets/_...522e6bf2.css +4 -0
- package/packages/storefront/dist/client/assets/_...a48b75c7.css +1 -0
- package/packages/storefront/dist/client/assets/cms-preview.css +274 -0
- package/packages/storefront/dist/client/assets/cms.css +114 -0
- package/packages/storefront/dist/client/assets/cvv.png +0 -0
- package/packages/storefront/dist/client/assets/icons/bootstrap-icons/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/feather-icons/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/font-awesome/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/line-awesome/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/tabler-icons/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/img-placeholder.png +0 -0
- package/packages/storefront/dist/client/assets/payments.png +0 -0
- package/packages/storefront/dist/client/assets/ssl-safe.png +0 -0
- package/packages/storefront/dist/client/chunks/LoginForm.d9251274.js +1066 -0
- package/packages/storefront/dist/client/chunks/LoginOffcanvas.07fe6492.js +1 -0
- package/packages/storefront/dist/client/chunks/index.esm.84a649c7.js +331 -0
- package/packages/storefront/dist/client/chunks/preload-helper.f15ab524.js +1 -0
- package/packages/storefront/dist/client/chunks/runtime-dom.esm-bundler.738639ee.js +1 -0
- package/packages/storefront/dist/client/chunks/workbox-window.prod.es5.4b654ae6.js +2 -0
- package/packages/storefront/dist/client/client.b552d86a.js +1 -0
- package/packages/storefront/dist/client/hoisted.054c36ac.js +1 -0
- package/packages/storefront/dist/client/img/icon.png +0 -0
- package/packages/storefront/dist/client/img/large-icon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner1.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner2.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner2.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/favicon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headless.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headphone.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headphone.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/icon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/large-icon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/logo.png +0 -0
- package/packages/storefront/dist/client/img/uploads/logo.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/og-image.png +0 -0
- package/packages/storefront/dist/client/img/uploads/passion.png +0 -0
- package/packages/storefront/dist/client/img/uploads/passion.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/pwa-reliable.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect8589.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect859.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect89.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect89.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/ssl-safe.png +0 -0
- package/packages/storefront/dist/client/manifest.webmanifest +1 -0
- package/packages/storefront/dist/client/page.3aa82516.js +1 -0
- package/packages/storefront/dist/client/robots.txt +8 -0
- package/packages/storefront/dist/client/sw.js +1 -0
- package/packages/storefront/dist/client/workbox-6f0d1f78.js +1 -0
- package/packages/storefront/dist/client/~partytown/partytown-atomics.js +2 -0
- package/packages/storefront/dist/client/~partytown/partytown-media.js +2 -0
- package/packages/storefront/dist/client/~partytown/partytown-sw.js +2 -0
- package/packages/storefront/dist/client/~partytown/partytown.js +2 -0
- package/packages/storefront/dist/server/entry.mjs +2852 -0
- package/packages/storefront/dist/server/manifest.webmanifest +1 -0
- package/packages/storefront/dist/server/registerSW.js +1 -0
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/layouts/PagesHeader.astro +2 -1
- package/packages/types/package.json +1 -1
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
import postTiny from '../post-tiny-erp.js';
|
|
2
|
-
|
|
3
2
|
export default (tinyOrder, shippingLines) => new Promise((resolve, reject) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const partialOrder = {};
|
|
4
|
+
if (tinyOrder.obs_interna) {
|
|
5
|
+
partialOrder.staff_notes = tinyOrder.obs_interna;
|
|
6
|
+
}
|
|
7
|
+
if (shippingLines && shippingLines.length) {
|
|
8
|
+
const shippingLine = shippingLines[0];
|
|
9
|
+
if ((tinyOrder.codigo_rastreamento || tinyOrder.url_rastreamento)
|
|
11
10
|
&& (!shippingLine.tracking_codes || !shippingLine.tracking_codes.length)) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
let link;
|
|
12
|
+
if (tinyOrder.url_rastreamento) {
|
|
13
|
+
link = tinyOrder.url_rastreamento;
|
|
14
|
+
}
|
|
15
|
+
const tracking = {
|
|
16
|
+
code: String(tinyOrder.codigo_rastreamento)
|
|
18
17
|
|| link.replace(/^https?:\/\/[^/]+/, '').replace(/^[^?]+\?/, '').substring(0, 70),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
link,
|
|
19
|
+
};
|
|
20
|
+
shippingLine.tracking_codes = [tracking];
|
|
21
|
+
partialOrder.shipping_lines = shippingLines;
|
|
22
|
+
}
|
|
23
|
+
if (tinyOrder.id_nota_fiscal > 0) {
|
|
24
|
+
if (!shippingLine.invoices) {
|
|
25
|
+
shippingLine.invoices = [];
|
|
26
|
+
}
|
|
27
|
+
postTiny('/nota.fiscal.obter.php', { id: tinyOrder.id_nota_fiscal })
|
|
28
|
+
.then((tinyInvoice) => {
|
|
29
|
+
const number = String(tinyInvoice.nota_fiscal.numero);
|
|
30
|
+
if (number && !shippingLine.invoices.find((invoice) => invoice.number === number)) {
|
|
31
|
+
shippingLine.invoices.push({
|
|
32
|
+
number,
|
|
33
|
+
serial_number: String(tinyInvoice.nota_fiscal.serie),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
partialOrder.shipping_lines = shippingLines;
|
|
37
|
+
resolve(partialOrder);
|
|
38
|
+
})
|
|
39
|
+
.catch(reject);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
resolve(partialOrder);
|
|
43
|
+
resolve(partialOrder);
|
|
45
44
|
});
|
|
46
|
-
|
|
45
|
+
//# sourceMappingURL=order-from-tiny.js.map
|
|
@@ -1,193 +1,198 @@
|
|
|
1
1
|
import ecomUtils from '@ecomplus/utils';
|
|
2
2
|
import formatDate from '../helpers/format-tiny-date.js';
|
|
3
3
|
import parseStatus from './status-to-tiny.js';
|
|
4
|
-
|
|
5
4
|
export default (order, appData) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
if (buyer) {
|
|
36
|
-
const tinyCustomer = {
|
|
37
|
-
codigo: buyer._id,
|
|
38
|
-
nome: (buyer.corporate_name || ecomUtils.fullName(buyer)).substring(0, 30)
|
|
39
|
-
|| `Comprador de #${orderRef}`,
|
|
40
|
-
tipo_pessoa: buyer.registry_type === 'j' ? 'J' : 'F',
|
|
5
|
+
const orderRef = String(order.number) || order._id;
|
|
6
|
+
const tinyOrder = {
|
|
7
|
+
numero_pedido_ecommerce: orderRef,
|
|
8
|
+
data_pedido: formatDate(new Date(order.opened_at || order.created_at)),
|
|
9
|
+
ecommerce: 'E-Com Plus',
|
|
10
|
+
situacao: parseStatus(order),
|
|
11
|
+
itens: [],
|
|
12
|
+
};
|
|
13
|
+
const buyer = order.buyers && order.buyers[0];
|
|
14
|
+
const shippingLine = order.shipping_lines && order.shipping_lines[0];
|
|
15
|
+
const transaction = order.transactions && order.transactions[0];
|
|
16
|
+
const shippingAddress = shippingLine && shippingLine.to;
|
|
17
|
+
const billingAddress = transaction && transaction.billing_address;
|
|
18
|
+
const parseAddress = (address, tinyObject) => {
|
|
19
|
+
[
|
|
20
|
+
['street', 'endereco', 50],
|
|
21
|
+
['number', 'numero', 10],
|
|
22
|
+
['complement', 'complemento', 50],
|
|
23
|
+
['borough', 'bairro', 30],
|
|
24
|
+
['zip', 'cep', 10],
|
|
25
|
+
['city', 'cidade', 30],
|
|
26
|
+
['province_code', 'uf', 30],
|
|
27
|
+
].forEach(([addressField, tinyField, maxLength]) => {
|
|
28
|
+
if (address[addressField]) {
|
|
29
|
+
tinyObject[tinyField] = String(address[addressField])
|
|
30
|
+
.substring(0, maxLength);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
41
33
|
};
|
|
42
|
-
if (buyer
|
|
43
|
-
|
|
34
|
+
if (buyer) {
|
|
35
|
+
const tinyCustomer = {
|
|
36
|
+
codigo: buyer._id,
|
|
37
|
+
nome: (buyer.corporate_name || ecomUtils.fullName(buyer)).substring(0, 30)
|
|
38
|
+
|| `Comprador de #${orderRef}`,
|
|
39
|
+
tipo_pessoa: buyer.registry_type === 'j' ? 'J' : 'F',
|
|
40
|
+
};
|
|
41
|
+
if (buyer.display_name) {
|
|
42
|
+
tinyCustomer.nome_fantasia = buyer.display_name.substring(0, 30);
|
|
43
|
+
}
|
|
44
|
+
if (buyer.doc_number && buyer.doc_number.length <= 18) {
|
|
45
|
+
tinyCustomer.cpf_cnpj = buyer.doc_number;
|
|
46
|
+
}
|
|
47
|
+
if (buyer.inscription_number && buyer.inscription_number.length <= 18) {
|
|
48
|
+
tinyCustomer.ie = buyer.inscription_number;
|
|
49
|
+
}
|
|
50
|
+
if (buyer.main_email && buyer.main_email.length <= 50) {
|
|
51
|
+
tinyCustomer.email = buyer.main_email;
|
|
52
|
+
}
|
|
53
|
+
if (shippingAddress) {
|
|
54
|
+
parseAddress(billingAddress || shippingAddress, tinyCustomer);
|
|
55
|
+
}
|
|
56
|
+
const phone = buyer.phones && buyer.phones[0];
|
|
57
|
+
if (phone) {
|
|
58
|
+
tinyCustomer.fone = phone.country_code ? `+${phone.country_code} ` : '';
|
|
59
|
+
tinyCustomer.fone += phone.number;
|
|
60
|
+
}
|
|
61
|
+
tinyOrder.cliente = tinyCustomer;
|
|
44
62
|
}
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
else {
|
|
64
|
+
tinyOrder.cliente = {
|
|
65
|
+
nome: `Comprador de #${orderRef}`,
|
|
66
|
+
};
|
|
47
67
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
68
|
+
if (shippingAddress && billingAddress) {
|
|
69
|
+
tinyOrder.endereco_entrega = {};
|
|
70
|
+
parseAddress(shippingAddress, tinyOrder.endereco_entrega);
|
|
71
|
+
if (shippingAddress.name) {
|
|
72
|
+
tinyOrder.endereco_entrega.nome_destinatario = shippingAddress.name.substring(0, 60);
|
|
73
|
+
}
|
|
50
74
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
75
|
+
if (order.items) {
|
|
76
|
+
order.items.forEach((item) => {
|
|
77
|
+
if (item.quantity) {
|
|
78
|
+
const itemRef = (item.sku || item._id || Math.random().toString()).substring(0, 30);
|
|
79
|
+
tinyOrder.itens.push({
|
|
80
|
+
item: {
|
|
81
|
+
codigo: itemRef,
|
|
82
|
+
descricao: item.name ? item.name.substring(0, 120) : itemRef,
|
|
83
|
+
unidade: 'UN',
|
|
84
|
+
quantidade: item.quantity,
|
|
85
|
+
valor_unitario: ecomUtils.price(item),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
53
90
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
91
|
+
if (order.payment_method_label) {
|
|
92
|
+
tinyOrder.meio_pagamento = order.payment_method_label;
|
|
56
93
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
94
|
+
if (transaction) {
|
|
95
|
+
switch (transaction.payment_method.code) {
|
|
96
|
+
case 'credit_card':
|
|
97
|
+
tinyOrder.forma_pagamento = 'credito';
|
|
98
|
+
break;
|
|
99
|
+
case 'banking_billet':
|
|
100
|
+
tinyOrder.forma_pagamento = 'boleto';
|
|
101
|
+
break;
|
|
102
|
+
case 'account_deposit':
|
|
103
|
+
tinyOrder.forma_pagamento = 'deposito';
|
|
104
|
+
break;
|
|
105
|
+
case 'online_debit':
|
|
106
|
+
case 'debit_card':
|
|
107
|
+
case 'balance_on_intermediary':
|
|
108
|
+
tinyOrder.forma_pagamento = 'debito';
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
tinyOrder.forma_pagamento = 'multiplas';
|
|
112
|
+
}
|
|
113
|
+
if (!tinyOrder.meio_pagamento && transaction.payment_method.name) {
|
|
114
|
+
tinyOrder.meio_pagamento = transaction.payment_method.name.substring(0, 100);
|
|
115
|
+
}
|
|
61
116
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
tinyOrder.cliente = {
|
|
65
|
-
nome: `Comprador de #${orderRef}`,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
if (shippingAddress && billingAddress) {
|
|
69
|
-
tinyOrder.endereco_entrega = {};
|
|
70
|
-
parseAddress(shippingAddress, tinyOrder.endereco_entrega);
|
|
71
|
-
if (shippingAddress.name) {
|
|
72
|
-
tinyOrder.endereco_entrega.nome_destinatario = shippingAddress.name.substring(0, 60);
|
|
117
|
+
if (order.shipping_method_label) {
|
|
118
|
+
tinyOrder.forma_frete = order.shipping_method_label;
|
|
73
119
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
tinyOrder.forma_pagamento = 'boleto';
|
|
101
|
-
break;
|
|
102
|
-
case 'account_deposit':
|
|
103
|
-
tinyOrder.forma_pagamento = 'deposito';
|
|
104
|
-
break;
|
|
105
|
-
case 'online_debit':
|
|
106
|
-
case 'debit_card':
|
|
107
|
-
case 'balance_on_intermediary':
|
|
108
|
-
tinyOrder.forma_pagamento = 'debito';
|
|
109
|
-
break;
|
|
110
|
-
default:
|
|
111
|
-
tinyOrder.forma_pagamento = 'multiplas';
|
|
120
|
+
if (shippingLine) {
|
|
121
|
+
tinyOrder.forma_envio = 'X';
|
|
122
|
+
if (shippingLine.app) {
|
|
123
|
+
const { carrier } = shippingLine.app;
|
|
124
|
+
if (carrier) {
|
|
125
|
+
if (/correios/i.test(carrier)) {
|
|
126
|
+
tinyOrder.forma_envio = 'C';
|
|
127
|
+
}
|
|
128
|
+
else if (/b2w/i.test(carrier)) {
|
|
129
|
+
tinyOrder.forma_envio = 'B';
|
|
130
|
+
}
|
|
131
|
+
else if (/mercado envios/i.test(carrier)) {
|
|
132
|
+
tinyOrder.forma_envio = 'M';
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
tinyOrder.forma_envio = 'T';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if ((!tinyOrder.forma_envio || tinyOrder.forma_envio === 'X' || tinyOrder.forma_envio === 'T')
|
|
139
|
+
&& shippingLine.app.service_name && /(pac|sedex)/i.test(shippingLine.app.service_name)) {
|
|
140
|
+
tinyOrder.forma_envio = 'C';
|
|
141
|
+
}
|
|
142
|
+
if (!tinyOrder.forma_frete && shippingLine.app.label) {
|
|
143
|
+
tinyOrder.forma_frete = shippingLine.app.label;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
112
146
|
}
|
|
113
|
-
|
|
114
|
-
|
|
147
|
+
else {
|
|
148
|
+
tinyOrder.forma_envio = 'S';
|
|
115
149
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} else if (/mercado envios/i.test(carrier)) {
|
|
130
|
-
tinyOrder.forma_envio = 'M';
|
|
131
|
-
} else {
|
|
132
|
-
tinyOrder.forma_envio = 'T';
|
|
150
|
+
const { amount } = order;
|
|
151
|
+
if (amount) {
|
|
152
|
+
if (typeof amount.freight === 'number') {
|
|
153
|
+
tinyOrder.valor_frete = amount.freight;
|
|
154
|
+
if (amount.tax) {
|
|
155
|
+
tinyOrder.valor_frete += amount.tax;
|
|
156
|
+
}
|
|
157
|
+
if (amount.extra) {
|
|
158
|
+
tinyOrder.valor_frete += amount.extra;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (amount.discount) {
|
|
162
|
+
tinyOrder.valor_desconto = amount.discount;
|
|
133
163
|
}
|
|
134
|
-
}
|
|
135
|
-
if ((!tinyOrder.forma_envio || tinyOrder.forma_envio === 'X' || tinyOrder.forma_envio === 'T')
|
|
136
|
-
&& shippingLine.app.service_name && /(pac|sedex)/i.test(shippingLine.app.service_name)) {
|
|
137
|
-
tinyOrder.forma_envio = 'C';
|
|
138
|
-
}
|
|
139
|
-
if (!tinyOrder.forma_frete && shippingLine.app.label) {
|
|
140
|
-
tinyOrder.forma_frete = shippingLine.app.label;
|
|
141
|
-
}
|
|
142
164
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
const { amount } = order;
|
|
147
|
-
if (amount) {
|
|
148
|
-
if (typeof amount.freight === 'number') {
|
|
149
|
-
tinyOrder.valor_frete = amount.freight;
|
|
150
|
-
if (amount.tax) {
|
|
151
|
-
tinyOrder.valor_frete += amount.tax;
|
|
152
|
-
}
|
|
153
|
-
if (amount.extra) {
|
|
154
|
-
tinyOrder.valor_frete += amount.extra;
|
|
155
|
-
}
|
|
165
|
+
if (order.notes) {
|
|
166
|
+
tinyOrder.obs = order.notes.substring(0, 100);
|
|
156
167
|
}
|
|
157
|
-
if (
|
|
158
|
-
|
|
168
|
+
if (order.extra_discount && order.extra_discount.discount_coupon) {
|
|
169
|
+
tinyOrder.obs = `${(tinyOrder.obs || '')} - ${order.extra_discount.discount_coupon}`
|
|
170
|
+
.substring(0, 100);
|
|
159
171
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
value = value.trim();
|
|
182
|
-
if (value) {
|
|
183
|
-
tinyOrder[field] = value;
|
|
172
|
+
if (order.staff_notes) {
|
|
173
|
+
tinyOrder.obs_internas = order.staff_notes.substring(0, 100);
|
|
174
|
+
}
|
|
175
|
+
if (appData.tiny_order_data && typeof appData.tiny_order_data === 'object') {
|
|
176
|
+
Object.keys(appData.tiny_order_data).forEach((field) => {
|
|
177
|
+
let value = appData.tiny_order_data[field];
|
|
178
|
+
switch (value) {
|
|
179
|
+
case undefined:
|
|
180
|
+
case '':
|
|
181
|
+
case null:
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
if (typeof value === 'string') {
|
|
185
|
+
value = value.trim();
|
|
186
|
+
if (value) {
|
|
187
|
+
tinyOrder[field] = value;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
tinyOrder[field] = value;
|
|
192
|
+
}
|
|
184
193
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
return tinyOrder;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return tinyOrder;
|
|
192
197
|
};
|
|
193
|
-
|
|
198
|
+
//# sourceMappingURL=order-to-tiny.js.map
|