Double-Entry Accounting Guide for Software Engineers — Part One: Why We Need It

Sergey Radzishevskii
6 min readDec 23, 2023

I’m not a professional accountant; I’m a software engineer. I don’t claim to unveil any secrets about the double-entry system. Everything is already available on the internet. However, for people unfamiliar with accounting, understanding its significance can be challenging. That’s why I’m writing this series of articles for engineers like me who are likely working on a product, whether it’s a startup or an established business, that requires some financial tracking and reporting. First and foremost, let’s try to understand why the double-entry system is necessary.

Even those unfamiliar with accounting know the basic principle: all money must be accounted for, and debits must match credits. The double-entry system was invented centuries ago, even before the advent of negative numbers, and it was genuinely revolutionary for its time. But nowadays, as software engineers, we meticulously track all transactions in our applications. We diligently record every event in the system that can in any way affect calculations. We can easily track all money flows. Do we still need a double-entry system?

A Real-Life Scenario: Managing Finances in a Marketplace Application

Let’s consider an example. Imagine a fictional application — Firecnc. It’s a new startup application that allows apartment owners to rent them out to tenants. Firecnc earns a percentage from each booking.

In this scenario, we have two user roles — owners and tenants, and we need to implement the following sequence:

  • Tenants make reservations and pay Firecnc.
  • Firecnc holds the money until the booking is completed.
  • Firecnc transfers money to the apartment owner’s account and retains its percentage.
  • Apartment owners withdraw money from their Firecnc balance to their bank accounts.

Now, let’s think about the data sources we need to implement this scenario. I simplified details to make it easier to understand.

  • Booking: To store booking information.
  • Payment: To track incoming payments from tenants.
  • Transfer: To track transfers of held funds to owner balance.
  • Payouts: To track owner withdrawals to their bank accounts.

To calculate an owner’s balance, we need to sum up all transfers to their account and deduct payouts.

SELECT SUM(amount)
FROM transfer t
WHERE user_id = 123
) AS total_transfers_amount -
SELECT SUM(amount - stripe_payout_fee)
FROM payout p
WHERE user_id = 123
) AS total_payouts

Preventing Unaccounted Funds

One day, we received a complaint from one of our owners that a tenant had caused damage to the apartment. The booking was for $700. As Firecnc is a new app, the team aims to build trust with owners. The product team asks the engineer to add $100 to the owner’s balance. After some thought, the engineer added a new transfer, referencing the existing booking worth $100. This action increases the owner’s balance by $100, and the issue is resolved while maintaining a reference to the existing booking for tracking purposes.

At the end of the year, management requests financial statements regarding profits. And this is where the problems begin. The income in the report does not match what we have in our bank account. According to our data, we were supposed to receive $700 and transfer it to the owner, but in reality, we transferred $700 + $100. Instead of recognizing this $100 as a loss, we mistakenly treated it as if it magically appeared in our records.

What complicates matters is that such unaccounted expenses occurred repeatedly. As the year wraps up, it becomes increasingly difficult to untangle and classify these losses.

This is precisely the scenario where the double-entry system prevents such discrepancies. With double-entry, you can’t simply inject money into the system without specifying its intended source.

Of course, one might argue that this doesn’t apply to their application, and they’ve learned the lesson, now tracking such fixes as expenses. However, the main idea here is that the next day, another case like this may arise, leading to unaccounted funds in the system. The double-entry system wouldn’t permit such actions.

Preventing Uncategorized Funds

The team successfully resolved the issue of unaccounted funds, ensuring greater financial transparency and trust among owners. At the end of the following year, the product team asks the engineer to prepare a profit report. After some thought, the engineer prepares an SQL query:

SELECT SUM(amount)
FROM booking_fee
WHERE created_at >= '2023-01-01'
AND created_at < '2024-01-01'

However, upon reviewing the report, the CFO points out a discrepancy. The numbers don’t match what’s in the bank account. The oversight? Forgetting about expenses. A fee of 0.25 cents is applied to every payout.

This is a simplified example, but in real-life applications, you’ll come across various sources of income and different types of expenses. The double-entry system, combined with a ledger, enables you to methodically monitor and categorize all forms of funds within the system. Whether it’s liabilities, expenses, income, receivables, or payables accounts, double entry allows you to track all income sources and uses. It’s a widely recognized and robust accounting method.

Calculate Balances with Ease

As Firecnc gains popularity, the product team seeks to enhance flexibility, particularly for owners. They aim to introduce a subscription system offering various benefits and access to new tools. The Pro subscription, for example, grants owners the ability to obtain insurance coverage in case of unexpected damage events. To facilitate this, we’ve implemented a new table, “damage_insurance_transfer,” to track damage insurance transactions. Now, all owner transactions are meticulously recorded through “owner_transaction.” With the increasing variety of transaction types, including transfers upon booking confirmation, partial refunds for tenant cancellations, funds received through damage insurance, withdrawals, and failed withdrawals, accurately tracking owner balances becomes more crucial than ever.

Table owner_transaction {
id int not null,
amount float not null,
transfer_id int,
refund_id int,
damage_insurance_transfer_id int,
payout_id int,
failed_payout_id int,

Simultaneously, calculating funds for other accounts, such as Firecnc’s incomes and expenses, becomes more complex as we account for various transaction scenarios. This is where a ledger, built upon the principles of double-entry accounting, proves invaluable. A well-structured ledger can effortlessly compute balances for any account within your system, whether it’s a system account like current income or expenses or individual client accounts holding available balances.

Summary: Ensuring Financial Accuracy with Double-Entry Accounting

In the realm of software engineering, where precision and financial transparency reign supreme, the double-entry accounting system stands as an unwavering sentinel against discrepancies and hidden financial mysteries.

Double-entry accounting enforces a strict rule: every cent within your system must have a clear source; nothing can materialize out of thin air. It diligently categorizes all financial inflows and outflows, whether they be income, expenses, or bank loans. These categorizations serve as the cornerstone for meticulous fund tracking and the creation of comprehensive financial reports. This system lays the groundwork for essential financial documents, including the Profit and Loss Statement and the Balance Sheet, assuring that no detail goes unnoticed. For startups and applications alike, these reports are indispensable, offering a clear and accountable financial perspective. With the double-entry accounting system as your ally, financial clarity becomes an attainable goal in the dynamic world of software engineering.

PS: What’s Next?

In this part, we’ve explored why the double-entry system is essential and how it can help us prevent errors in financial tracking. However, we haven’t delved into the mechanics of building one just yet. In the next parts, we will learn how double entry works and construct a ledger with double-entry principles at its core for the Firecnc application.

Stay tuned for the upcoming part, where we’ll turn theory into practice and build a functional double-entry ledger.



Sergey Radzishevskii

Enjoy turning complex systems into intelligible architectures chilling in my garden.