{
  "name": "Automatic invoice generation and email with Airtable and CustomJS PDF generator",
  "nodes": [
    {
      "id": "c2e9a234-394c-4c5e-ab59-a5311fa61ed8",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -144,
        16
      ]
    },
    {
      "id": "1f9f59c4-9927-4a0f-8aaf-64488bdc5a13",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -576
      ],
      "parameters": {
        "width": 864,
        "height": 448,
        "content": "# Invoice Management With Airtable \nHere you will find an example of how you can create \nand manage your invoices for free, easily, and beautifully:\n[Public Airtable Example](https://airtable.com/apph"
      }
    },
    {
      "id": "895fe916-1db2-4055-a87e-804a6be14383",
      "name": "Get Ready Invoices",
      "type": "n8n-nodes-base.airtable",
      "position": [
        144,
        16
      ]
    },
    {
      "id": "5c20d60e-72b3-45db-8df0-223676a7880e",
      "name": "Get Clients",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1024,
        0
      ]
    },
    {
      "id": "1da85e53-eaf2-4928-b1bb-0d2d7eb56056",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        -96
      ],
      "parameters": {
        "width": 416,
        "height": 560,
        "content": "## Define Your Company Details\nHere you can customize your own company details."
      }
    },
    {
      "id": "047f3d97-760b-4307-a17f-a92d4c8f268d",
      "name": "Get Invoice Items",
      "type": "n8n-nodes-base.airtable",
      "position": [
        528,
        128
      ]
    },
    {
      "id": "3e86f778-d65a-47c6-8fd4-83b8063174e1",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        848,
        128
      ]
    },
    {
      "id": "32205005-9879-4abe-be18-d77126675ccb",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        352,
        16
      ]
    },
    {
      "id": "9e68a44d-f0d2-407b-88fb-bf97032504b0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        -96
      ],
      "parameters": {
        "width": 416,
        "height": 560,
        "content": "## Mark Invoices as \"Sent\"\nFinally, the invoices are set to “Sent” so that they will never be reloaded again next time."
      }
    },
    {
      "id": "6d4c0372-e2b4-45fb-8840-82378e557f4c",
      "name": "Update record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2288,
        0
      ]
    },
    {
      "id": "6792cf9c-9aa6-444e-9c1c-66cf5784341d",
      "name": "Generate Invoice",
      "type": "@custom-js/n8n-nodes-pdf-toolkit.invoiceGenerator",
      "position": [
        1728,
        0
      ]
    },
    {
      "id": "b3263d7d-e8ca-4776-8d27-08773ab65549",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -96
      ],
      "parameters": {
        "width": 1040,
        "height": 560,
        "content": "## Collect Invoice Data From Airtable \nHere, all invoices with the status “Ready” are retrieved and enriched with the respective invoice items and client information."
      }
    },
    {
      "id": "7904b830-14ce-4ff5-8ca4-e4ab2cd4a644",
      "name": "Set Company Details",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        0
      ]
    },
    {
      "id": "a0d0705b-5d60-4845-bace-2e0cc9a9a8bd",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1648,
        -96
      ],
      "parameters": {
        "width": 448,
        "height": 560,
        "content": "## Generate Invoice & send email with invoice\n"
      }
    },
    {
      "id": "bbdd0964-c9ea-4c4b-b402-7a2e34e79c70",
      "name": "Map Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        688,
        128
      ]
    },
    {
      "id": "0a5e9db0-410f-4b5c-99cf-a616107942a5",
      "name": "Send Email With Attachment",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1904,
        0
      ]
    },
    {
      "id": "cc9d1907-9d69-4f72-b3a0-76ce416e75e8",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -96
      ],
      "parameters": {
        "width": 288,
        "height": 560,
        "content": "## Run this workflow manually\n"
      }
    },
    {
      "id": "ec0d2733-966b-49ff-ab2f-5a944882e916",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        0
      ],
      "parameters": {
        "width": 720,
        "height": 448,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Loop Over Items\nSince the number of invoice items does not match the number of invoices, we have to retrieve them in a loop and aggregate them so that they match the number"
      }
    }
  ],
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Fields": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Clients": {
      "main": [
        [
          {
            "node": "Set Company Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Get Clients",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Invoice Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Invoice": {
      "main": [
        [
          {
            "node": "Send Email With Attachment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Invoice Items": {
      "main": [
        [
          {
            "node": "Map Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ready Invoices": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Company Details": {
      "main": [
        [
          {
            "node": "Generate Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email With Attachment": {
      "main": [
        [
          {
            "node": "Update record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Ready Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}