BlogAnton Ignashev

Auto-Pulling Purchase Invoices From KSeF — Turning the Inbox Into Ready-to-Book Entries

Auto-Pulling Purchase Invoices From KSeF — Turning the Inbox Into Ready-to-Book Entries

For years the hardest part of booking a purchase invoice wasn't the accounting — it was getting the invoice into a usable shape. Someone had to find the PDF in an inbox, read the numbers off it, retype them, and hope the OCR guessed the VAT rate right. KSeF quietly deleted that entire problem for Polish purchase invoices, and almost nobody has rebuilt their process around the fact.

Structured e-invoicing became mandatory in phases through 2026 — receipt for all taxpayers from February, issuing for everyone from April, with penalties suspended through the end of the year. (For the regulatory fine print, podatki.gov.pl is the source; this is an implementation article, not legal advice.) The conversation so far has been all about compliance: how do we get ready? That question is answered. The interesting one is the next one: now that every invoice you receive lands in one national system as clean, structured data, why is anyone still typing them into the books by hand?

What "pull from KSeF" actually means

It means fetching invoices as data, not as pictures. When a supplier issues you a cost invoice, it doesn't just email you a PDF — it registers a structured FA(3) document in KSeF, and that document is available to you through the KSeF API 2.0. NIP, amounts, net/gross, per-position VAT rates, the KSeF reference number: all of it arrives as fields, already machine-readable.

That single fact changes the economics of bookkeeping. The classic automation pitch was "our OCR reads your invoices 95% accurately." With KSeF there is nothing to read — the data is exact because the supplier's own system produced it. This is why I describe the whole approach as post-KSeF automation, not OCR. OCR was a workaround for the era when invoices were images. That era is ending for domestic B2B.

The agent loop, step by step

An AI agent for accounting turns that raw availability into finished work. Here's the loop it runs, unattended, on a schedule:

  1. Poll KSeF for new inbound purchase invoices since the last run. Each comes back as an FA(3) structured document.
  2. Normalise the data — seller, dates, amounts, VAT breakdown, line items — into your chart-of-accounts vocabulary.
  3. Verify the counterparty (the step humans skip when busy — more below).
  4. Classify the booking — which cost account, KUP vs NKUP, VAT deductible or not, cost centre — using a mix of rules and a language model that learns your firm's conventions.
  5. Write a draft, not a final entry, into your accounting system, with every field pre-filled and a note explaining any judgment call.
  6. Queue it for one-click approval. A human sees a ready booking and either confirms it or nudges it.

The accountant stops being a typist and becomes a reviewer. The volume that used to eat a morning — thirty, fifty, a hundred invoices — arrives already sorted, and the human spends their attention only on the handful that are genuinely ambiguous. If you've read how AI agents differ from a simple chatbot, this is the concrete version: an agent that does a multi-step job end to end, not a box that answers questions.

Why the counterparty check matters more than the typing

Here's the part most "invoice automation" tools ignore because it isn't glamorous: before you book a cost, you're supposed to know who you're paying. For any payment over 15 000 zł by transfer, Polish law expects you to confirm the supplier's active VAT status and that the invoice's bank account appears on the official whitelist (biała lista). Miss it and you can lose the deduction and pick up joint liability for the supplier's VAT.

A human under deadline pressure checks this... sometimes. An agent checks it every time. On each invoice it runs a verification pipeline against public registries:

  • Biała lista (the Ministry of Finance VAT whitelist) — active VAT status plus a match of the invoice's IBAN against the registered accounts, storing the query ID as proof of due diligence.
  • VIES for EU counterparties — validity of the VAT number for intra-community transactions.
  • NIP checksum and registry status as a first, free gate before anything else.

None of this is new obligation — it's existing obligation that was previously done inconsistently. Automating the pull from KSeF is what finally makes automating the check free, because the agent is already holding the invoice as data at exactly the moment the check needs to happen.

Where OCR still lives

Honesty check: KSeF doesn't cover everything. Paper receipts from a petrol station, invoices from a supplier in Germany, a pre-mandate PDF from a laggard — these never enter KSeF. The agent keeps an OCR path for exactly this tail, but treats it as the exception, not the design centre. The mistake is building your whole process around OCR when 80–90% of your domestic purchase invoices now arrive as perfect structured data through one API. Design for the KSeF path; fall back to OCR only when you must.

This is the same door KSeF already opened

If you run a wholesale or distribution business, you may recognise this argument in a different costume. I've written about how, right after a KSeF rollout, adding a B2B portal costs less because the ERP integration already exists. The accounting agent is the mirror image: KSeF opened your ERP's integration surface and created a single API where every purchase invoice appears. The portal reuses that opening to let clients order; the accounting agent reuses it to book what you buy. One rollout, two automations, same plumbing.

The end state is worth naming plainly: from the moment a supplier issues you an invoice to the moment a reviewed, verified booking sits in your accounting system, nobody retypes anything and nobody forgets the whitelist check.

Getting started without betting the farm

You don't switch this on across the whole company on day one. The sane path:

  • Start read-only: let the agent pull and draft for one cost category or one client of the accounting office, and compare its drafts against what a human would have booked for a week.
  • Keep every write as a draft with mandatory human approval — no silent posting, ever.
  • Widen the scope once the drafts are boringly correct.

Draft-only, human-in-the-loop, one category at a time. That's how you get the speed without inheriting a machine's mistakes.


I build these accounting agents for Polish accounting offices and finance teams — wired to KSeF and your existing system, draft-only, with the counterparty check built in. If you want to see what the invoice-to-books loop would look like on your setup, let's talk.

Let’s talk about your project

Free 30-minute consultation. We’ll figure out if and how I can help.

Book a Free 30-Minute Call

Select a date

July 2026
Mon
Tue
Wed
Thu
Fri
Sat
Sun
Back to Blog

Related Posts

Integrating Comarch Optima with a B2B Portal — How It Actually Works
Blog

Integrating Comarch Optima with a B2B Portal — How It Actually Works

Comarch Optima has no clean REST API like enova365. Three real integration routes to a B2B portal: distributed-work XML, direct SQL access, middleware. What to pick, how long it takes, where the traps are.

Read more
Wholesale Order Automation — From Phone Calls and Excel to a System That Runs Itself
Blog

Wholesale Order Automation — From Phone Calls and Excel to a System That Runs Itself

Your sales rep spends half the day retyping email orders into the ERP? Here's wholesale order automation broken down: B2B portal, AI email parsing, ERP integration with enova365, Subiekt and Optima — with real costs and timelines.

Read more
The EU AI Act for Small Businesses — What You Actually Have to Do Before August 2026
Blog

The EU AI Act for Small Businesses — What You Actually Have to Do Before August 2026

Using a chatbot, screening CVs with AI, processing documents? The AI Act applies to you too — but in 90% of cases the obligations are lighter than the consultants' scare stories. Here's the plain-words decision tree.

Read more