Business ops

Net + VAT Must Equal Gross: An n8n Workflow Checks Invoice Math in Code Before Writing to Sheets

  • Level Intermediate
  • Setup1–3 hrs (estimated)
  • Evidence Some evidence
  • CostNot stated in source
  • No-codeYes
n8nSource-linkedNeeds verification

What they did

AI can read an invoice and still get the sums wrong. This free n8n template watches one Gmail label for supplier invoices, pulls the PDF text, and has OpenAI fill a strict set of fields. Then plain code checks the math: net plus VAT must equal gross, line items must add up, and the VAT rate must be allowed. Rows that pass go to an Invoices tab; failures go to an Exceptions tab with the reason.

How it went

Invoices logged automatically, with bad math caught before it reaches your books.

Worth knowing

  • Shared on the n8n forum by someone who builds n8n workflows for small UK businesses; the template is free. Credit notes look like invoices with a negative sign.

Prompt

Cleaned version rewritten from the source — not a direct quote.

Build a workflow: watch Gmail label [label] for supplier invoices with PDF attachments. Extract the text and have the AI return supplier, invoice number, dates, currency, net, VAT, gross and line items, leaving any field empty if not found. Then check in code: required fields present, net + VAT = gross (allow rounding), line items sum to net, VAT rate in [allowed rates], negative totals flagged. Write passing rows to an Invoices sheet and failures to an Exceptions sheet with the reason.

Recommended

Try it in Grok Bot

Grok Bot can read invoice PDFs from your inbox and double-check the math the same way.

  1. Copy the prompt (button below).
  2. Open Grok Bot chat and paste it. Replace any [bracketed] placeholders.
  3. Connect the listed tools (Gmail, Google Sheets) as connectors when Grok Bot asks.
  4. If the task repeats, ask: "Make this a daily routine."

Alternatives: the same prompt works in n8n, Claude, ChatGPT Agent, OpenClaw.

Set it up

Tools: Gmail, Google Sheets · Stack: n8n + Gmail + OpenAI + Google Sheets

  1. Read the original source for full context.
  2. Connect the tools your agent needs.
  3. Paste the prompt and replace [bracketed] placeholders.
  4. Run once manually and check the output before scheduling it.

Generic suggested steps, not from the source.

Evidence

n8n community post with a free library template: Gmail label, strict schema, code-side math checks, Invoices/Exceptions tabs. Author builds workflows for UK businesses; template free

Source: Web · 2026-10-19 · Verified by us: not yet · Report broken or outdated

Related use cases

Inbox & communicationReddit

6-class email router for a 22-person consultancy

An IMAP trigger feeds an OpenAI classifier that routes 80–120 emails a day to Slack, Pipedrive and Zendesk. It hit 94% accuracy on 500 emails and saves 11 hours a week.

  • Level Intermediate
  • Setup1–3 hrs*
  • Evidence Some evidence
n8nSource-linked
MoneyReddit

Invoice capture for a distributor: 4m12s down to 38s each

A shared Gmail label feeds an extractor, totals are validated to €0.01, low-confidence fields go to a human, and results push to Sage. 87% need no human touch.

  • Level Intermediate
  • Setup1–3 hrs*
  • Evidence Some evidence
n8nMakeSource-linkedNeeds verification