{
  "name": "06 Ochtendoverzicht van open offertes en facturen",
  "nodes": [
    {
      "id": "8b2a6485-35d5-4a29-96dc-d18dd5a4e34f",
      "name": "Werkdagen 7:30",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "30 7 * * 1-5"
            }
          ]
        }
      }
    },
    {
      "id": "752892c4-f1df-4d76-b2c7-23d5cdba3c54",
      "name": "Open offertes",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        240,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "offertes"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "condition": "eq",
              "keyValue": "verstuurd"
            }
          ]
        },
        "returnAll": true
      },
      "alwaysOutputData": true
    },
    {
      "id": "f30a727c-2afb-4b12-9a47-cdd92b3ae63b",
      "name": "Open facturen",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        480,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "facturen"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "condition": "eq",
              "keyValue": "open"
            }
          ]
        },
        "returnAll": true
      },
      "alwaysOutputData": true,
      "executeOnce": true
    },
    {
      "id": "a9fcc804-babd-417a-9a14-6c8d7b6dbc6d",
      "name": "Overzicht opmaken",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        300
      ],
      "parameters": {
        "jsCode": "const eur = n => '€ ' + Number(n).toLocaleString('nl-NL', {minimumFractionDigits: 2});\nconst dagen = d => Math.floor((Date.now() - new Date(d).getTime()) / 864e5);\nconst off = $('Open offertes').all().map(i => i.json).filter(o => o.klant);\nconst fac = $('Open facturen').all().map(i => i.json).filter(f => f.factuurnummer);\nconst laat = fac.filter(f => dagen(f.vervaldatum) >= 1);\nconst r = [];\nr.push(`Open offertes: ${off.length} (samen ${eur(off.reduce((s, o) => s + o.bedrag, 0))})`);\nfor (const o of off) r.push(`- ${o.klant}: ${o.omschrijving}, ${eur(o.bedrag)}, ${dagen(o.verstuurd_op)} dagen geleden verstuurd`);\nr.push('', `Te late facturen: ${laat.length} (samen ${eur(laat.reduce((s, f) => s + f.bedrag, 0))})`);\nfor (const f of laat) r.push(`- ${f.factuurnummer} ${f.klant}: ${eur(f.bedrag)}, ${dagen(f.vervaldatum)} dagen te laat`);\nreturn [{ json: { tekst: r.join('\\n'), leeg: off.length + laat.length === 0 } }];"
      },
      "notes": "Geen AI nodig: tellen en opmaken is code",
      "notesInFlow": true
    },
    {
      "id": "3aabf5a5-ac44-4cbd-97ff-5abef260655a",
      "name": "Iets te melden?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        960,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "l",
              "leftValue": "={{ $json.leeg }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "ddcaee23-646a-4db2-89c8-01a6a6ba3365",
      "name": "Overzicht mailen",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1200,
        300
      ],
      "parameters": {
        "fromEmail": "info@example.com",
        "toEmail": "jij@example.com",
        "subject": "=Ochtendoverzicht {{ $now.setLocale('nl').toFormat('cccc d MMMM') }}",
        "emailFormat": "text",
        "text": "={{ $json.tekst }}",
        "options": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "1e9169cf-8c26-4d63-aec8-5d04cf2e9a00",
      "name": "Handmatig testen",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        560
      ],
      "parameters": {}
    },
    {
      "id": "bd59a5a2-175a-4033-978d-01dbe5604aa3",
      "name": "Lees mij",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -160
      ],
      "parameters": {
        "content": "## Ochtendoverzicht zonder AI\nGetest op 11-11-2026 met n8n 2.47.3.\n\n**Invullen:** SMTP-account, je eigen adres, de tabellen *offertes* en *facturen* (zie sjabloon 01 en 02).\n\nStille ochtend = geen mail.",
        "height": 220,
        "width": 520,
        "color": 7
      }
    }
  ],
  "connections": {
    "Werkdagen 7:30": {
      "main": [
        [
          {
            "node": "Open offertes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Open offertes": {
      "main": [
        [
          {
            "node": "Open facturen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Open facturen": {
      "main": [
        [
          {
            "node": "Overzicht opmaken",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Overzicht opmaken": {
      "main": [
        [
          {
            "node": "Iets te melden?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Iets te melden?": {
      "main": [
        [
          {
            "node": "Overzicht mailen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handmatig testen": {
      "main": [
        [
          {
            "node": "Open offertes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}