@wondai/n8n-nodes-nucleo 0.2.7 → 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.
|
@@ -358,10 +358,24 @@ class Nucleo {
|
|
|
358
358
|
name: "trocoPara",
|
|
359
359
|
type: "number",
|
|
360
360
|
default: 0,
|
|
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.",
|
|
362
|
-
displayOptions: {
|
|
363
|
-
|
|
364
|
-
|
|
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
|
+
displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
|
|
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"] } },
|
|
365
379
|
},
|
|
366
380
|
{
|
|
367
381
|
displayName: "Loja (unit_id)",
|
|
@@ -474,6 +488,44 @@ class Nucleo {
|
|
|
474
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.",
|
|
475
489
|
displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
|
|
476
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
|
+
},
|
|
477
529
|
{
|
|
478
530
|
displayName: "Motivo",
|
|
479
531
|
name: "motivo",
|
|
@@ -575,6 +627,8 @@ class Nucleo {
|
|
|
575
627
|
const enderecoEntrega = asObject(this.getNodeParameter("enderecoEntrega", i, "{}"));
|
|
576
628
|
const formaPagamento = this.getNodeParameter("formaPagamento", i, "").trim();
|
|
577
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));
|
|
578
632
|
const unitId = this.getNodeParameter("unitId", i, "").trim();
|
|
579
633
|
idempotencyKey =
|
|
580
634
|
this.getNodeParameter("idempotencyKey", i, "").trim() || (0, node_crypto_1.randomUUID)();
|
|
@@ -596,6 +650,11 @@ class Nucleo {
|
|
|
596
650
|
if (formaPagamento === "dinheiro" && Number.isFinite(trocoPara) && trocoPara > 0) {
|
|
597
651
|
b.troco_para = trocoPara;
|
|
598
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;
|
|
599
658
|
if (unitId)
|
|
600
659
|
b.unit_id = unitId;
|
|
601
660
|
method = "POST";
|
|
@@ -614,6 +673,10 @@ class Nucleo {
|
|
|
614
673
|
const ajustar = asArray(this.getNodeParameter("ajustarItens", i, "[]"));
|
|
615
674
|
const definir = asArray(this.getNodeParameter("definirItens", i, "[]"));
|
|
616
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();
|
|
617
680
|
const b = {};
|
|
618
681
|
if (observacoes.trim())
|
|
619
682
|
b.observacoes = observacoes.trim();
|
|
@@ -636,6 +699,19 @@ class Nucleo {
|
|
|
636
699
|
b.definir_itens = definir;
|
|
637
700
|
if (removerProdutos.length)
|
|
638
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
|
+
}
|
|
639
715
|
// Idempotência (opcional): mesma chave num retry → backend não reaplica a alteração.
|
|
640
716
|
idempotencyKey =
|
|
641
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",
|