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