Stale Accrual Detector – CRE MicroApps vol. 1

A common financial review task is to identify and investigate expense accruals over a certain age. This helps us ferret out estimates that got stuck or maybe even items paid from another expense line. When a reviewer is tasked with dozens of reviews it can be easy to miss one and I though maybe a small app dedicated to identifying these would be beneficial.

Welcome to the first in a series of MicroApps, these will be small Python based apps that focus on one task. This comes from the Linux mehodology of make one application that does one thing really well. In this series we’ll build several applications dedicated to a sole function. This will allow the user to build a toolkit which they can depoly in depening on the situation they are in.

One of the first challenges for this MicroApp is building a way for Python to find stale accruals. The General Ledger (GL) date is useless sine it will tend to be a date in the period, so the best key is to parse the description. Of course the application needs to be nimble enough to parse the string and find a meaningful date from it.

This project was written in Python 3 using the regex and Pandas modules to support it’s code. For this post we’ll keep this high level – if you’re interested in the code please let me know!

The goals for this application are to:

  • Read a GL export
  • extracts the intended accrual period from the description
  • compares it to the current period
  • flags stale accruals
  • includes property numbers (because CRE always needs property context)
  • run from a simple command‑line interface

Even though this is a small tool, I organized it like a real Python project. Each file has one job, which keeps the code clean, readable, and easy to extend as I build more MicroApps.

The project files for the Stale Accrual Checker

These are the program files I’ve created and their purpose:

parser.pyExtracts dates from messy GL descriptions using regex patterns.
This is where the “intelligence” of the tool lives.
detector.pyApplies the stale‑accrual logic.
It takes the parsed dates, compares them to the current period, and assigns a status like ok, warning, or stale.
utils.pyHandles loading the GL file into a DataFrame.
This will become reusable across future tools.
main.pyThe command‑line interface.
This is the file you run to execute the tool.
__init__.pyAn empty file that tells Python, “This folder is a package.”
Without it, the imports between these files wouldn’t work.
This structure might look like overkill for a tiny script, but it sets me up to reuse pieces of this project in future micro‑apps — and it teaches beginners how real Python projects are organized.

How the Tool Works

The logic is simple:

  1. Load the GL file
  2. Identify accrual‑like entries (based on keywords)
  3. Extract a date from the description
  4. Normalize it into a real period end date
  5. Compare it to the current period
  6. Flag anything older than 60–90 days

This is the kind of problem where regex shines — descriptions are messy, but they follow patterns.

The Parser (parser.py)

This file looks for patterns like:

  • MM/DD/YY
  • MM/YYYY
  • MM-YYYY
  • September 25
  • Sep 2025

It returns a real datetime object representing the period.

The Detector (detector.py)

This file:

  • filters for accrual‑like descriptions
  • applies the parser
  • calculates age in days
  • assigns a status
  • includes the property number in the output

The output is a clean DataFrame you can export, filter, or drop into a report.

detector.py code (partial)

Running the Tool

From the parent directory of the project:

python -m StaleAccrualChecker.main gl.csv --current 2025-12-31

This prints a table of stale accruals, including:

  • property number
  • description
  • amount
  • parsed period
  • age in days
  • status

Example:

property_numberdescriptionamountparsed_periodage_daysstatus
100104/2025 Window Cleaning Accrual45002025‑04‑30210stale

Closing

If you’ve ever stared at a GL description trying to guess how old an accrual really is… this tool is for you. It’s small, practical, and easy to extend — and it’s the perfect starting point for building a real accounting automation toolkit in Python.

Do you want to learn how to automate your financial workpapers? Do you want to build MicroApps like this one to bloster your own automation toolkit? Do you want to get started with VBA?

My book, Beginning Microsoft Excel VBA Programming for Accountants has many examples like this to teach you to use Excel to maximize your productivity! It’s available on Amazon,Apple iBooks and other eBook retailers!






A Simple Python Machine Learning Script to help Accountants with Account Miscoding

With all the push for AI in the workplace I was curious if I could build a small program using machine learning to perform some useful function for accountants and financial reviewers – as account miscoding came to mind I wrote a program that would predict the account coding of a payable, this could aid a reviewer in determining if the months payable are coded correctly. I made a mock general ledger in Excel and trained a small machine learning model to predict which account each transaction should belong to. If the model’s prediction doesn’t match the coded account, that’s a potential miscoding.

A screenshot from Excel showing a mock general ledger for training data

This model was built in Python 3.9 using Pandas, scikit learn and a couple other modules to support transforming the Excel file into a model the program can work with. 

What is Machine Learning

Machine learning is a subset of artificial intelligence that enables computers to learn and improve from experience without being explicitly programmed, by identifying patterns in data through algorithms trained on examples like labeled images or past transactions. 

It works by feeding data into models, allowing predictions on new data. You see this everyday in recommendations for movies on streaming services, filtering spam emails, or detecting fraud in banking. 

Machine learning is basically pattern recognition.

If your GL says:

  • “Office Depot – pens” → Office Supplies
  • “Printer ink” → Office Supplies
  • “AWS cloud hosting” → IT Expense
  • “Uber to client site” → Travel
  • “Lunch with client” → Meals

…then the model learns those patterns.

Give it a new transaction like:

“AWS EC2 monthly bill – Amazon Web Services – $260”

and it will say:

“This looks like IT Expense.”

If the GL has it coded as something else, that’s a red flag.

Here’s the Python code:

#! python3
#GL Classifer Bot

import pandas as pd
from sentence_transformers import SentenceTransformer
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

df = pd.read_excel(r"C:\GL_Training_Data.xlsx")

# Load a lightweight embedding model
model = SentenceTransformer("all-MiniLM-L6-v2")

# Combine text fields into one string
df["text"] = df["Description"].astype(str) + " " + df["Vendor"].astype(str)

# Convert text to embeddings
embeddings = model.encode(df["text"].tolist())
X = np.hstack([embeddings, df[["Amount"]].values])
y = df["Account"]

X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.25, random_state=42
)

clf = RandomForestClassifier()
clf.fit(X_train, y_train)

def predict_account(description, vendor, amount):
    text = description + " " + vendor
    emb = model.encode([text])
    X_new = np.hstack([emb, [[amount]]])
    return clf.predict(X_new)[0]

print(predict_account("AWS EC2 monthly bill", "Amazon Web Services", 260.00))

the last line feeds in a transaction and the output is it’s expected coding.

A simple walkthrough

Here’s the workflow of how the application works:

1. I loaded my GL from Excel.

Just a simple table with:

  • Date
  • Description
  • Vendor
  • Amount
  • Account

2. I converted the text into “meaning vectors.”

This sounds fancy, but it’s basically a tool that turns text like:

“Uber to client site”

into a list of numbers that represent its meaning.

3. I trained a small model to learn the patterns.

It looks at:

  • the meaning of the description
  • the vendor
  • the amount
  • the account it was coded to

…and learns how they relate.

4. I asked it to predict the account for new transactions.

If the prediction doesn’t match the coded account, I flag it.

That’s it. No deep learning, no giant datasets, no complicated math.

The output with a box drawn around the predicted account

What surprised me

When I only had 8 rows of data, the model predicted everything as “Office Supplies.”
Once I added a few more rows — it suddenly started predicting correctly.

That’s the magic of small ML models:  they don’t need much to start learning.

Why this matters for accountants

This tiny example shows how machine learning can help with:

  • miscoded expense detection
  • reclass suggestions
  • anomaly spotting
  • cleaning up messy GLs
  • speeding up month‑end review

And you can build the whole thing in under an hour.

The takeaway

Machine learning doesn’t have to be intimidating.
You can start with:

  • a tiny GL
  • a few lines of Python
  • and a simple idea:
    “Does this transaction look like the account it was coded to?”

That’s enough to demonstrate the concept — and enough to spark ideas for real‑world automation. This could easily be expanded to use a more complicated general ledger and to automatically search a general ledger under review for correct coding.

Do you want to learn how to automate your financial workpapers? Do you want to get started with VBA?

My book, Beginning Microsoft Excel VBA Programming for Accountants has many examples like this to teach you to use Excel to maximize your productivity! It’s available on Amazon, Apple iBooks and other eBook retailers!