{
  "name": "Lembrete faturas em atraso",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "id": "fc181193-6a69-47f0-bbd3-00a3738c02bc",
      "name": "Segundas 9h",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "ESCOLHE_A_FOLHA"
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0"
        },
        "options": {}
      },
      "id": "bf8205e9-0455-4955-820d-a81996b5fa76",
      "name": "Ler faturas",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const hoje = $now.toFormat('yyyy-MM-dd');\nreturn $input.all().filter(i => String(i.json.Pago).toLowerCase() !== 'sim' && String(i.json.Vencimento) < hoje);"
      },
      "id": "a6df4d19-1620-4875-903e-e84089dd38c8",
      "name": "Só vencidas",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "=Fatura {{ $json['Número'] }} — lembrete",
        "message": "=Olá {{ $json.Cliente }},\n\nEsperamos que esteja tudo bem. Segundo os nossos registos, a fatura {{ $json['Número'] }} no valor de {{ $json.Valor }} € venceu a {{ $json.Vencimento }}. Se já tiver feito o pagamento, por favor ignore este email.\n\nObrigado!",
        "options": {
          "sendTo": "={{ $json.Email }}"
        }
      },
      "id": "1ae388bd-a414-4007-995e-7d734239b483",
      "name": "Rascunho lembrete",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        720,
        0
      ]
    }
  ],
  "connections": {
    "Segundas 9h": {
      "main": [
        [
          {
            "node": "Ler faturas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ler faturas": {
      "main": [
        [
          {
            "node": "Só vencidas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Só vencidas": {
      "main": [
        [
          {
            "node": "Rascunho lembrete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Lisbon"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "automacoespme"
  },
  "tags": []
}