Skip to main content

3 posts tagged with "business accounting"

View All Tags

Automating Small Business Expenses with Beancount and AI

· 6 min read
Mike Thrift
Mike Thrift
Marketing Manager

Small business owners spend an average of 11 hours per month manually categorizing expenses - nearly three full workweeks annually devoted to data entry. A 2023 QuickBooks survey reveals that 68% of business owners rank expense tracking as their most frustrating bookkeeping task, yet only 15% have embraced automation solutions.

Plain text accounting, powered by tools like Beancount, offers a fresh approach to financial management. By combining transparent, programmable architecture with modern AI capabilities, businesses can achieve highly accurate expense categorization while maintaining full control over their data.

2025-05-28-how-to-automate-small-business-expense-categorization-with-plain-text-accounting-a-step-by-step-guide-for-beancount-users

This guide will walk you through building an expense automation system tailored to your business's unique patterns. You'll learn why traditional software falls short, how to harness Beancount's plain text foundation, and practical steps for implementing adaptive machine learning models.

The Hidden Costs of Manual Expense Management

Manual expense categorization drains more than just time—it undermines business potential. Consider the opportunity cost: those hours spent matching receipts to categories could instead fuel business growth, strengthen client relationships, or refine your offerings.

A recent Accounting Today survey found small business owners dedicate 10 hours weekly to bookkeeping tasks. Beyond the time sink, manual processes introduce risks. Take the case of a digital marketing agency that discovered their manual categorization had inflated travel expenses by 20%, distorting their financial planning and decision-making.

Poor financial management remains a leading cause of small business failure, according to the Small Business Administration. Misclassified expenses can mask profitability issues, overlook cost-saving opportunities, and create tax season headaches.

Beancount's Architecture: Where Simplicity Meets Power

Beancount's plain-text foundation transforms financial data into code, making every transaction trackable and AI-ready. Unlike traditional software trapped in proprietary databases, Beancount's approach enables version control through tools like Git, creating an audit trail for every change.

This open architecture allows seamless integration with programming languages and AI tools. A digital marketing agency reported saving 12 monthly hours through custom scripts that automatically categorize transactions based on their specific business rules.

The plain text format ensures data remains accessible and portable—no vendor lock-in means businesses can adapt as technology evolves. This flexibility, combined with robust automation capabilities, creates a foundation for sophisticated financial management without sacrificing simplicity.

Creating Your Automation Pipeline

Building an expense automation system with Beancount starts with organizing your financial data. Let's walk through a practical implementation using real examples.

1. Setting Up Your Beancount Structure

First, establish your account structure and categories:

2025-01-01 open Assets:Business:Checking
2025-01-01 open Expenses:Office:Supplies
2025-01-01 open Expenses:Software:Subscriptions
2025-01-01 open Expenses:Marketing:Advertising
2025-01-01 open Liabilities:CreditCard

2. Creating Automation Rules

Here's a Python script that demonstrates automatic categorization:

import pandas as pd
from datetime import datetime

def categorize_transaction(description, amount):
rules = {
'ADOBE': 'Expenses:Software:Subscriptions',
'OFFICE DEPOT': 'Expenses:Office:Supplies',
'FACEBOOK ADS': 'Expenses:Marketing:Advertising'
}

for vendor, category in rules.items():
if vendor.lower() in description.lower():
return category
return 'Expenses:Uncategorized'

def generate_beancount_entry(row):
date = row['date'].strftime('%Y-%m-%d')
desc = row['description']
amount = abs(float(row['amount']))
category = categorize_transaction(desc, amount)

return f'''
{date} * "{desc}"
{category} {amount:.2f} USD
Liabilities:CreditCard -{amount:.2f} USD
'''

3. Processing Transactions

Here's how the automated entries look in your Beancount file:

2025-05-01 * "ADOBE CREATIVE CLOUD"
Expenses:Software:Subscriptions 52.99 USD
Liabilities:CreditCard -52.99 USD

2025-05-02 * "OFFICE DEPOT #1234 - PRINTER PAPER"
Expenses:Office:Supplies 45.67 USD
Liabilities:CreditCard -45.67 USD

2025-05-03 * "FACEBOOK ADS #FB12345"
Expenses:Marketing:Advertising 250.00 USD
Liabilities:CreditCard -250.00 USD

Testing proves crucial—start with a subset of transactions to verify categorization accuracy. Regular execution through task schedulers can save 10+ hours monthly, freeing you to focus on strategic priorities.

Achieving High Accuracy Through Advanced Techniques

Let's explore how to combine machine learning with pattern matching for precise categorization.

Pattern Matching with Regular Expressions

import re

patterns = {
r'(?i)aws.*cloud': 'Expenses:Cloud:AWS',
r'(?i)(zoom|slack|notion).*subscription': 'Expenses:Software:Subscriptions',
r'(?i)(uber|lyft|taxi)': 'Expenses:Travel:Transport',
r'(?i)(marriott|hilton|airbnb)': 'Expenses:Travel:Accommodation'
}

def regex_categorize(description):
for pattern, category in patterns.items():
if re.search(pattern, description):
return category
return None

Machine Learning Integration

from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
import re
from typing import List, Tuple

class ExpenseClassifier:
def __init__(self):
self.vectorizer = TfidfVectorizer()
self.classifier = MultinomialNB()

def parse_beancount_entries(self, beancount_text: str) -> List[Tuple[str, str]]:
"""Parse Beancount entries into (description, category) pairs."""
entries = []
for line in beancount_text.split('\n'):
# Look for transaction descriptions
if '* "' in line:
desc = re.search('"(.+)"', line)
if desc:
description = desc.group(1)
# Get the next line which should contain the expense category
next_line = next(filter(None, beancount_text.split('\n')[beancount_text.split('\n').index(line)+1:]))
if 'Expenses:' in next_line:
category = next_line.split()[0].strip()
entries.append((description, category))
return entries

def train(self, beancount_text: str):
"""Train the classifier using Beancount entries."""
entries = self.parse_beancount_entries(beancount_text)
if not entries:
raise ValueError("No valid entries found in training data")

descriptions, categories = zip(*entries)
X = self.vectorizer.fit_transform(descriptions)
self.classifier.fit(X, categories)

def predict(self, description: str) -> str:
"""Predict category for a new transaction description."""
X = self.vectorizer.transform([description])
return self.classifier.predict(X)[0]

# Example usage with training data:
classifier = ExpenseClassifier()

training_data = """
2025-04-01 * "AWS Cloud Services Monthly Bill"
Expenses:Cloud:AWS 150.00 USD
Liabilities:CreditCard -150.00 USD

2025-04-02 * "Zoom Monthly Subscription"
Expenses:Software:Subscriptions 14.99 USD
Liabilities:CreditCard -14.99 USD

2025-04-03 * "AWS EC2 Instances"
Expenses:Cloud:AWS 250.00 USD
Liabilities:CreditCard -250.00 USD

2025-04-04 * "Slack Annual Plan"
Expenses:Software:Subscriptions 120.00 USD
Liabilities:CreditCard -120.00 USD
"""

# Train the classifier
classifier.train(training_data)

# Test predictions
test_descriptions = [
"AWS Lambda Services",
"Zoom Webinar Add-on",
"Microsoft Teams Subscription"
]

for desc in test_descriptions:
predicted_category = classifier.predict(desc)
print(f"Description: {desc}")
print(f"Predicted Category: {predicted_category}\n")

This implementation includes:

  • Proper parsing of Beancount entries
  • Training data with multiple examples per category
  • Type hints for better code clarity
  • Error handling for invalid training data
  • Example predictions with similar but unseen transactions

### Combining Both Approaches

```beancount
2025-05-15 * "AWS Cloud Platform - Monthly Usage"
Expenses:Cloud:AWS 234.56 USD
Liabilities:CreditCard -234.56 USD

2025-05-15 * "Uber Trip - Client Meeting"
Expenses:Travel:Transport 45.00 USD
Liabilities:CreditCard -45.00 USD

2025-05-16 * "Marriott Hotel - Conference Stay"
Expenses:Travel:Accommodation 299.99 USD
Liabilities:CreditCard -299.99 USD

This hybrid approach achieves remarkable accuracy by:

  1. Using regex for predictable patterns (subscriptions, vendors)
  2. Applying ML for complex or new transactions
  3. Maintaining a feedback loop for continuous improvement

A tech startup implemented these techniques to automate their expense tracking, reducing manual processing time by 12 hours monthly while maintaining 99% accuracy.

Tracking Impact and Optimization

Measure your automation success through concrete metrics: time saved, error reduction, and team satisfaction. Track how automation affects broader financial indicators like cash flow accuracy and forecasting reliability.

Random transaction sampling helps verify categorization accuracy. When discrepancies arise, refine your rules or update training data. Analytics tools integrated with Beancount can reveal spending patterns and optimization opportunities previously hidden in manual processes.

Engage with the Beancount community to discover emerging best practices and optimization techniques. Regular refinement ensures your system continues delivering value as your business evolves.

Moving Forward

Automated plain-text accounting represents a fundamental shift in financial management. Beancount's approach combines human oversight with AI precision, delivering accuracy while maintaining transparency and control.

The benefits extend beyond time savings—think clearer financial insights, reduced errors, and more informed decision-making. Whether you're technically inclined or focused on business growth, this framework offers a path to more efficient financial operations.

Start small, measure carefully, and build on success. Your journey toward automated financial management begins with a single transaction.

Understanding Receivables and Payables in Beancount

· 3 min read
Mike Thrift
Mike Thrift
Marketing Manager

Hello everyone! In today's blog post, we're diving into the world of Beancount, a double-entry accounting tool that's loved by many for its simplicity and power. More specifically, we're going to talk about two key concepts: Receivables and Payables.

Understanding these terms is crucial to using Beancount (or any double-entry accounting system) effectively. But don't worry if you're a beginner - we're going to break it all down, step by step!

Receivables and Payables: The Basics

2023-05-30-receiveable-and-payable

In accounting, "receivables" and "payables" are terms used to track money that is owed. "Receivables" refers to money that others owe to you, while "payables" refers to money that you owe to others.

Let's take an example:

  1. Accounts Receivable (A/R): Suppose you own a bookstore and a customer buys a book on credit. The money they owe you for the book is an account receivable.

  2. Accounts Payable (A/P): On the flip side, imagine you order a new set of books from a publisher, but you don't pay for them upfront. The money you owe the publisher is an account payable.

In Beancount, these are typically tracked through corresponding accounts. The main benefit here is that it provides you with a clear and accurate picture of your financial position at any point in time.

Setting Up Receivables and Payables in Beancount

The structure of your Beancount file can be as simple or as complex as you need it to be. For receivables and payables, you'll likely want to create separate accounts under your Assets and Liabilities sections.

Here is a simple example:

1970-01-01 open Assets:AccountsReceivable
1970-01-01 open Liabilities:AccountsPayable

Tracking Transactions

Payee side

After setting up your accounts, you can track transactions that involve receivables and payables. Let's look at an example:

2023-05-29 * "Sold books to customer on credit"
Assets:AccountsReceivable 100 USD
Income:BookSales -100 USD

Here, you're adding $100 to your receivables because a customer owes you this amount. Simultaneously, you're reducing your income by the same amount to maintain the balance (since you haven't actually received the money yet).

When the customer eventually pays, you'll record it like this:

2023-06-01 * "Received payment from customer"
Assets:Bank:Savings 100 USD
Assets:AccountsReceivable -100 USD

Payer side

The same principle applies for payables, but with reversed signs:

2023-05-30 * "Bought books from publisher on credit"
Liabilities:AccountsPayable 200 USD
Expenses:BookPurchases -200 USD

And when you pay off your debt:

2023-06-02 * "Paid off debt to publisher"
Liabilities:AccountsPayable -200 USD
Assets:Bank:Checking 200 USD

Wrapping Up

Receivables and payables are at the heart of any accounting system. By accurately tracking these, you gain a comprehensive understanding of your financial health.

This is just a starting point, and Beancount is capable of much more. I hope this blog post helps clarify these important concepts. As always, happy accounting!

Deconstructing a Beancount Ledger: A Case Study for Business Accounting

· 3 min read
Mike Thrift
Mike Thrift
Marketing Manager

In today's blog post, we will be breaking down a Beancount ledger for businesses, which will help you understand the intricacies of this plain text double-entry accounting system.

Deconstructing a Beancount Ledger: A Case Study for Business Accounting

Let's start with the code first:

2023-05-22-business-template

1970-01-01 open Assets:Bank:Mercury
1970-01-01 open Assets:Crypto

1970-01-01 open Equity:Bank:Chase

1970-01-01 open Income:Stripe
1970-01-01 open Income:Crypto:ETH

1970-01-01 open Expenses:COGS
1970-01-01 open Expenses:COGS:Contabo
1970-01-01 open Expenses:COGS:AmazonWebServices

1970-01-01 open Expenses:BusinessExpenses
1970-01-01 open Expenses:BusinessExpenses:ChatGPT

2023-05-14 * "CONTABO.COM" "Mercury Checking ••1234"
Expenses:COGS:Contabo 17.49 USD
Assets:Bank:Mercury -17.49 USD

2023-05-11 * "Amazon Web Services" "Mercury Checking ••1234"
Expenses:COGS:AmazonWebServices 14490.33 USD
Assets:Bank:Mercury -14490.33 USD

2023-03-01 * "STRIPE" "Mercury Checking ••1234"
Income:Stripe -21230.75 USD
Assets:Bank:Mercury 21230.75 USD

2023-05-18 * "customer_182734" "0x5190E84918FD67706A9DFDb337d5744dF4EE5f3f"
Assets:Crypto -19 ETH {1,856.20 USD}
Income:Crypto:ETH 19 ETH @@ 35267.8 USD

Understanding the Code

  1. Opening Accounts: The code starts by opening a series of accounts on 1970-01-01. These include a mix of asset accounts (Assets:Bank:Mercury and Assets:Crypto), an equity account (Equity:Bank:Chase), income accounts (Income:Stripe and Income:Crypto:ETH), and expense accounts (Expenses:COGS, Expenses:COGS:AmazonWebServices, Expenses:BusinessExpenses, and Expenses:BusinessExpenses:ChatGPT).

  2. Transactions: It then progresses to record a series of transactions between 2023-03-01 and 2023-05-18.

    • The transaction on 2023-05-14 represents a payment of $17.49 to CONTABO.COM from Mercury Checking ••1234. This is recorded as an expense (Expenses:COGS:Contabo) and a corresponding deduction from the Assets:Bank:Mercury account.

    • Similarly, the transaction on 2023-05-11 represents a payment of $14490.33 to Amazon Web Services from the same bank account. This is logged under Expenses:COGS:AmazonWebServices.

    • The transaction on 2023-03-01 shows income from STRIPE being deposited into Mercury Checking ••1234, totaling $21230.75. This is recorded as income (Income:Stripe) and an addition to the bank account (Assets:Bank:Mercury).

    • The last transaction on 2023-05-18 represents a crypto transaction involving 19 ETH from a customer. This is tracked under Assets:Crypto and Income:Crypto:ETH. The {1,856.20 USD} shows the price of ETH at the time of transaction, while the @@ 35267.8 USD specifies the total value of the 19 ETH transaction.

In all transactions, the principle of double-entry accounting is maintained, ensuring that the equation Assets = Liabilities + Equity always holds true.

Final Thoughts

This Beancount ledger provides a straightforward yet robust system for tracking financial transactions. As seen in the final transaction, Beancount is flexible enough to account for non-traditional assets like cryptocurrency, which is a testament to its utility in our increasingly digital financial landscape.

We hope this breakdown helps you better understand the structure and capabilities of Beancount, whether you're a seasoned accountant or a beginner trying to keep track of your personal finances. Stay tuned for our next blog post, where we'll delve further into advanced Beancount operations.