TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: A complete double-entry accounting system in PostgreSQL

4 pointsby gerdembabout 1 year ago
I wanted to share an interesting experiment I&#x27;ve been working on: creating a double-entry accounting system entirely in a PostgreSQL database. It&#x27;s inspired by plain-text accounting, especially Beancount, a fantastic project for plain-text double-entry accounting.<p>I&#x27;ve implemented most core accounting features as PostgreSQL functions, including multi-currency support, account balance calculations, and cost-basis calculations for lot matching, average cost, FIFO, or LIFO. It turns out it&#x27;s easier to create a &quot;database-based&quot; accounting system than you&#x27;d think! The core idea is to use a custom PostgreSQL type called amount, which combines a numeric value with a currency and then write custom aggregation functions to sum amounts into balances (baskets of currencies) which can be used in other custom functions.<p>I also created two Python scripts: one to import Beancount files into the database and another to export the database back to a Beancount file. I&#x27;ve been using this system, called Beanpost, with my personal Beancount file, which has about four years of data and over 10,000 transactions across multiple currencies.<p>I started Beanpost for fun and to create a backend for a custom mobile-friendly web app using Beancount data. While a database isn&#x27;t as immediately usable as a text file, the possibilities for integrating with other tools are broader.<p>I&#x27;m not sure where to take this next, but it&#x27;s been a fun experiment, and I hope some of you find it intriguing. I&#x27;d love to hear any feedback or suggestions! Here&#x27;s the link if you&#x27;d like to check it out:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;gerdemb&#x2F;beanpost">https:&#x2F;&#x2F;github.com&#x2F;gerdemb&#x2F;beanpost</a>

1 comment

jdenningabout 1 year ago
Very nice - thanks for posting!