n8n-nodes-ifood-completo 0.1.21 → 0.1.22
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
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.22
|
|
4
|
+
|
|
5
|
+
- Altera a saida do node `iFood Analise Conciliacao` para um unico item JSON consolidado com `merchantId`, `periodo`, `vendas` e `repasses`.
|
|
6
|
+
- Remove os payloads brutos de origem e campos extras da resposta, mantendo apenas o modelo sintetico de conciliacao solicitado.
|
|
7
|
+
|
|
3
8
|
## 0.1.21
|
|
4
9
|
|
|
5
10
|
- Ajusta `Financial Events` para paginar a partir de `page=1` e consultar o periodo semanal do corte, respeitando o limite da API.
|
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ O node `iFood Authentication` nao exige credencial nem recebe `Access Token`; el
|
|
|
60
60
|
|
|
61
61
|
`iFood Produtos do Catalogo` gera o token internamente por `client_credentials`. Informe somente `Client ID`, `Client Secret`, `Merchant ID` e `Catalog ID`; a saída contém um item n8n por produto, com categoria, código externo, valor, situação, pausa e grupos de complementos.
|
|
62
62
|
|
|
63
|
-
`iFood Analise Conciliacao` tambem gera o token internamente por `client_credentials`. Informe `Client ID`, `Client Secret`, `Merchant ID da Loja` e `Data` no formato `yyyy-mm-dd`; o node consulta vendas do dia, eventos financeiros e repasses relacionados, retornando um
|
|
63
|
+
`iFood Analise Conciliacao` tambem gera o token internamente por `client_credentials`. Informe `Client ID`, `Client Secret`, `Merchant ID da Loja` e `Data` no formato `yyyy-mm-dd`; o node consulta vendas do dia, eventos financeiros e repasses relacionados, retornando um unico JSON consolidado com `merchantId`, `periodo`, `vendas` e `repasses`.
|
|
64
64
|
|
|
65
65
|
## Tutorial
|
|
66
66
|
|
package/TUTORIAL.md
CHANGED
|
@@ -421,7 +421,8 @@ Reconciliation Arquivo:
|
|
|
421
421
|
|
|
422
422
|
O node `iFood Analise Conciliacao` executa o fluxo financeiro consolidado para uma
|
|
423
423
|
data especifica. Ele recebe os dados de credenciamento manualmente, gera o token
|
|
424
|
-
OAuth internamente e retorna um item n8n
|
|
424
|
+
OAuth internamente e retorna um unico item n8n consolidado com as vendas e repasses
|
|
425
|
+
da data informada.
|
|
425
426
|
|
|
426
427
|
Parametros obrigatorios:
|
|
427
428
|
|
|
@@ -440,37 +441,50 @@ Fluxo executado:
|
|
|
440
441
|
4. Consulta repasses em `/financial/v3.0/merchants/{merchantId}/settlements` para identificar lote, valor e data de pagamento.
|
|
441
442
|
5. Agrupa eventos por pedido e retorna a conciliacao de cada venda.
|
|
442
443
|
|
|
443
|
-
Modelo de saida
|
|
444
|
+
Modelo de saida consolidada:
|
|
444
445
|
|
|
445
446
|
```json
|
|
446
447
|
{
|
|
447
448
|
"merchantId": "MERCHANT_ID",
|
|
448
|
-
"
|
|
449
|
-
|
|
450
|
-
"orderId": "ORDER_ID",
|
|
451
|
-
"shortId": "1234",
|
|
452
|
-
"statusFinal": "CONCLUDED",
|
|
453
|
-
"dataVenda": "2026-09-06T18:40:00Z"
|
|
454
|
-
},
|
|
455
|
-
"corteSemanal": {
|
|
456
|
-
"inicio": "2026-08-31",
|
|
449
|
+
"periodo": {
|
|
450
|
+
"inicio": "2026-09-06",
|
|
457
451
|
"fim": "2026-09-06"
|
|
458
452
|
},
|
|
459
|
-
"
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
453
|
+
"vendas": [
|
|
454
|
+
{
|
|
455
|
+
"orderId": "ORDER_ID",
|
|
456
|
+
"shortId": "1234",
|
|
457
|
+
"statusFinal": "CONCLUDED",
|
|
458
|
+
"dataVenda": "2026-09-06T18:40:00Z",
|
|
459
|
+
"corteSemanal": {
|
|
460
|
+
"inicio": "2026-08-31",
|
|
461
|
+
"fim": "2026-09-06"
|
|
462
|
+
},
|
|
463
|
+
"repasse": {
|
|
464
|
+
"dataPrevista": "2026-09-16",
|
|
465
|
+
"dataPagamento": "2026-09-16",
|
|
466
|
+
"loteId": "LOTE_ID",
|
|
467
|
+
"valorLote": 14082.41,
|
|
468
|
+
"status": "SUCCEED"
|
|
469
|
+
},
|
|
470
|
+
"valores": {
|
|
471
|
+
"bruto": 100,
|
|
472
|
+
"descontos": 10,
|
|
473
|
+
"acrescimos": 0,
|
|
474
|
+
"liquidoVenda": 90,
|
|
475
|
+
"liquidoRepasse": 72.5
|
|
476
|
+
},
|
|
477
|
+
"diferencas": []
|
|
478
|
+
}
|
|
479
|
+
],
|
|
480
|
+
"repasses": [
|
|
481
|
+
{
|
|
482
|
+
"dataPagamento": "2026-09-16",
|
|
483
|
+
"loteId": "LOTE_ID",
|
|
484
|
+
"valor": 14082.41,
|
|
485
|
+
"vendas": ["ORDER_ID"]
|
|
486
|
+
}
|
|
487
|
+
]
|
|
474
488
|
}
|
|
475
489
|
```
|
|
476
490
|
|
|
@@ -69,6 +69,8 @@ class IfoodCompletoAnaliseConciliacao {
|
|
|
69
69
|
|
|
70
70
|
const eventsByOrder = groupFinancialEventsByOrder(financialEvents);
|
|
71
71
|
const settlementsIndex = indexSettlements(settlements);
|
|
72
|
+
const vendas = [];
|
|
73
|
+
const repassesMap = {};
|
|
72
74
|
|
|
73
75
|
for (const sale of sales) {
|
|
74
76
|
const saleId = saleIdentifier(sale);
|
|
@@ -77,10 +79,19 @@ class IfoodCompletoAnaliseConciliacao {
|
|
|
77
79
|
const orderEvents = mergeEvents(saleId && eventsByOrder[saleId] ? eventsByOrder[saleId] : [], salesOrderEvents);
|
|
78
80
|
const corte = weekCut(saleDate.slice(0, 10));
|
|
79
81
|
const settlement = matchSettlement(orderEvents, settlementsIndex, corte);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const venda = buildSaleConciliation({ sale, saleId, saleDate, orderEvents, corte, settlement });
|
|
83
|
+
vendas.push(venda);
|
|
84
|
+
addRepasseSale(repassesMap, venda);
|
|
83
85
|
}
|
|
86
|
+
|
|
87
|
+
returnData.push({
|
|
88
|
+
json: {
|
|
89
|
+
merchantId,
|
|
90
|
+
periodo: { inicio: data, fim: data },
|
|
91
|
+
vendas,
|
|
92
|
+
repasses: Object.keys(repassesMap).map((key) => repassesMap[key]),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
return [returnData];
|
|
@@ -295,13 +306,11 @@ function settlementSummary(settlement, matchedId) {
|
|
|
295
306
|
dataPagamento: firstText(settlement, ['paymentDate', 'paidAt', 'date', 'settlementDate']),
|
|
296
307
|
valorLote: firstNumber(settlement, ['balance', 'amount', 'value', 'totalAmount']),
|
|
297
308
|
status: firstText(settlement, ['status', 'situation']),
|
|
298
|
-
banco: objectValue(settlement, ['accountDetails', 'bankAccount', 'bank']),
|
|
299
|
-
origem: settlement,
|
|
300
309
|
};
|
|
301
310
|
}
|
|
302
311
|
|
|
303
312
|
function buildSaleConciliation(ctx) {
|
|
304
|
-
const {
|
|
313
|
+
const { sale, saleId, saleDate, orderEvents, corte, settlement } = ctx;
|
|
305
314
|
const valoresVenda = saleValues(sale);
|
|
306
315
|
const diferencas = orderEvents.map(normalizeFinancialEvent);
|
|
307
316
|
const liquidoRepasse = calculateTransferNet(diferencas, valoresVenda.liquidoVenda);
|
|
@@ -309,14 +318,10 @@ function buildSaleConciliation(ctx) {
|
|
|
309
318
|
const acrescimosEventos = sumBySignAndType(diferencas, 'acrescimo');
|
|
310
319
|
|
|
311
320
|
return {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
shortId: firstText(sale, ['shortId', 'displayId', 'order.displayId']),
|
|
317
|
-
statusFinal: firstText(sale, ['currentStatus', 'status', 'order.status']),
|
|
318
|
-
dataVenda: saleDate,
|
|
319
|
-
},
|
|
321
|
+
orderId: saleId,
|
|
322
|
+
shortId: firstText(sale, ['shortId', 'displayId', 'order.displayId']),
|
|
323
|
+
statusFinal: firstText(sale, ['currentStatus', 'status', 'order.status']),
|
|
324
|
+
dataVenda: saleDate,
|
|
320
325
|
corteSemanal: corte,
|
|
321
326
|
repasse: settlement ? {
|
|
322
327
|
dataPrevista: firstTextFromEvents(orderEvents, ['settlement.expectedDate', 'expectedPaymentDate', 'paymentDate']) || settlement.dataPagamento,
|
|
@@ -324,7 +329,6 @@ function buildSaleConciliation(ctx) {
|
|
|
324
329
|
loteId: settlement.loteId,
|
|
325
330
|
valorLote: settlement.valorLote,
|
|
326
331
|
status: settlement.status,
|
|
327
|
-
banco: settlement.banco,
|
|
328
332
|
} : {
|
|
329
333
|
dataPrevista: firstTextFromEvents(orderEvents, ['settlement.expectedDate', 'expectedPaymentDate', 'paymentDate']),
|
|
330
334
|
dataPagamento: '',
|
|
@@ -341,14 +345,26 @@ function buildSaleConciliation(ctx) {
|
|
|
341
345
|
liquidoRepasse,
|
|
342
346
|
},
|
|
343
347
|
diferencas,
|
|
344
|
-
repassesRelacionados: settlement ? [settlement.origem] : [],
|
|
345
|
-
origem: {
|
|
346
|
-
sale,
|
|
347
|
-
financialEvents: orderEvents,
|
|
348
|
-
},
|
|
349
348
|
};
|
|
350
349
|
}
|
|
351
350
|
|
|
351
|
+
function addRepasseSale(map, venda) {
|
|
352
|
+
const repasse = venda && venda.repasse ? venda.repasse : null;
|
|
353
|
+
if (!repasse || !repasse.loteId) return;
|
|
354
|
+
const key = `${repasse.dataPagamento}|${repasse.loteId}`;
|
|
355
|
+
if (!map[key]) {
|
|
356
|
+
map[key] = {
|
|
357
|
+
dataPagamento: repasse.dataPagamento,
|
|
358
|
+
loteId: repasse.loteId,
|
|
359
|
+
valor: repasse.valorLote,
|
|
360
|
+
vendas: [],
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
if (venda.orderId && map[key].vendas.indexOf(venda.orderId) === -1) {
|
|
364
|
+
map[key].vendas.push(venda.orderId);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
352
368
|
function saleValues(sale) {
|
|
353
369
|
return {
|
|
354
370
|
bruto: firstNumber(sale, ['billingSummary.grossValue', 'billingSummary.total', 'total.orderAmount', 'total.price', 'orderAmount', 'amount']),
|
|
@@ -366,9 +382,6 @@ function normalizeFinancialEvent(event) {
|
|
|
366
382
|
descricao: firstText(event, ['description', 'name', 'title', 'detail.description']),
|
|
367
383
|
valor,
|
|
368
384
|
impactaRepasse: Boolean(valueAt(event, 'hasTransferImpact')),
|
|
369
|
-
dataEvento: firstText(event, ['eventDate', 'date', 'createdAt', 'paymentDate']),
|
|
370
|
-
loteId: firstText(event, ['settlement.id', 'settlementId', 'payment.id', 'paymentId', 'closingItem.id', 'closingItemId']),
|
|
371
|
-
origem: event,
|
|
372
385
|
};
|
|
373
386
|
}
|
|
374
387
|
|
|
@@ -422,14 +435,6 @@ function valueAt(object, path) {
|
|
|
422
435
|
}, object);
|
|
423
436
|
}
|
|
424
437
|
|
|
425
|
-
function objectValue(object, paths) {
|
|
426
|
-
for (const path of paths) {
|
|
427
|
-
const value = valueAt(object, path);
|
|
428
|
-
if (value && typeof value === 'object') return value;
|
|
429
|
-
}
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
438
|
function arrayFrom(object, paths) {
|
|
434
439
|
for (const path of paths) {
|
|
435
440
|
const value = valueAt(object, path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-ifood-completo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Nodes n8n modulares para Merchant API iFood: autenticação, lojas, eventos, pedidos, financeiro, análise de conciliação, catálogo, produtos de catálogo, logística, shipping e avaliações.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|