{
  "name": "29-fluxo-caixa-projecao-semanal",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": 1,
              "triggerAtHour": 8
            }
          ]
        }
      },
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://localhost:3000/api/n8n/financeiro/fluxo-caixa-projecao?dias=15",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "name": "Buscar Proje\u00e7\u00e3o Fluxo Caixa",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        470,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "http://localhost:3000/api/n8n/whatsapp/enviar-grupo",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "body": {
          "mode": "json",
          "json": "={{ JSON.stringify({ grupo: 'financeiro', mensagem: '\ud83d\udcb5 *PROJE\u00c7\u00c3O FLUXO DE CAIXA - 15 dias*\\n\\n\ud83d\udcc8 A Receber: R$ ' + $json.total_a_receber + '\\n\ud83d\udcc9 A Pagar: R$ ' + $json.total_a_pagar + '\\n\\n' + (parseFloat($json.saldo_projetado) >= 0 ? '\u2705' : '\ud83d\udd34') + ' Saldo Projetado: R$ ' + $json.saldo_projetado }) }}"
        },
        "options": {}
      },
      "name": "Enviar Proje\u00e7\u00e3o WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        690,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "financeiro@aluforce.ind.br",
        "subject": "=Proje\u00e7\u00e3o Fluxo de Caixa - {{ $json.periodo_dias }} dias",
        "emailType": "html",
        "html": "=<h2>Proje\u00e7\u00e3o de Fluxo de Caixa</h2><p><strong>A Receber:</strong> R$ {{ $('Buscar Proje\u00e7\u00e3o Fluxo Caixa').item.json.total_a_receber }}</p><p><strong>A Pagar:</strong> R$ {{ $('Buscar Proje\u00e7\u00e3o Fluxo Caixa').item.json.total_a_pagar }}</p><p><strong>Saldo Projetado:</strong> R$ {{ $('Buscar Proje\u00e7\u00e3o Fluxo Caixa').item.json.saldo_projetado }}</p>",
        "options": {}
      },
      "name": "Email Proje\u00e7\u00e3o",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        690,
        500
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Buscar Proje\u00e7\u00e3o Fluxo Caixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Proje\u00e7\u00e3o Fluxo Caixa": {
      "main": [
        [
          {
            "node": "Enviar Proje\u00e7\u00e3o WhatsApp",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email Proje\u00e7\u00e3o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": true
}