ARDHOLT
Wrayfield automations · overnight sync · accounts payable

Built so nothing is re-keyed and no bill is paid twice.

Two jobs stop being done by hand: copying invoices, payments, customer details and stock between a maintenance business’s five tools, and checking every supplier bill before it is paid. We built two automations that do both: the tools are brought into step every night, with a report at 08:00, and each bill is read, matched, coded and sent to whoever signs for it; anything that looks wrong is held for a person.

Price: ask for a quote; one task automated takes 5 working days; a system on this scale is fixed in a written scope. Get a quote → · Ask us for one like it

Open the run viewer The overnight viewer, in the laptop: every plate below is drawn from the night shown

Wrayfield Facilities is the multi-site maintenance business the automations are shown running on. Built by Genco Doganay at Ardholt.

See the platform these automations run beside

The run viewer open on a laptop: the overnight sync’s plates, drawn from the night shown: the 24-hour dial of fourteen runs, the 08:00 morning report, the retry story and the three duplicates caught.
The 08:00 morning report on a phone: a greeting and what changed overnight; 439 read, 236 written, 198 skipped, 3 merged, 1 held; and one thing that needs you, Ferrant Joinery Ltd: two VAT numbers.
The 08:00 report, on a phone

1 · The night, plate by plate

One night, 18:00 to 08:00.

The overnight sync on one 24-hour dial: fourteen runs from 18:00 to 08:00 on the rings of the tools they touch, three duplicates caught, and one change held for a person at 00:24.

Overnight: 14 runs, one dial.

The whole night on one 24-hour dial. Each run sits on the ring of the tools it touches, on its own slot. The hatched mark at 01:00 is a run failing and retrying while the ledger is unavailable; the orange mark at 00:24 is the one change held for a person.

Plate 01 at full size
The 08:00 morning report: a greeting and what changed overnight, with the totals and one thing that needs you: Ferrant Joinery Ltd, two VAT numbers.

The 08:00 report, written for a person.

What needs a decision comes first; then what moved, each line naming its runs and one record to look up. 439 read, 236 written, 198 skipped because there was nothing to change, 3 merged, 1 held. The figures equal the audit trail. On a phone it is the same report in one column, as on the first screen.

Plate 02 at full size
The retry story of run R09 on a time axis: four failed attempts from 01:00 with growing waits between them, then a fifth that succeeds at 01:46, with nothing written by the failed ones.

Four failed attempts from 01:00, then success at 01:46, nothing written twice.

When the ledger is unavailable, the payments-to-ledger run times out once and meets three 503s. Each retry waits a random time up to a ceiling that doubles from 5 minutes to a cap of 45. The fifth attempt succeeds: 19 payments written, each once. The failed attempts write nothing, because every write carries a key.

Plate 03 at full size
Three pairs of duplicate customer records, each shown with the rule that matched them, the field that decided it and the account they were merged into.

Three duplicates, each caught by a rule you can read.

The same email address once spaces and capitals are ignored (R02, 18:45). The same VAT number when the emails differ (R08, 00:25). Near-identical names at the same postcode, 0.96 alike against a bar of 0.85 (R11, 04:12). Nothing is deleted: every account stays on file and a merged one points at the survivor. Names that are merely similar are held for a person, not merged.

Plate 04 at full size
The audit trail, and the fourteen runs
The audit trail of one order, as a timeline of runs R01, R03 and R09 with the rows each wrote into the ledger and the stock sheet.

One order, three tools, three runs. Every write on record.

One job (WF-J-10870) followed from the platform into the ledger and the stock sheet, run by run. The audit trail holds 240 rows for the night: 236 writes (167 created, 44 updated and 25 follow-up tasks), 3 merges and 1 hold. Every one of the 236 records written has its row, and any change can be traced to the run that made it and the record it came from.

Plate 05 at full size

Scroll sideways to see every column

The fourteen runs (times on the compressed clock)
RunStartWhat it doesToolsReadWrittenSkippedRetries
R0118:00Platform invoices to the ledgerPlatform → Ledger541440–
R0218:45New trade accounts to the CRMPlatform → CRM491830–
R0319:15Parts used to the stock sheetPlatform → Stock sheet21210–
R0420:30Latest invoice to each CRM accountLedger → CRM14104–
R0521:15CRM contacts to the email listCRM → Mail69690–
R0622:00Unsubscribes back to the CRMMail → CRM660–
R0723:00Platform invoices to the ledgerPlatform → Ledger21210–
R0800:24Customer details to the ledgerCRM → Ledger301315–
R0901:00Payments to the ledgerPlatform → Ledger191904
R1002:30Parts used to the stock sheetPlatform → Stock sheet550–
R1104:12Duplicate check across the CRMCRM → CRM70068–
R1205:01Price changes to the platformStock sheet → Platform12120–
R1306:30Overdue invoices to follow-up tasksLedger → CRM662541–
R1407:15Web sign-ups to the CRMPlatform → CRM330–

Want one like it? →

2 · The month of payables, plate by plate

One month: 252 supplier documents on their own dates, 65 by email, 174 by upload and 13 as e-invoice files, from 24 suppliers. Each document is read from its PDF or XML, matched to its order and delivery note, checked for duplicates and changed bank details, coded, routed to whoever signs for it, exported once, paid in a weekly run and aged at month-end.

Documents in, read and sorted: 252 documents by type, and the matching result for the 90 invoices: matched, quantity short, price over the order, no order, two duplicates stopped, and one held.

252 documents in, read and sorted.

90 invoices, 66 purchase orders, 66 delivery notes, 24 receipts and 6 contracts, 252 documents read (239 PDFs, 13 e-invoice XML files). Each of the 90 invoices was set against its order and delivery note: 56 matched, 5 short on quantity, 4 over on price, 22 without an order. Two duplicates were stopped before payment, one by number in another case, one by amount on close dates; a look-alike twelve days later was correctly let through. One was held.

Plate 03 at full size
The approved total of £201,670.56, who approves what by amount, and where the 78 approved invoices were coded.

£201,670.56 coded line by line, sent to whoever signs for it.

78 approved invoices, each coded across 8 cost codes with the coded lines adding up to the invoice total. Routed by amount: 15 paid on the match up to £1,000.00, 58 to the contracts manager up to £10,000.00, 5 to the operations director above that, 9 queried with the supplier; the 2 stopped and 1 held never left. Routing agreed with the stated thresholds for every invoice.

Plate 04 at full size
Aged payables at month-end: £89,904.01 across 40 open invoices by age, with a reason on every overdue line, and the approved, held and stopped totals beneath.

£89,904.01 owed at month-end, every pound of it aged.

40 open invoices at month-end: 36 not yet due, £82,828.40, and 4 overdue by 1 to 30 days, £7,075.61, each with its reason on file. Between them, three weekly payment runs pay 48 bills (9 bills £39,914.52; 16 bills £57,625.08; 23 bills £49,131.48), each bill once.

Plate 05 at full size
Accounts payable · the approver, on a phone

The approver’s queue, and the held payment.

What a signatory sees on a phone: the held payment first, with what to do next, then what waits for a signature. The held payment is £17,600.40 to a structural steel supplier (invoice CSS-36351, order PO-41162): all four lines agree with the order and the delivery note, but the bank details are not the ones on the last three invoices, so it is held before it leaves. A call-back task goes to the number on file, no bill is exported and the bank on file stays unchanged. Open it and the two bank details sit side by side, the digits that differ marked, with the three-way match beneath.

The approver’s queue on a phone: the held payment to a structural steel supplier, £17,600.40, marked do not pay, with the next step, and four invoices to approve below it.
01 · The approver’s queue
The held payment on a phone: £17,600.40 to a structural steel supplier, the bank details on file and on the invoice with the differing digits marked, the three-way match of four lines, and the next step: a call-back to the number on file.
02 · The held payment

3 · The scope, agreed first

The shape of every job: the scope is written and priced before work starts, with the checks that decide whether it is done. This is the scope these automations are built against.

What is delivered
  1. The overnight sync: fourteen scheduled runs between the platform, the ledger, the CRM, the stock sheet and the mail service (invoices, payments, customer accounts, parts used, price changes, unsubscribes, overdue follow-ups and a duplicate check), with keyed writes, three stated duplicate rules, holds for a person and an audit row for every write.
  2. The 08:00 morning report, written for a person, with its numbers equal to the audit trail.
  3. Accounts payable: supplier documents in PDF and e-invoice XML read deterministically; a three-way match with stated tolerances; checks for duplicates and changed bank details; coding line by line; routing at £1,000.00 and £10,000.00; one ledger bill per approved invoice; weekly payment runs with a payment file; month-end aged payables with a reason on every overdue line.
  4. The engine under both, built so that a dropped connection, a tool that is down or a process that is killed never loses a write or makes one twice; a step that keeps failing is set aside with a command to replay it, and every step is logged. The same engine runs order to cash: from a finished job to its invoice, payment link, stock, purchase order and receipt.
  5. Seven local services that answer like the real tools, each its own process and a real HTTP server with its own store, request log and fault injection.
  6. The run viewer, so the work can be seen running.

Handed over with the source and the commands to run it.

Not included
  • Connection to your own tools, accounts and credentials: scoped and priced with your brief. Each local service gives way to the real tool’s interface, one step at a time; the engine, the rules and the records carry over unchanged.
  • Running the automations on your servers: hosting, scheduling and monitoring.
  • Data import from an existing system.
Acceptance checks
Agreed now, and checked with you before hand-over.
Timing
Both automations as shown: designed and built as one build, from written scope to hand-over.

4 · How it is built

How it fits together: the flow, tool to tool

One engine drives all the work, so a dropped connection at 01:00 and a duplicate invoice arriving by a second route are met by the same code and logged the same way. Each tool is its own service (the service platform, the accounting ledger, the CRM, the stock sheet, the mail service, the card payments service and the supplier’s order desk), and each can be told to fail.

Scroll sideways to see the whole diagram

The five tools and the fourteen runs between themPlatform, Ledger, CRM, Stock sheet and Mail, joined by the scheduled runs R01 to R14 that move records between them, and the 08:00 morning report written from the CRM and mailed.Platformservices/platform.tsJobs, invoices, payments,customers, parts used, pricesLedgerservices/accounting.tsContacts, invoices, payments,bills; honours Idempotency-KeyCRMservices/crm.tsAccounts, merges, follow-uptasks, holds for a personStock sheetservices/inventory.tsVan and warehouse stock,reorder points, price listMailservices/mail.tsEvery rendered message;audience and unsubscribes08:00 reportsrc/flows/report.tsThe night, written for a personR01 · R07 · R09invoices, paymentsR02 · R14accounts, sign-upsR03 · R10parts usedR12price changesR04 · R13latest invoice, overdue tasksR08customer detailsR05contacts to the listR06unsubscribesR11duplicate checkcompilesendFive tools · fourteen scheduled runs · one morning report
The night. Five tools, fourteen scheduled runs (R01 to R14) and the 08:00 report. An arrow runs from the tool a run reads to the tool it writes; each box names the module that is that tool.

Scroll sideways to see the whole diagram

What every step goes throughA signed webhook, the scheduler or a supplier document enters through intake, is written to a durable queue in SQLite, and each step is attempted with an idempotency key, a circuit breaker and a real HTTP request to one of seven services; failures are retried with backoff and jitter, and parked in a dead-letter queue with a replay command; every request is in the run log and every write in the audit trail.Every run, every stepSigned webhooksrc/receiver.tsjob.completed andpayment_intent.succeededSchedulersrc/scheduler.ts14 runs, 18:00 to 08:00Supplier documentssrc/ap/extract.ts239 PDFs · 13 e-invoice XMLIntakereceiver.ts · lib/sign.tsHMAC-SHA256 over the rawbody, timestamped; refusedafter 5 minutes or on a badsignature (401).De-duplicated by event id:a second copy is acknowledged,never run twice.Durable queueengine/engine.ts · node:sqlite, WALA run is a set of steps withdependencies, written to diskbefore anything is sent.Killed mid-run (SIGKILL): onrestart the interrupted step isre-sent under the same key.SQLiteOne attemptengine/steps.ts · lib/client.ts1Idempotency keylib/idempotency.tsjob + step name: a replay returns the first result2Circuit breakerlib/breaker.tsper service: opens after 5 failures, one probe3Requestlib/client.tsreal HTTP, with a timeout, to the serviceResultok, or retried with backoff, or dead-letteredretry: exponential backoff, full jitter, Retry-After honoured · lib/backoff.tsSeven services, seven processes, 127.0.0.1Platformservices/platform.tsLedgerservices/accounting.tsCRMservices/crm.tsStock sheetservices/inventory.tsMailservices/mail.tsPaymentsservices/payments.tsSupplierservices/supplier.tsrequests out; each service injects real faults on demand: dropped sockets, 5xx, 429, timeouts, lost responsesDead-letter queuesrc/cli.ts · npm run dlq · npm run replayAfter the last attempt a step is parked, the rest of the run carries on, and replay re-queues it.Run log and audit traillib/log.ts · pipeline run logA structured line for every request, retry and transition; an audit row for every write.
What every step goes through. Each box names the module that does the work.

Scroll sideways to see the whole diagram

One supplier document through accounts payableA supplier document arrives, is read, matched three ways, checked for duplicates and changed bank details, routed by amount, exported to the ledger once if approved, paid in a weekly run, and aged at month-end; held, stopped and queried documents never reach the ledger.One supplier document, October 2026Arrivesemail · upload · e-invoice252 documents from 24suppliers: 90 invoices,66 orders, 66 deliverynotes, 24 receipts,6 contractsReadsrc/ap/extract.tsPDF text layer or XML:type, number, date, order,lines, totals, bankaccount.252 documents readMatchedsrc/ap/rules.tsInvoice v order v deliverynote, line by line, withinstated tolerances.56 matched · 5 qty short4 price over · 22 no orderCheckedsrc/ap/rules.tsSame invoice number, orsame amount on closedates; bank detailschanged since the lastinvoices.2 stopped · 1 heldRouted by amountsrc/ap/rules.ts15Paid on the match, to £1,000.0058Contracts manager, to £10,000.005Operations director, above9Queried with the supplier78 approvedExported onceap.approval · accounting.ts78 bills in the ledger,one per approved invoice,coded line by line across8 cost codes: £201,670.56Weekly payment runap.payment_run · FridaysApproved bills due within aweek are chosen, paid once,and a payment file written.3 runs paid 48 billsAged at month-endap.month_end · 31 Oct 2026Every open invoice aged;every overdue one has areason on file.40 open · £89,904.01What does not leaveholds, stops and queries never reach the ledger1 held: A structural steel supplier, CSS-36351, £17,600.40.Bank details differ from the last three invoices: a call-backtask is raised, no bill exported, bank on file unchanged.2 stopped: Kestle Plant Hire kph-46131 (same number),Askett Aggregates 37400 (same amount, close dates).9 queried: short deliveries, prices over the order.
The month. One supplier document from arrival to the aged ledger; what is held, stopped or queried never reaches the ledger.

A write carries a key

Every side effect is sent under an idempotency key built from the job and the step. A request that is sent again, because a response was lost or a process was killed, is answered from the service’s own record and changes nothing.

A failed step is retried, then parked

Retries wait a random time up to a ceiling that doubles, and honour Retry-After. A breaker per service stops hammering a service that is down. After the last attempt the step is dead-lettered, the rest of the run carries on, and a replay command puts it back.

A person is asked only when they must be

A VAT number changed in one tool only is held with a task, not guessed. A supplier’s changed bank details hold the payment and raise a call-back to the number on file. Everything the rules can settle, they settle.

The night, R08 · the month, CSS-36351
The stack and how to run it

Written to be read and handed over, with two dependencies.

2dependencies

pdfjs-dist reads the PDF text layer; playwright-core renders the month’s supplier documents and the plates. Everything else is the Node standard library.

8operating-system processes

Seven local services and the pipeline, each separate, talking real HTTP on 127.0.0.1.

1engine, three automations

The overnight sync, accounts payable and order to cash are all workflows of read, decide and write steps on the same queue.

Stack and how to run it

Runtime
Node 26, TypeScript run natively by type stripping: no build step.
Queue
A durable queue in node:sqlite, WAL mode: every commit survives the process being killed. A step whose success was not saved is sent again under its key and answered from the service’s record.
Services
Seven local HTTP servers, each its own process with its own SQLite store, request log and fault injection (X-Fault on any request, or rules armed over the admin interface).
Hand-off note
What you receive: the source and the commands to run it.

Want one like it?

Send us what you have and what it needs to do. A written scope and fixed price follow. Nothing starts until you agree.

[email protected]

You deal with us directly, from the first reply to hand-over.

Get a quote → · See all the work