Skip to main content
Data Resources

Models and stories for finance data

Working Excel, Python and SQL models built by finance professionals, and data stories that explain the numbers behind the news. Every model is explained sheet by sheet and paired with a DATA DARE practice dataset.

Python model

Accounts Payable Analysis in Python — DPO, Overdue and Duplicate Invoices (pandas)

Accounts payable analysis answers three questions a treasurer asks constantly: what do we owe, how much of it is late, and how long are we taking to pay. Each one needs a rule rather than a number — owed means invoiced less paid at a date, and late means past a due date that is different for every supplier. This notebook writes those rules once in pandas, applies them across 15,129 invoices and 14,542 payments, and ends by finding six invoices that were entered twice and the part of them still inflating the liability today.

By findi360 · Updated November 2026

Accounts Payable in Python — Jupyter Notebook
Format
Jupyter notebook (.ipynb), outputs saved
Data
DATA DARE DD-APY-001 · 15,129 supplier invoices · 14,542 payments · 2024 to September 2026
Covers
30 questions, easy to very hard
Needs
Python 3.9+, pandas, openpyxl

Download and share

Downloads need a findi360 account — create one in a minute and the file starts straight away. Already a member? Sign in

No account? Get this model by email.
One model by email is free. For more, a free account takes a minute.

Continue with Google

The two rules that decide most answers

What is owed at a date is everything invoiced on or before it, less everything paid on or before it. When an invoice falls due is its invoice date plus that supplier's own payment terms — thirty days for some, sixty or ninety for others — which live in the supplier master and are joined on before anything else happens. A flat thirty days across the ledger is the most common mistake in a payables report, and it moves both the overdue figure and DPO.

DPO, and the three months behind it

Days payable outstanding is what is owed divided by the purchases of the three calendar months ending at the measurement date, multiplied by the days in those months. Taking a full year of purchases instead would smooth away exactly the seasonality a treasurer is watching for. The notebook writes DPO as a function of one date, which is why the final question can run it at thirty consecutive month-ends and point to the month suppliers waited longest.

How late the company really pays

Each payment carries the journal reference of the invoice it settles, so the two tables join and every payment gains two numbers: days from invoice to payment, and days past the due date. From those come the average days to pay, the share of payments made more than a week late, and the payments made more than three days early — which in a business with cash pressure is usually a sign of a supplier with leverage.

The invoices posted twice

A duplicate here is a second invoice with the same supplier, the same supplier invoice number and the same amount as an earlier one. Blank supplier invoice numbers — and there are 730 of them in a single year — cannot be checked this way, which is itself the point: the gap in the control is the reason duplicates get in. Six slipped through, and the last question works out how much of them is still sitting in the liability on the final day of the data.

Python or Excel?

An ageing of open payables at one date is an Excel job. Thirty consecutive month-ends of DPO is not, and neither is a duplicate check across 15,000 rows with per-supplier terms. The notebook does both in seconds and shows the working — and it runs again unchanged on next month's export.

Inside the notebook

  1. Libraries — A cell that tells you which libraries are missing before anything else runs.
  2. Load the sheets — Supplier invoices, payments, the supplier master, the payment plan and the calendar.
  3. First look — Column types, the spread of payment terms, and the date ranges on both sides.
  4. Fix the data — The year on each side, and a due date on every invoice from its own supplier's terms.
  5. The working functions — Owed, unpaid and overdue at a date; DPO at a date; payments joined to their invoices.
  6. The answers, Q01 to Q30 — One cell per question, each ending with the answer, and a final list of all thirty.

Excel + Python — the Power of Plus

Excel does this model well when all five of these are true. When two or more are not, you add Python — not instead of Excel, beside it. That is the Power of Plus.

  1. One-off — you build it once, not again every month.
  2. Fixed structure — the same accounts, entities and layout each time.
  3. Small enough to check by eye — thousands of rows, not millions.
  4. One source — one ledger or one plan, not data scattered across systems and files.
  5. No live link needed — nobody expects it to update from the ledger by itself.
Excel

What next month's payables report really costs in Excel

  1. Paste both exports in and extend the lookups that give each invoice its supplier terms.
  2. Rebuild the open-items list at the new date, and the overdue split with it.
  3. Work DPO again — and again for every earlier month-end you want to compare it with.
  4. Re-run the duplicate check by sorting and eyeballing, which is where duplicates survive.
Python

The same work, once it repeats

In Python owed, overdue and DPO are functions of a date: thirty month-ends is one line, and the duplicate check cannot be skipped by tired eyes.

Python still needs your judgement where the data is new — but everything after that repeats by itself.

Learn it on findi360: Python for Finance — Advanced Analytics & Reporting

Notify me when it opens

Want to see what scattered data looks like? Three ERPs, three currencies and one consolidated group: DD-CON-004 — Diversified Group Close: Acquisition, Goodwill & Multi-ERP Consolidation

Who this model is for

  • Accounts payable and treasury teams reporting what is owed, what is late and DPO
  • Controllers and internal auditors testing for duplicate payments and weak invoice-number controls
  • Finance people learning Python on a ledger that behaves like their own

Frequently asked questions

Do I need to know Python already?

No. Every block is introduced in plain words, and the three rules that matter — owed, due, overdue — are written as short functions you can read.

How is DPO calculated here?

What is owed at the date, divided by the purchases of the three calendar months ending on that date, multiplied by the number of days in those three months. The notebook shows both halves of the division so you can compare it with your own definition.

Can I run it on my own purchase ledger?

Yes, once the column names match. It expects supplier invoices with a supplier code, a date and an amount, payments carrying the invoice's journal reference, and a supplier master with payment terms.

How do I find duplicate invoices in my own data?

The same way the notebook does: group by supplier, supplier invoice number and amount, and keep everything after the first in each group. Then check whether those are still unpaid — a duplicate that was paid is a recovery conversation, one that is open is simply a wrong liability.

Are the answers correct?

All thirty were compared with the Expected_Result_Value in the dataset's Question Bank, on pandas 2.2.3 and 3.0.5, before the file was published.

Keep going on findi360

Related models

  • AR Analysis in Python — Jupyter Notebook

    A complete receivables working file in pandas: load four file formats, append the new quarter, build six working tables, then answer forty graded questions — from the ageing bucket to the overdue book corrected for cash nobody could place.

  • 13-Week Cash Flow Forecast in Python — Jupyter Notebook

    The thirteen-week cash forecast built the way a treasury team builds it — from the invoices open on the day it is made, the delay each customer really takes, the Monday payment run and the dates treasury already knows — and then the same forecast run for last year and marked against the bank.

  • Trial Balance in Python — Jupyter Notebook

    The general ledger worked end to end in pandas: a trial balance that proves it balances, a profit and loss account by reporting line, actuals against budget, and a gross profit bridge that explains why profit grew less than sales.

Need a model we have not built yet?

Tell us what you need. Members vote, and the most-requested models are built first — free to download.

Educational model on illustrative data. Not investment, accounting or tax advice. © findi360 — share freely with attribution.