Shouldn't it be possible to encapsulate something like this with SQLite and produce an accounting engine that can guarantee consistent numbers and generate key numbers (trial balance, P&L, gearing, ...) ?
It is yes, but this is for Plain Text Accounting which allows you to put your books in version control which is an interesting way to keep track of changes over time.
Also great for "eyeball auditing". When Gnucash did something, I was never sure what actually happened. And sometimes it would crash. Was all my data safe? Hard to tell.
With ledger/hledger, I've never felt unsure about the change I'm making, and if something wipes out records I'll notice it before committing.
> When Gnucash did something, I was never sure what actually happened. And sometimes it would crash. Was all my data safe? Hard to tell.
You express it exactly, I felt the same way with Gnucash, Quicken, and all the other non-plain-text accounting apps I tried. Finance was stressful enough without also worrying about messed-up data. That was perhaps the biggest motivation to switch to Ledger, when I found it.
Later, I often could not figure out how to make Ledger do something I knew it could do, and I often was surprised by a crash or wrong behaviour when it saw some new combination of features and data that hadn't been tested or implemented yet. This was a big motivation to write hledger.
Indeed! https://www.gnucash.org/
> that can guarantee consistent numbers
It was consistent, and now it's transparent and user-friendly.
> and generate key numbers
Yes, hledger generates useful reports including trial balance, p&l