04 / Finance automation · Moglix

Payment Advice

Project study

Reads customer payment advices and auto-maps every payment to the right open invoices for the finance team.

Payment Advice Automation / Finance automation · Moglix / 2026

Role
Backend & ML · AI & Analytics team
Status
In production
Year
2026
Stack
Python / Django / Celery / Kafka / Redis / MongoDB / MySQL / Qdrant / LayoutLMv3 / HDBSCAN / Gemini / HTMX / Docker

02 / Overview

A payment arrives with a PDF. The invoices close themselves.

When a customer pays, they send a payment advice: a document listing which invoices the money covers, the UTR and any tax deducted. This pipeline reads those advices from support tickets, extracts every line, checks it against the ERP and the bank, and maps the payment to open invoices for the accounts-receivable team.

  1. Collect
  2. Classify
  3. Extract
  4. Validate
  5. Map
  6. Learn

Payment Advice Automation / how the parts connect

03 / The problem

Every customer sends the same information in a different shape.

Advices arrive as PDFs, spreadsheets and emails, each customer with its own layout, and some run to hundreds of pages. Matching them to invoices by hand is slow, and a small mistake means a payment sits unapplied or an invoice stays open.

  1. 01

    A different layout for every customer

  2. 02

    Long advices with hundreds of invoice lines

  3. 03

    Manual matching against the ERP and bank entries

04 / How it works

From a ticket to a mapped payment, in six steps.

  1. 01

    Collect

    Tickets flow in from the helpdesk through Kafka and Celery workers.

  2. 02

    Classify

    LayoutLMv3 and Qdrant layout matching route each advice to the right parser.

  3. 03

    Extract

    14+ customer-specific parsers pull UTRs, invoices and TDS, with Gemini as fallback.

  4. 04

    Validate

    Extracted payments are checked against the ERP and matched to bank entries.

  5. 05

    Map

    Payments are auto-mapped to open invoices behind open-balance and deduction guards.

  6. 06

    Learn

    HDBSCAN clusters unseen layouts and Gemini writes a parser config for each one.

05 / Key decisions

Where the important calls were made.

Decision 01

Parsers or an LLM for every document?

  1. →

    The choice

    Fast deterministic parsers first, Gemini only as the fallback.

  2. →

    What it gave

    Most advices are parsed in a fraction of a second, cheaply and predictably.

Decision 02

How do new customer layouts get supported?

  1. →

    The choice

    A self-learning loop: cluster unseen layouts, generate a config, activate it only above 80% held-out accuracy.

  2. →

    What it gave

    New formats come online without hand-writing every parser.

Decision 03

How do you change the model safely?

  1. →

    The choice

    An A/B harness compares models on real advices before switching.

  2. →

    What it gave

    The model migration made extraction about 3× faster and cheaper.

06 / The flow

From the first step to the result.

What it looks like from the side of the person using it — the path through Payment Advice in 4 steps.

  1. 01An advice arrives in a ticket
  2. 02It is classified and parsed
  3. 03Payments are validated and mapped
  4. 04Finance reviews it in the dashboard

Payment Advice Automation / user flow

07 / Outcome

Cash application that runs itself, with a person still in control.

Customer-specific parsers
14+
To parse a 100+ page advice
~0.2 s
Faster, cheaper extraction
~3×
05 / Next project Repo-Safety A static scanner that checks an untrusted repo or ZIP, like a “take-home test”, for hidden auto-run malware before you open it.