{
  "name": "UK overdue invoice reminders with statutory late payment interest (Google Sheets to Gmail drafts)",
  "nodes": [
    {
      "id": "6380a1fd-f935-4582-a668-12b174a97366",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -800,
        -300
      ],
      "parameters": {
        "content": "## UK overdue invoice reminder with late payment interest\n\n### How it works\nEvery weekday at 09:00 this reads unpaid invoices from Google Sheets, works out how many days each is overdue, and calculates statutory interest (8% plus the Bank of England reference rate, simple daily interest) and the fixed recovery sum (£40 under £1,000, £70 from £1,000 to £9,999.99, £100 at £10,000 or more). It then writes a polite reminder as a **Gmail draft**. Nothing is sent automatically: you review and send. Each draft is logged, and the invoice row is stamped so the same invoice is not drafted again within your chosen gap.\n\n### Setup\n1. Create a Google Sheet with an **Invoices** tab: invoice_number, client_name, client_email, amount_gbp, due_date, status, last_draft_date\n2. Add a **Reminder log** tab: logged_at, invoice_number, client_email, amount_gbp, days_overdue, interest_gbp, fixed_recovery_sum_gbp, total_claimable_gbp, gmail_draft_id, drafted_on, status\n3. Fill in **Set your settings**, including the base rate.\n4. Connect Google Sheets and Gmail credentials.\n\nRows with status paid, cancelled or disputed are skipped. Dates can be 2026-11-30 or 30/11/2026.\n\n### Customization\nEdit the wording in **Calculate interest and draft text**.\n\nNot legal advice. It applies to business to business debts only. Check https://www.gov.uk/late-commercial-payments-interest-debt-recovery\n\nBuilt by Extol Affiliates (extol.si). Related guide: https://www.extol.si/insights-invoice-automation-uk-small-business.html",
        "width": 540,
        "height": 960
      }
    },
    {
      "id": "4c3c324c-f70f-4ea6-afd2-aaf273d3eea4",
      "name": "Update the base rate",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -20,
        -100
      ],
      "parameters": {
        "content": "## Update the base rate\n**boeBaseRatePercent** must be the Bank of England base rate in force on the 30 June or 31 December before the debt became overdue. Check it before every use. The workflow stops if it is empty.",
        "width": 300,
        "height": 340,
        "color": 3
      }
    },
    {
      "id": "19b60dbf-54fb-4c4c-ad3e-9e8090634f2f",
      "name": "Section: calculate",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        360,
        -120
      ],
      "parameters": {
        "content": "## 1. Find overdue invoices\nSkips paid, not yet due and recently reminded invoices, then calculates interest and the fixed sum.",
        "width": 460,
        "height": 440,
        "color": 7
      }
    },
    {
      "id": "04eb14f2-7256-4d2a-afb9-7b6ce2b1c3a0",
      "name": "Section: draft and log",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        860,
        -120
      ],
      "parameters": {
        "content": "## 2. Draft, log and stamp\nCreates a Gmail draft only. Logs every draft and stamps last_draft_date on the invoice.",
        "width": 760,
        "height": 620,
        "color": 7
      }
    },
    {
      "id": "5b245316-34f1-44b7-add6-7f2cb285d04e",
      "name": "Run now",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -200,
        20
      ],
      "parameters": {}
    },
    {
      "id": "2a1484d2-89e0-47a6-ac8e-0bc884a51a1d",
      "name": "Every weekday at 09:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -200,
        200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                2,
                3,
                4,
                5
              ],
              "triggerAtHour": 9
            }
          ]
        }
      }
    },
    {
      "id": "86017246-08b5-4560-a84b-e20ba6358c20",
      "name": "Set your settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        100,
        100
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a89ce531-141a-4673-aed4-f3f61377f74c",
              "name": "spreadsheetId",
              "value": "PASTE_YOUR_GOOGLE_SHEET_ID",
              "type": "string"
            },
            {
              "id": "b67d1cc0-bc2e-4772-a59a-d676b3460a9d",
              "name": "invoicesTab",
              "value": "Invoices",
              "type": "string"
            },
            {
              "id": "d0654082-d293-4b8e-a4e7-719fef0336c9",
              "name": "logTab",
              "value": "Reminder log",
              "type": "string"
            },
            {
              "id": "524bedab-bc8d-40ec-a37b-6cebbd4311b8",
              "name": "boeBaseRatePercent",
              "value": "",
              "type": "string"
            },
            {
              "id": "8012175e-857d-4eff-a6a3-e51b9872ac46",
              "name": "minDaysOverdue",
              "value": 1,
              "type": "number"
            },
            {
              "id": "8c30af54-1132-4ca8-ac57-fb6c6502a1ea",
              "name": "daysBetweenReminders",
              "value": 7,
              "type": "number"
            },
            {
              "id": "c0603fb9-8ba7-459c-a265-bc0efeea84b1",
              "name": "senderName",
              "value": "Your name, Your Company Ltd",
              "type": "string"
            },
            {
              "id": "3e2010c2-5077-4440-a886-6181fb708d65",
              "name": "paymentDetails",
              "value": "Add your bank details or payment link here",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "f79bf580-8b9e-4ef3-aaaa-24ba445b0506",
      "name": "Read unpaid invoices",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        420,
        100
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "={{ $('Set your settings').first().json.spreadsheetId }}",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Set your settings').first().json.invoicesTab }}",
          "mode": "name"
        },
        "options": {}
      }
    },
    {
      "id": "80c9399c-890e-4e0f-a935-453ca2f743b3",
      "name": "Calculate interest and draft text",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        640,
        100
      ],
      "parameters": {
        "jsCode": "// Works out days overdue, statutory interest and the fixed recovery sum for each unpaid invoice,\n// then writes a polite reminder. Expected sheet columns:\n// invoice_number, client_name, client_email, amount_gbp, due_date, status, last_draft_date\n// Statutory interest = 8% + the Bank of England reference rate, simple interest, per day.\n// This is a calculator, not legal advice. Check https://www.gov.uk/late-commercial-payments-interest-debt-recovery\nconst s = $('Set your settings').first().json;\nconst baseRate = Number(s.boeBaseRatePercent);\nif (s.boeBaseRatePercent === '' || s.boeBaseRatePercent === null || !Number.isFinite(baseRate)) throw new Error('Set boeBaseRatePercent in \"Set your settings\" to a number, for example 4');\nconst annualRate = (8 + baseRate) / 100;\nconst minDays = Number(s.minDaysOverdue) || 1;\nconst gapDays = Number(s.daysBetweenReminders) || 7;\nconst DAY = 24 * 60 * 60 * 1000;\n\nconst today = new Date();\nconst todayUtc = Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());\n\n// Accepts 2026-11-30, 30/11/2026, 30-11-2026 or a Google Sheets serial number.\nconst parseDate = (value) => {\n  if (value === undefined || value === null || value === '') return null;\n  if (typeof value === 'number') return Date.UTC(1899, 11, 30) + Math.round(value) * DAY;\n  const v = String(value).trim();\n  let m = v.match(/^(\\d{4})-(\\d{1,2})-(\\d{1,2})/);\n  if (m) return Date.UTC(+m[1], +m[2] - 1, +m[3]);\n  m = v.match(/^(\\d{1,2})[\\/\\-.](\\d{1,2})[\\/\\-.](\\d{4})$/);\n  if (m) return Date.UTC(+m[3], +m[2] - 1, +m[1]);\n  return null;\n};\nconst toAmount = (value) => {\n  const n = parseFloat(String(value ?? '').replace(/[£,\\s]/g, ''));\n  return Number.isFinite(n) ? n : null;\n};\nconst money = (n) => '£' + n.toLocaleString('en-GB', { minimumFractionDigits: 2, maximumFractionDigits: 2 });\nconst isoDate = (ms) => new Date(ms).toISOString().slice(0, 10);\nconst ukDate = (ms) => new Date(ms).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' });\n\n// Fixed sum for recovering the debt, set by the late payment legislation.\nconst recoverySum = (amount) => (amount < 1000 ? 40 : amount < 10000 ? 70 : 100);\n\nconst out = [];\nfor (const item of $input.all()) {\n  const r = item.json;\n  const status = String(r.status || '').trim().toLowerCase();\n  if (status === 'paid' || status === 'cancelled' || status === 'disputed') continue;\n  const amount = toAmount(r.amount_gbp);\n  const due = parseDate(r.due_date);\n  const email = String(r.client_email || '').trim();\n  if (amount === null || amount <= 0 || due === null || !/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(email)) continue;\n\n  const daysOverdue = Math.floor((todayUtc - due) / DAY);\n  if (daysOverdue < minDays) continue;\n\n  const lastDraft = parseDate(r.last_draft_date);\n  if (lastDraft !== null && (todayUtc - lastDraft) / DAY < gapDays) continue;\n\n  const dailyInterest = amount * annualRate / 365;\n  const interest = Math.round(dailyInterest * daysOverdue * 100) / 100;\n  const fixedSum = recoverySum(amount);\n  const total = Math.round((amount + interest + fixedSum) * 100) / 100;\n  const firstName = String(r.client_name || '').trim().split(/\\s+/)[0] || 'there';\n\n  const body = [\n    `Hi ${firstName},`,\n    '',\n    `I hope you are well. A quick reminder that invoice ${r.invoice_number} for ${money(amount)} was due on ${ukDate(due)} and is now ${daysOverdue} day${daysOverdue === 1 ? '' : 's'} overdue.`,\n    '',\n    `If it has already been paid, thank you, and please ignore this note. If not, could you let me know when we can expect payment?`,\n    '',\n    `For transparency: under the Late Payment of Commercial Debts (Interest) Act 1998, a supplier can claim statutory interest of ${(annualRate * 100).toFixed(2)}% a year (${money(dailyInterest)} a day, ${money(interest)} so far) and a fixed recovery sum of ${money(fixedSum)}. We would much rather simply receive the original amount, so settling soon keeps things simple.`,\n    '',\n    s.paymentDetails ? `Payment details: ${s.paymentDetails}` : '',\n    '',\n    'Many thanks,',\n    s.senderName || '',\n  ].filter((line, i, arr) => !(line === '' && arr[i - 1] === '')).join('\\n').trim();\n\n  out.push({\n    json: {\n      invoice_number: String(r.invoice_number),\n      client_name: r.client_name || '',\n      client_email: email,\n      amount_gbp: amount,\n      due_date: isoDate(due),\n      days_overdue: daysOverdue,\n      annual_rate_percent: Math.round(annualRate * 10000) / 100,\n      daily_interest_gbp: Math.round(dailyInterest * 100) / 100,\n      interest_gbp: interest,\n      fixed_recovery_sum_gbp: fixedSum,\n      total_claimable_gbp: total,\n      subject: `Friendly reminder: invoice ${r.invoice_number} is ${daysOverdue} day${daysOverdue === 1 ? '' : 's'} overdue`,\n      body,\n      drafted_on: isoDate(todayUtc),\n    },\n  });\n}\nreturn out;"
      }
    },
    {
      "id": "a580c0b1-2ca7-4086-a906-b1b1009e62e3",
      "name": "Create Gmail draft",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        920,
        100
      ],
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "subject": "={{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.body }}",
        "options": {
          "sendTo": "={{ $json.client_email }}"
        }
      }
    },
    {
      "id": "35096b38-4312-4907-ad20-e7aa9c7f72ee",
      "name": "Prepare log row",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1140,
        100
      ],
      "parameters": {
        "jsCode": "// Combines each Gmail draft with the invoice it was written for, ready for the log tab.\nconst invoices = $('Calculate interest and draft text').all();\nreturn $input.all().map((draft, i) => {\n  const inv = invoices[i] ? invoices[i].json : {};\n  return {\n    json: {\n      logged_at: new Date().toISOString(),\n      invoice_number: inv.invoice_number,\n      client_email: inv.client_email,\n      amount_gbp: inv.amount_gbp,\n      days_overdue: inv.days_overdue,\n      interest_gbp: inv.interest_gbp,\n      fixed_recovery_sum_gbp: inv.fixed_recovery_sum_gbp,\n      total_claimable_gbp: inv.total_claimable_gbp,\n      gmail_draft_id: draft.json.id || '',\n      drafted_on: inv.drafted_on,\n      status: draft.json.error ? 'draft failed' : 'draft created',\n    },\n  };\n});"
      }
    },
    {
      "id": "2d8c2599-2628-4350-a456-8a20fc1e4a14",
      "name": "Log reminder",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1400,
        0
      ],
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "={{ $('Set your settings').first().json.spreadsheetId }}",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Set your settings').first().json.logTab }}",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "logged_at",
              "displayName": "logged_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "invoice_number",
              "displayName": "invoice_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "client_email",
              "displayName": "client_email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "amount_gbp",
              "displayName": "amount_gbp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "days_overdue",
              "displayName": "days_overdue",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "interest_gbp",
              "displayName": "interest_gbp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "fixed_recovery_sum_gbp",
              "displayName": "fixed_recovery_sum_gbp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "total_claimable_gbp",
              "displayName": "total_claimable_gbp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "gmail_draft_id",
              "displayName": "gmail_draft_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "drafted_on",
              "displayName": "drafted_on",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "07b92021-0984-43e9-a2e6-8db8c2eeeba7",
      "name": "Stamp invoice as drafted",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1400,
        240
      ],
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "={{ $('Set your settings').first().json.spreadsheetId }}",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Set your settings').first().json.invoicesTab }}",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "invoice_number": "={{ $json.invoice_number }}",
            "last_draft_date": "={{ $json.drafted_on }}"
          },
          "matchingColumns": [
            "invoice_number"
          ],
          "schema": [
            {
              "id": "invoice_number",
              "displayName": "invoice_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "last_draft_date",
              "displayName": "last_draft_date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Run now": {
      "main": [
        [
          {
            "node": "Set your settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every weekday at 09:00": {
      "main": [
        [
          {
            "node": "Set your settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set your settings": {
      "main": [
        [
          {
            "node": "Read unpaid invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read unpaid invoices": {
      "main": [
        [
          {
            "node": "Calculate interest and draft text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate interest and draft text": {
      "main": [
        [
          {
            "node": "Create Gmail draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Gmail draft": {
      "main": [
        [
          {
            "node": "Prepare log row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare log row": {
      "main": [
        [
          {
            "node": "Log reminder",
            "type": "main",
            "index": 0
          },
          {
            "node": "Stamp invoice as drafted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
