@wondai/n8n-nodes-nucleo 0.2.8 → 0.2.9
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.
|
@@ -361,6 +361,22 @@ class Nucleo {
|
|
|
361
361
|
description: "SÓ dinheiro na entrega: valor da NOTA que o cliente vai entregar (ex.: 50). Tem que ser ≥ total do pedido. 0/vazio = não precisa de troco. O troco a separar = troco_para − total. (Só é enviado quando a forma de pagamento é dinheiro.)",
|
|
362
362
|
displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
|
|
363
363
|
},
|
|
364
|
+
{
|
|
365
|
+
displayName: "Taxa de Entrega",
|
|
366
|
+
name: "taxaEntrega",
|
|
367
|
+
type: "number",
|
|
368
|
+
default: 0,
|
|
369
|
+
description: "Opcional. Valor da taxa de entrega cobrada (ex.: 8). Soma no valor a cobrar e no troco. 0/vazio = sem taxa.",
|
|
370
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
displayName: "Desconto",
|
|
374
|
+
name: "desconto",
|
|
375
|
+
type: "number",
|
|
376
|
+
default: 0,
|
|
377
|
+
description: "Opcional. Desconto concedido em reais (ex.: 5). Abate do valor a cobrar e do troco. 0/vazio = sem desconto.",
|
|
378
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
|
|
379
|
+
},
|
|
364
380
|
{
|
|
365
381
|
displayName: "Loja (unit_id)",
|
|
366
382
|
name: "unitId",
|
|
@@ -472,6 +488,44 @@ class Nucleo {
|
|
|
472
488
|
description: "produto_ids a remover do pedido (todas as linhas do produto), separados por vírgula ou JSON array. Use para 'tirar os X' e para a troca. produto_id vem do Catálogo Resolver.",
|
|
473
489
|
displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
|
|
474
490
|
},
|
|
491
|
+
{
|
|
492
|
+
displayName: "Forma de Pagamento (alterar)",
|
|
493
|
+
name: "formaPagamentoNova",
|
|
494
|
+
type: "options",
|
|
495
|
+
options: [
|
|
496
|
+
{ name: "(não alterar)", value: "" },
|
|
497
|
+
{ name: "PIX", value: "pix" },
|
|
498
|
+
{ name: "Cartão", value: "cartao" },
|
|
499
|
+
{ name: "Dinheiro", value: "dinheiro" },
|
|
500
|
+
],
|
|
501
|
+
default: "",
|
|
502
|
+
description: "Troca/registra a forma de pagamento de um pedido já criado. Para dinheiro na entrega, pergunte se precisa de troco e preencha 'Troco Para (alterar)'. Vazio = não mexe no pagamento.",
|
|
503
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
displayName: "Troco Para (alterar)",
|
|
507
|
+
name: "trocoParaNovo",
|
|
508
|
+
type: "number",
|
|
509
|
+
default: 0,
|
|
510
|
+
description: "SÓ dinheiro na entrega: valor da NOTA que o cliente vai entregar. Tem que ser ≥ valor a cobrar. 0/vazio = não precisa de troco. Só é enviado quando 'Forma de Pagamento (alterar)' = dinheiro.",
|
|
511
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
displayName: "Taxa de Entrega (alterar)",
|
|
515
|
+
name: "taxaEntregaNova",
|
|
516
|
+
type: "string",
|
|
517
|
+
default: "",
|
|
518
|
+
description: "Redefine a taxa de entrega (recalcula o valor a cobrar e o pagamento pendente). Ex.: 8. Vazio = não altera a taxa. Use 0 para zerar.",
|
|
519
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
displayName: "Desconto (alterar)",
|
|
523
|
+
name: "descontoNovo",
|
|
524
|
+
type: "string",
|
|
525
|
+
default: "",
|
|
526
|
+
description: "Redefine o desconto (recalcula o valor a cobrar e o pagamento pendente). Ex.: 5. Vazio = não altera o desconto. Use 0 para zerar.",
|
|
527
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
|
|
528
|
+
},
|
|
475
529
|
{
|
|
476
530
|
displayName: "Motivo",
|
|
477
531
|
name: "motivo",
|
|
@@ -573,6 +627,8 @@ class Nucleo {
|
|
|
573
627
|
const enderecoEntrega = asObject(this.getNodeParameter("enderecoEntrega", i, "{}"));
|
|
574
628
|
const formaPagamento = this.getNodeParameter("formaPagamento", i, "").trim();
|
|
575
629
|
const trocoPara = Number(this.getNodeParameter("trocoPara", i, 0));
|
|
630
|
+
const taxaEntrega = Number(this.getNodeParameter("taxaEntrega", i, 0));
|
|
631
|
+
const desconto = Number(this.getNodeParameter("desconto", i, 0));
|
|
576
632
|
const unitId = this.getNodeParameter("unitId", i, "").trim();
|
|
577
633
|
idempotencyKey =
|
|
578
634
|
this.getNodeParameter("idempotencyKey", i, "").trim() || (0, node_crypto_1.randomUUID)();
|
|
@@ -594,6 +650,11 @@ class Nucleo {
|
|
|
594
650
|
if (formaPagamento === "dinheiro" && Number.isFinite(trocoPara) && trocoPara > 0) {
|
|
595
651
|
b.troco_para = trocoPara;
|
|
596
652
|
}
|
|
653
|
+
// Taxa/desconto: 0/vazio = não envia (mantém o default 0 do banco).
|
|
654
|
+
if (Number.isFinite(taxaEntrega) && taxaEntrega > 0)
|
|
655
|
+
b.taxa_entrega = taxaEntrega;
|
|
656
|
+
if (Number.isFinite(desconto) && desconto > 0)
|
|
657
|
+
b.desconto = desconto;
|
|
597
658
|
if (unitId)
|
|
598
659
|
b.unit_id = unitId;
|
|
599
660
|
method = "POST";
|
|
@@ -612,6 +673,10 @@ class Nucleo {
|
|
|
612
673
|
const ajustar = asArray(this.getNodeParameter("ajustarItens", i, "[]"));
|
|
613
674
|
const definir = asArray(this.getNodeParameter("definirItens", i, "[]"));
|
|
614
675
|
const removerProdutos = parseIds(this.getNodeParameter("removerProdutoIds", i, ""));
|
|
676
|
+
const formaPagamentoNova = this.getNodeParameter("formaPagamentoNova", i, "").trim();
|
|
677
|
+
const trocoParaNovo = Number(this.getNodeParameter("trocoParaNovo", i, 0));
|
|
678
|
+
const taxaEntregaNova = this.getNodeParameter("taxaEntregaNova", i, "").trim();
|
|
679
|
+
const descontoNovo = this.getNodeParameter("descontoNovo", i, "").trim();
|
|
615
680
|
const b = {};
|
|
616
681
|
if (observacoes.trim())
|
|
617
682
|
b.observacoes = observacoes.trim();
|
|
@@ -634,6 +699,19 @@ class Nucleo {
|
|
|
634
699
|
b.definir_itens = definir;
|
|
635
700
|
if (removerProdutos.length)
|
|
636
701
|
b.remover_produto_ids = removerProdutos;
|
|
702
|
+
// Pagamento: troca a forma do pedido já criado. Troco só com dinheiro e > 0.
|
|
703
|
+
if (formaPagamentoNova)
|
|
704
|
+
b.forma_pagamento = formaPagamentoNova;
|
|
705
|
+
if (formaPagamentoNova === "dinheiro" && Number.isFinite(trocoParaNovo) && trocoParaNovo > 0) {
|
|
706
|
+
b.troco_para = trocoParaNovo;
|
|
707
|
+
}
|
|
708
|
+
// Taxa/desconto (string p/ distinguir "não mexer" de "zerar"): vazio = não envia; "0" zera.
|
|
709
|
+
if (taxaEntregaNova !== "" && Number.isFinite(Number(taxaEntregaNova))) {
|
|
710
|
+
b.taxa_entrega = Number(taxaEntregaNova);
|
|
711
|
+
}
|
|
712
|
+
if (descontoNovo !== "" && Number.isFinite(Number(descontoNovo))) {
|
|
713
|
+
b.desconto = Number(descontoNovo);
|
|
714
|
+
}
|
|
637
715
|
// Idempotência (opcional): mesma chave num retry → backend não reaplica a alteração.
|
|
638
716
|
idempotencyKey =
|
|
639
717
|
this.getNodeParameter("idempotencyKey", i, "").trim() || undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wondai/n8n-nodes-nucleo",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Node n8n para o Núcleo Wondai — atendimento de IA (cliente, catálogo fuzzy, pedidos) com assinatura HMAC v1. Tenant vem do token (a parede, ADR-013).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|