@wondai/n8n-nodes-nucleo 0.2.6 → 0.2.8

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.
@@ -339,6 +339,28 @@ class Nucleo {
339
339
  description: 'Opcional. Para entrega, snapshot do endereço escolhido: {"logradouro","numero","complemento","bairro","cidade","estado","cep","referencia"}. Logradouro e cidade são obrigatórios quando enviado.',
340
340
  displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
341
341
  },
342
+ {
343
+ displayName: "Forma de Pagamento",
344
+ name: "formaPagamento",
345
+ type: "options",
346
+ options: [
347
+ { name: "(não informado)", value: "" },
348
+ { name: "PIX", value: "pix" },
349
+ { name: "Cartão", value: "cartao" },
350
+ { name: "Dinheiro", value: "dinheiro" },
351
+ ],
352
+ default: "",
353
+ description: "Opcional. Quando informado, registra um pagamento pendente no pedido. Para dinheiro na entrega, pergunte ao cliente se precisa de troco e preencha 'Troco Para'.",
354
+ displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
355
+ },
356
+ {
357
+ displayName: "Troco Para",
358
+ name: "trocoPara",
359
+ type: "number",
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. (Só é enviado quando a forma de pagamento é dinheiro.)",
362
+ displayOptions: { show: { resource: ["pedido"], operation: ["criar"] } },
363
+ },
342
364
  {
343
365
  displayName: "Loja (unit_id)",
344
366
  name: "unitId",
@@ -381,6 +403,27 @@ class Nucleo {
381
403
  description: "ISO 8601. Envie vazio para não alterar.",
382
404
  displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
383
405
  },
406
+ {
407
+ displayName: "Tipo de Entrega (alterar)",
408
+ name: "tipoEntregaNova",
409
+ type: "options",
410
+ options: [
411
+ { name: "(não alterar)", value: "" },
412
+ { name: "Retirada", value: "retirada" },
413
+ { name: "Entrega", value: "entrega" },
414
+ ],
415
+ default: "",
416
+ description: "Troca a modalidade do pedido. Ao mudar para entrega, preencha também 'Endereço de Entrega' se já tiver o endereço.",
417
+ displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
418
+ },
419
+ {
420
+ displayName: "Endereço de Entrega (JSON)",
421
+ name: "enderecoEntregaNovo",
422
+ type: "json",
423
+ default: "{}",
424
+ description: 'Opcional. Snapshot do endereço quando a modalidade final for entrega: {"logradouro","numero","complemento","bairro","cidade","estado","cep","referencia"}. Logradouro e cidade obrigatórios quando enviado. Endereço com modalidade final retirada → erro.',
425
+ displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
426
+ },
384
427
  {
385
428
  displayName: "Adicionar Itens (JSON)",
386
429
  name: "adicionarItens",
@@ -528,6 +571,8 @@ class Nucleo {
528
571
  const observacoes = this.getNodeParameter("observacoes", i, "").trim();
529
572
  const agendadoPara = this.getNodeParameter("agendadoPara", i, "").trim();
530
573
  const enderecoEntrega = asObject(this.getNodeParameter("enderecoEntrega", i, "{}"));
574
+ const formaPagamento = this.getNodeParameter("formaPagamento", i, "").trim();
575
+ const trocoPara = Number(this.getNodeParameter("trocoPara", i, 0));
531
576
  const unitId = this.getNodeParameter("unitId", i, "").trim();
532
577
  idempotencyKey =
533
578
  this.getNodeParameter("idempotencyKey", i, "").trim() || (0, node_crypto_1.randomUUID)();
@@ -543,6 +588,12 @@ class Nucleo {
543
588
  if (enderecoEntrega && Object.keys(enderecoEntrega).length) {
544
589
  b.endereco_entrega = enderecoEntrega;
545
590
  }
591
+ if (formaPagamento)
592
+ b.forma_pagamento = formaPagamento;
593
+ // Troco só faz sentido com dinheiro; 0/negativo = "não precisa de troco" → não envia.
594
+ if (formaPagamento === "dinheiro" && Number.isFinite(trocoPara) && trocoPara > 0) {
595
+ b.troco_para = trocoPara;
596
+ }
546
597
  if (unitId)
547
598
  b.unit_id = unitId;
548
599
  method = "POST";
@@ -553,6 +604,8 @@ class Nucleo {
553
604
  const pedidoId = this.getNodeParameter("pedidoId", i).trim();
554
605
  const observacoes = this.getNodeParameter("observacoes", i, "");
555
606
  const agendadoPara = this.getNodeParameter("agendadoPara", i, "");
607
+ const tipoEntregaNova = this.getNodeParameter("tipoEntregaNova", i, "").trim();
608
+ const enderecoEntregaNovo = asObject(this.getNodeParameter("enderecoEntregaNovo", i, "{}"));
556
609
  const adicionar = asArray(this.getNodeParameter("adicionarItens", i, "[]"));
557
610
  const remover = parseIds(this.getNodeParameter("removerItemIds", i, ""));
558
611
  const alterar = asArray(this.getNodeParameter("alterarItens", i, "[]"));
@@ -564,6 +617,11 @@ class Nucleo {
564
617
  b.observacoes = observacoes.trim();
565
618
  if (agendadoPara.trim())
566
619
  b.agendado_para = agendadoPara.trim();
620
+ if (tipoEntregaNova)
621
+ b.tipo_entrega = tipoEntregaNova;
622
+ if (enderecoEntregaNovo && Object.keys(enderecoEntregaNovo).length) {
623
+ b.endereco_entrega = enderecoEntregaNovo;
624
+ }
567
625
  if (adicionar.length)
568
626
  b.adicionar_itens = adicionar;
569
627
  if (remover.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wondai/n8n-nodes-nucleo",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
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",