Skip to content

Commit a51b13f

Browse files
chore: remove logs and add customization in notes
1 parent 60ef569 commit a51b13f

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

functions/lib/integration/export-order.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const handleJob = require('./handle-job')
77

88
module.exports = ({ appSdk, storeId, auth }, blingToken, blingStore, blingDeposit, queueEntry, appData, canCreateNew) => {
99
const orderId = queueEntry.nextId
10-
if (Number(storeId) === 51292) {
11-
console.log(`Enviando pedido ${orderId} loja ${storeId}. Antes de buscar pedido`)
12-
}
1310
return appSdk.apiRequest(storeId, `/orders/${orderId}.json`, 'GET', null, auth)
1411
.then(({ response }) => {
1512
const order = response.data
@@ -18,9 +15,6 @@ module.exports = ({ appSdk, storeId, auth }, blingToken, blingStore, blingDeposi
1815
console.log(`${logHead}skipped with no financial status`)
1916
return null
2017
}
21-
if (Number(storeId) === 51292) {
22-
console.log(`Enviando pedido ${orderId} loja ${storeId}. O resultado foi ${order._id}`)
23-
}
2418

2519
let blingOrderNumber
2620
let { metafields } = order
@@ -44,9 +38,6 @@ module.exports = ({ appSdk, storeId, auth }, blingToken, blingStore, blingDeposi
4438
.then(({ data }) => {
4539
const blingStatus = parseStatus(order)
4640
const hasFoundByNumber = Boolean(Array.isArray(data.pedidos) && data.pedidos.length)
47-
if (Number(storeId) === 51292) {
48-
console.log(`Enviando pedido loja ${storeId} - ${hasFoundByNumber}. O resultado da busca foi ${JSON.stringify(data)}`)
49-
}
5041
let originalBlingOrder
5142
if (hasFoundByNumber) {
5243
originalBlingOrder = data.pedidos.find(({ pedido }) => {
@@ -87,7 +78,6 @@ module.exports = ({ appSdk, storeId, auth }, blingToken, blingStore, blingDeposi
8778
}
8879

8980
const blingOrder = parseOrder(order, blingOrderNumber, blingStore, appData, storeId)
90-
console.log(`${logHead}${JSON.stringify(blingOrder)}`)
9181
return bling.post('/pedido', { pedido: blingOrder })
9282

9383
.then(({ data }) => {

functions/lib/integration/parsers/order-to-bling/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = (order, blingOrderNumber, blingStore, appData, storeId) => {
8080
nome: `Comprador de #${order.number}`
8181
}
8282
}
83-
83+
let notesForCustomization = ''
8484
if (order.items && order.items.length) {
8585
blingOrder.itens = []
8686
order.items.forEach(item => {
@@ -95,6 +95,11 @@ module.exports = (order, blingOrderNumber, blingStore, appData, storeId) => {
9595
vlr_unit: ecomUtils.price(item)
9696
}
9797
})
98+
if (item.customizations && item.customizations.length) {
99+
item.customizations.forEach(customization => {
100+
notesForCustomization += `${customization.label} ${customization.option && customization.option.text} - ${item.sku}`
101+
})
102+
}
98103
}
99104
})
100105
}
@@ -180,7 +185,12 @@ module.exports = (order, blingOrderNumber, blingStore, appData, storeId) => {
180185
}
181186

182187
if (order.notes) {
183-
blingOrder.obs = order.notes.substring(0, 250)
188+
blingOrder.obs = order.notes
189+
}
190+
if (!blingOrder.obs && notesForCustomization.length) {
191+
blingOrder.obs = notesForCustomization
192+
} else if (blingOrder.obs && notesForCustomization.length) {
193+
blingOrder.obs += ` ${notesForCustomization}`
184194
}
185195
if (order.staff_notes) {
186196
blingOrder.obs_internas = order.staff_notes.substring(0, 250)

functions/lib/integration/parsers/order-to-ecomplus/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ module.exports = (blingOrder, shippingLines, bling, storeId) => new Promise((res
107107
}
108108
})
109109
}
110-
if (storeId == 1137) {
111-
console.log('#1137 import nfe and track', JSON.stringify(partialOrder))
112-
}
113110
resolve(partialOrder)
114111
})
115112
.catch(e => {

0 commit comments

Comments
 (0)