From code lines to orchestrated background task workflows at scale
Lessons from building and maintaining enterprise-scale systems with Django, PostgreSQL, Celery, and RabbitMQ — the hard problems nobody warns you about.
Read storyWhy fintech software engineers should learn and embrace the double-entry accounting system?

Furthermore, would you believe if I said that it’s possible to manage the state of an object in software engineering using a financial accounting system?
As I write this article, two years have passed since I joined Moneyflow A/S as a software engineer. This company provides embedded financing services, specifically invoice factoring. It is ok if these terms don’t ring a bell.
Let me (try to) explain it. Imagine your company issues an invoice to a customer using an ERP (Enterprise Resource Planning) system. Normally, you’d have to wait for the customer to pay the invoice, which could take days, weeks or even months.
But if your business requires immediate liquidity (a.k.a. cash), you can opt to sell the invoice directly to Moneyflow from the ERP system for a small fee (of course). And within a few hours, the money (invoice amount minus the fee) will be deposited into your bank account.
From definition, breakdown:
Probably, I had to start with the definition first :) Back to the studio…
In other words, you can say that the factoring system lives under the hood (is embedded) of an accounting system. Whenever a new invoice is issued the factoring system:
In this article, we are focusing on the last part - financial accounting, which heavily relies on:
Luckily, dependable financial systems that address the challenges mentioned above existed far longer than the Gang of Four (design patterns).
Dating back to 1494, the system of double-entry accounting has stood the test of time, so there is no need to reinvent the wheel here. Learning double-entry accounting was also one of the greatest skills I’ve picked up during the past two years (thank you Mathias and Alexander).
For simplicity’s sake, I will skip the “how it works” part and get strict to the points on why the double-entry accounting system is reliable:
Each transaction has its source and destination. Meaning, it has at least two entries, each of which corresponds to one account. One account represents the source (credit) and the other represents the use of funds (debit). In other words, you can trace back where the money came from and where it went.
A single account reflects a specific aspect of the company’s financial position or transaction history. By examining an account’s balance (sum of transaction entries), you can discern the state of the current asset.
For example, in the context of invoice factoring, you can check if the invoice has been paid back:
receivables_balance = Transactions(
account="receivables"
).sum()
if receivables_balance > 0:
print("awaiting_payment")
elif receivables_balance == 0:
print("paid_back")
elif receivables_balance < 0:
print("paid_back, handle_overpaid_balance")
Since the system ensures that every financial entry (a subset of the transaction) is recorded twice. Once as debit and once as credit. And on top of that you also have to check if the entries are balanced: sum(debit) == sum(credit). This makes it easier for errors or discrepancies to be noticed.
Using double-entry bookkeeping eliminates the need for complex state machines. It simplifies maintenance, even with new features, making it a robust framework for managing state in financial applications. If there is a need for a new state, consider creating a new account in the flow.
Over the past two years, with the help of the double-entry accounting system, I was able to:
I believe the double-entry accounting system should be used whenever your system involves currency. For example, in video games, you could use the system to:
Just because you are a software engineer doesn’t mean that you have to use only software architecture design patterns. Don’t be afraid to look out for systems that have existed long before computers.
If you feel adventurous, here are some good articles, and videos on how exactly financial accounting works: