@wondai/n8n-nodes-nucleo 0.2.6 → 0.2.7

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,30 @@ 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.",
362
+ displayOptions: {
363
+ show: { resource: ["pedido"], operation: ["criar"], formaPagamento: ["dinheiro"] },
364
+ },
365
+ },
342
366
  {
343
367
  displayName: "Loja (unit_id)",
344
368
  name: "unitId",
@@ -381,6 +405,27 @@ class Nucleo {
381
405
  description: "ISO 8601. Envie vazio para não alterar.",
382
406
  displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
383
407
  },
408
+ {
409
+ displayName: "Tipo de Entrega (alterar)",
410
+ name: "tipoEntregaNova",
411
+ type: "options",
412
+ options: [
413
+ { name: "(não alterar)", value: "" },
414
+ { name: "Retirada", value: "retirada" },
415
+ { name: "Entrega", value: "entrega" },
416
+ ],
417
+ default: "",
418
+ description: "Troca a modalidade do pedido. Ao mudar para entrega, preencha também 'Endereço de Entrega' se já tiver o endereço.",
419
+ displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
420
+ },
421
+ {
422
+ displayName: "Endereço de Entrega (JSON)",
423
+ name: "enderecoEntregaNovo",
424
+ type: "json",
425
+ default: "{}",
426
+ 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.',
427
+ displayOptions: { show: { resource: ["pedido"], operation: ["alterar"] } },
428
+ },
384
429
  {
385
430
  displayName: "Adicionar Itens (JSON)",
386
431
  name: "adicionarItens",
@@ -528,6 +573,8 @@ class Nucleo {
528
573
  const observacoes = this.getNodeParameter("observacoes", i, "").trim();
529
574
  const agendadoPara = this.getNodeParameter("agendadoPara", i, "").trim();
530
575
  const enderecoEntrega = asObject(this.getNodeParameter("enderecoEntrega", i, "{}"));
576
+ const formaPagamento = this.getNodeParameter("formaPagamento", i, "").trim();
577
+ const trocoPara = Number(this.getNodeParameter("trocoPara", i, 0));
531
578
  const unitId = this.getNodeParameter("unitId", i, "").trim();
532
579
  idempotencyKey =
533
580
  this.getNodeParameter("idempotencyKey", i, "").trim() || (0, node_crypto_1.randomUUID)();
@@ -543,6 +590,12 @@ class Nucleo {
543
590
  if (enderecoEntrega && Object.keys(enderecoEntrega).length) {
544
591
  b.endereco_entrega = enderecoEntrega;
545
592
  }
593
+ if (formaPagamento)
594
+ b.forma_pagamento = formaPagamento;
595
+ // Troco só faz sentido com dinheiro; 0/negativo = "não precisa de troco" → não envia.
596
+ if (formaPagamento === "dinheiro" && Number.isFinite(trocoPara) && trocoPara > 0) {
597
+ b.troco_para = trocoPara;
598
+ }
546
599
  if (unitId)
547
600
  b.unit_id = unitId;
548
601
  method = "POST";
@@ -553,6 +606,8 @@ class Nucleo {
553
606
  const pedidoId = this.getNodeParameter("pedidoId", i).trim();
554
607
  const observacoes = this.getNodeParameter("observacoes", i, "");
555
608
  const agendadoPara = this.getNodeParameter("agendadoPara", i, "");
609
+ const tipoEntregaNova = this.getNodeParameter("tipoEntregaNova", i, "").trim();
610
+ const enderecoEntregaNovo = asObject(this.getNodeParameter("enderecoEntregaNovo", i, "{}"));
556
611
  const adicionar = asArray(this.getNodeParameter("adicionarItens", i, "[]"));
557
612
  const remover = parseIds(this.getNodeParameter("removerItemIds", i, ""));
558
613
  const alterar = asArray(this.getNodeParameter("alterarItens", i, "[]"));
@@ -564,6 +619,11 @@ class Nucleo {
564
619
  b.observacoes = observacoes.trim();
565
620
  if (agendadoPara.trim())
566
621
  b.agendado_para = agendadoPara.trim();
622
+ if (tipoEntregaNova)
623
+ b.tipo_entrega = tipoEntregaNova;
624
+ if (enderecoEntregaNovo && Object.keys(enderecoEntregaNovo).length) {
625
+ b.endereco_entrega = enderecoEntregaNovo;
626
+ }
567
627
  if (adicionar.length)
568
628
  b.adicionar_itens = adicionar;
569
629
  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.7",
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",