Work snippetAI invoice capture

AI supplier invoice capture into Xero bills, with job-code matching and an approval queue

How I would approach about 270 supplier invoices a month for a 22-tech electrical and HVAC business: each email and PDF read by a model, checked for duplicates and price changes, matched to a job and placed in an approval queue before a draft bill is created in Xero.

Work snippet with example figures.

Area
AI invoice capture
Tools
Xero · ServiceM8 · Jobber · n8n · Airtable
Typical scope
US$2,800–4,500
Timeline
About 7 weeks · 4 fixed milestones

Problem

What the owner sees

  1. Supplier bills typed into Xero by hand from PDFs, days after they arrive
  2. Materials that are not tied to a job, so job costing is wrong
  3. The same invoice emailed twice and paid twice
  4. Supplier prices that creep up unnoticed
  5. An AI tool that posts to the ledger with nobody looking

Reading an invoice is the slow part of accounts payable, and it is work a model can do well. Deciding that the invoice is right, belongs to a job and should be paid is not. The design splits the two: the model reads and proposes, rules check, and a person approves before anything reaches Xero.

Where it goes wrong today
Everyday situationWhat goes wrong
Invoice arrives as a PDF in an emailTyped into Xero days later, with typos in the amount or date
Job number appears only in the email subjectThe bill is coded to general materials and job costing misses it
Supplier resends with the word ReminderEntered twice and paid twice
Price on the invoice is above the last purchaseNobody notices until the margin report
Supplier statement arrives with the invoicesStatement lines are entered as bills
Photo of an invoice taken at an angleThe amount is read wrongly or entered from memory
Credit note emailed as an invoicePosted as a positive bill

System map

A 22-tech electrical and HVAC business receiving about 270 supplier invoices a month into one accounts mailbox. A part-time bookkeeper enters them in Xero, and the job system is ServiceM8 or Jobber.

The example reads each email and PDF, proposes a Xero bill with a job code, runs the checks and puts the result in an approval queue. The bookkeeper approves, and only then is a draft bill created in Xero.

System map: who and what does each job
PartWhat it does
Accounts mailboxA dedicated mailbox for supplier invoices. The workflow reads this mailbox only.
n8n workflowTriage, reading, checks, queue and posting. Every step is logged.
Document readerText layer first, OCR for scans and photos.
Language modelExtracts fields into a fixed schema with a confidence for each value and the text it was read from.
Approval queueAn Airtable base where the bookkeeper sees the PDF beside the proposed bill.
XeroContacts, accounts, tracking categories, bills and attachments.
Job list and price historyOpen jobs and purchase orders read from the job system, and the last three prices paid for each item.

How the data moves

  1. Email arrives
  2. PDF read
  3. Fields extracted
  4. Checks run
  5. Approval queue
  6. Draft bill in Xero
  7. Bookkeeper pays as usual

Rules agreed in writing

Thresholds are set from a test on 60 past invoices with known answers, then written down. A change needs the bookkeeper and the owner to agree.

Confidence bands and rules (example settings)
ItemExample setting
Ready bandEvery key field at 0.95 or above and every check passes. One-click approval, still by a person.
Review bandAny key field from 0.80 to 0.94, or one soft check fails. The fields in doubt are highlighted.
Manual bandAny key field under 0.80, or a hard check fails. Entered by hand with the PDF alongside.
Hard checksTotal equals lines plus tax within 0.02. Supplier matched to an existing Xero contact. Not a duplicate.
Soft checksPrice more than 5% or US$25 above the average of the last three. Job code unclear. New supplier.
Job-code orderPurchase order number, then a job number in the text, then a delivery address matching one open job, then none.
Second approvalOver US$5,000, a new supplier or a changed bank detail needs the owner as well.
What is createdA draft bill with the PDF attached. Never an authorised bill, a payment or a new contact.

Flow steps

Ten steps. A step that fails stops that invoice only, and the reason is shown in the queue.

Flow steps, in order
StepTriggerWhat happensResult
1 ReceiveNew email in the accounts mailboxMessage ID and attachments stored. Logos and signature images under 20 KB ignored.Intake record
2 ClassifyAttachment presentInvoice, credit note, statement or other. Statements and remittances are routed away.Document type
3 ReadInvoice or credit noteText layer extracted. OCR if there is none.Plain text
4 ExtractText readyModel fills the schema: supplier, number, dates, lines, tax, total, each with confidence and source text.Proposed bill
5 ValidateProposed billArithmetic, tax rates, date sanity and supplier match.Hard check results
6 DuplicatesValidation doneSupplier and invoice number, then supplier with total and date within 14 days, then file hash.Duplicate flag or clear
7 Job codeLines readPurchase order, job number in text or subject, then delivery address.Job code with evidence
8 Price checkLines matched to itemsEach unit price compared with the last three purchases.Variance flags
9 QueueAll checks runBand assigned and the record placed in the approval queue with the PDF.Queue item
10 Approve and postApprover clicks approveDraft bill created in Xero, PDF attached, price history updated.Xero bill ID

Field mapping

The first table is the field mapping into Xero. The second shows how a job code is chosen and how far it is trusted.

Extracted field to Xero bill (example settings)
Extracted valueXero fieldRule
Supplier nameContactExact match, then close match with the sender domain. Never creates a contact.
Invoice numberInvoice numberKept as printed. Compared after removing spaces and leading zeros.
Invoice date and due dateDate and due dateDue date from terms on the contact if the invoice has none.
Line description, quantity, unit priceLine item fieldsAs printed. Item code kept in the description.
Tax per lineTax typeRate matched to a Xero tax rate by percentage.
AccountAccount codeSupplier default, or the account used last time for that item.
Job codeTracking category optionOnly when the evidence is a purchase order or a job number.
PDFAttachmentOriginal file, unchanged.
How a job code is chosen (example settings)
Evidence foundWhat it matchesResult
Purchase order number in the invoiceAn open purchase order linked to one jobJob code proposed, high trust
Job number in the subject or bodyOne open jobJob code proposed, high trust
Delivery address matches one open jobOne open job at that addressProposed, medium trust, shown as a Review item
Delivery address matches several open jobsSeveral jobsNo code. The approver chooses from a list.
Nothing usableNothingStock or overhead suggested. The approver confirms.

Edge cases

These are written as test invoices, taken from real mail where the business allows it.

Edge cases and how each is handled
SituationHow it is handled
Credit noteCreated as a supplier credit note draft, never a positive bill
Supplier statementRouted to a statements folder. No bill is created.
Bank details change in an emailFlagged to the owner, not processed, and checked by phone on a known number
One email with three invoicesSplit into three queue items
Resent invoice with a different numberCaught by total and date, shown beside the original
Foreign currency invoiceManual band unless the contact is set up in that currency
Password-protected PDFManual band with a note to ask the supplier
Negotiated price below the price listApprover accepts the variance and records the agreed price with a reason
Job already closedWarning shown. The approver picks another job or overhead.
Xero unavailable when approvingOne retry, then the item waits. The invoice number is checked first so no bill is created twice.

Human sign-off and audit trail

The model never approves, pays, creates a contact or changes a bank detail. Approval is a person clicking a button on a record they can see.

Who signs off what
WhoSigns offWhenIf nobody acts
BookkeeperReady items, after a glance at highlighted fieldsDailyItems age in the queue and appear on a Friday report
BookkeeperReview items, after editing the highlighted fieldsDailySame
BookkeeperManual items, entered from the PDFDailySame
OwnerOver US$5,000, new suppliers and changed bank detailsWithin one working dayItem stays in the queue and nothing is posted
Operations managerAccepting a price variance as the new agreed priceWeeklyVariance stays flagged
Audit trail kept for every item (example entry)
FieldExample
SourceEmail message ID and received time
FileSHA-256 hash of the PDF, page count
Extracted valuesEach field with its confidence and source text
ChecksEach check with PASS, FAIL or WARN
EditsField, value before, value after, who and when
ApprovalApprover name, time and band at approval
Xero billBill ID, job code and the evidence used

Data and privacy

Supplier invoices contain bank details and prices. The design sends the model as little as it needs and keeps the rest in your accounts.

Where the data lives and who can see it
DataHandling
MailboxThe workflow reads the accounts mailbox only. Processed emails are moved to a folder, not deleted.
Bank and card numbersMasked in the text before it goes to a hosted model. The original stays in the PDF.
Model useA hosted model on terms that do not allow training on your data, or a local model as in snippet 08. Written down at the Audit.
Xero accessConnected to your Xero organisation with the scopes the build needs. The workflow has no payment step.
AccountsMailbox, n8n, Airtable and Xero stay in your accounts. I am added as a user and removed at handover.

Worked example

The tables below use one month of example figures. They show the shape of the numbers, not a client result.

One month of the accounts mailbox (example figures)
MeasureCount
Invoices and credit notes received268
Not invoices: statements, remittances, marketing21
Duplicates caught6
Processed241
Ready band163
Review band58
Manual band20
Approved as draft bills236
Rejected by the approver5
Price check on one electrical wholesaler invoice (example figures, US$)
ItemAverage of last threeThis invoiceChangeResult
Conduit, 20 mm, 3 m14.2015.90+12.0%Over 5%: flagged
Breaker, 20 A single pole11.8011.80+0.0%Clear
Cable, 2.5 mm twin, 100 m138.00142.00+2.9%Under 5%: clear
Isolator, 63 A46.5052.40+12.7%Over 5%: flagged

Testing and checks

Every check has a written pass condition and fail condition before it is run. A FAIL stops go-live until it is cleared and the check is run again.

Test plan with PASS and FAIL conditions
IDCheckMethodPASS whenFAIL when
T1Clean PDFRun ten invoices with a text layerFields equal the PDF and band is ReadyAny wrong field in Ready
T2Photo at an angleRun a skewed phone photoManual band, never ReadyReady band
T3Same invoice twiceSend the same email twiceSecond one flagged as a duplicateTwo bills possible
T4Resend with a new numberSame total and dateFlagged beside the originalNot flagged
T5Total off by 0.03Edit a test invoiceHard check fails, Manual bandPasses
T6Price up 11%Change one unit priceReview band, variance highlightedNo flag
T7Job number in the subject onlySend a test emailJob proposed with the evidence shownNo job or the wrong job
T8Credit noteSend a supplier creditCredit note draftPositive bill
T9Changed bank detailsSend a test emailFlagged to the owner, nothing createdA bill is created
T10Approve clickApprove one Ready itemOne draft bill with the PDF attachedNo bill or two bills
T1160 past invoicesRun the whole set against known answersAccuracy per field reported and thresholds agreedThresholds set without a result

Scope and milestones

A fixed scope agreed in writing before anything starts. Each milestone is paid when you sign off its deliverable.

Scope: what a project like this covers
AreaIncluded
Systems AuditReview of the accounts mailbox, a month of invoices and the Xero chart and tracking setup, a 45-minute call, written findings and a fixed quote
Mailbox intakeTriage, classification and reading of PDFs and photos
Extraction and checksSchema, confidence bands, arithmetic, duplicate and price checks
Job-code matchingPurchase order, job number and address rules
Approval queueAirtable queue with the PDF beside the proposed bill
Xero postingDraft bills with attachments, tracking and supplier credits
TestingEleven checks, including 60 past invoices kept aside
HandoverWritten SOPs, a recorded handover video and files you own, plus 14 days of fixes after go-live
Not includedTax filing and statutory returns.
Also outside the scopePaying bills or building the bank file. Supplier onboarding. Model and OCR usage fees, billed to you by the vendors. Chart of accounts redesign.
Fixed milestones
MilestoneDeliverableTimingShare
M1 Rules and schemaBands, checks and job-code rules signed, 60 invoices gatheredWeeks 1 to 225%
M2 Reading and checksExtraction, duplicate and price checks working, T1 to T9 passWeeks 3 to 430%
M3 Queue and XeroApproval queue and draft bills working, T10 and T11 passWeeks 5 to 630%
M4 HandoverA week of parallel running, SOPs, handover video, 14 days of fixesWeek 715%

Typical scope for this kind of project: US$2,800–4,500

About 7 weeks across 4 fixed milestones. The Systems Audit (US$300, fixed) comes first and confirms the scope.

Describe what is going wrong between your job system and your books, and I will say where I would look first.

Send a short note through the form on the home page. I will reply with where I would start, and whether the US$300 Systems Audit is the right first step.

Hire me on Upwork (opens in a new tab)Hire me on Freelancer (opens in a new tab)