Skip to content
Tayakorn
← All projects
2026

Invoice filing from email — automatic sorting and summary

A script that pulls receipts from email with read-only access, files them by year and month, merges in the ones downloaded by hand, and builds an Excel summary — on a monthly schedule.

Role: SoloStack: Python · Gmail API · Automation
Impact

A monthly chore done by hand became something that runs itself — catching the same charge arriving twice under different dates, and flagging a regular vendor missing from the current month.

Every month a handful of service receipts trickle in by email and have to be collected for accounting. It isn't hard work — it's easy-to-forget work, and you usually notice you forgot at year end, when the numbers don't add up.

Three steps, safe to re-run

  1. Pull PDF attachments from mail whose subject looks like a receipt, using read-only access, and file them by year and month as date-vendor-type
  2. Pick up the ones you had to download by hand, because some vendors never email a receipt at all. The script reads the vendor, date and amount out of the PDF itself and files them into the same tree
  3. Build an Excel summary over the tree, counting each charge once and grouping totals by currency

Anything already fetched is skipped, so re-running never duplicates.

The bug you have to catch up front

The same charge can arrive by both routes, and the two routes disagree about its date — the emailed copy is named after the day the mail arrived, the portal copy after the date printed inside the document, routinely one or two days apart. Left alone, that vendor's monthly total silently doubles. So the rule is: same vendor, same type, same amount within five days is the same charge.

Never guess, and speak up when something is missing

If the date or vendor can't be read, it doesn't guess — the file stays where it is and gets reported. A misfiled document is harder to find than an unfiled one.

And since the real failure mode here is forgetting rather than breaking, it warns when a vendor that bills every month is missing from the current one. The whole thing runs itself on the 1st and leaves a log behind.

A personal tool, not open-sourced — it's wired to a real mailbox.