Re:Double-Entry Ledgers: The Missing Primitive in Modern Sof...
by pgr0ss on Friday June 20, 2025 @03:32PM
(#44331165)
I updated the README and added an example test: https://github.com/pgr0ss/pgledger?tab=readme-ov-file#histor...
Re:Double-Entry Ledgers: The Missing Primitive in Modern Sof...
by accrual on Friday June 20, 2025 @02:45PM
(#44330691)
That makes sense and is an elegant solution. This way one can check the balance at any time without recalculating, but we still have an audit log to find discrepancies when the balance is expected to be zero but is not.
This depends on how you implement the ledger. For pgledger, I store the balance in every entry, so to find a historical balance, you just need to find the most recent entry before that time:
https://github.com/pgr0ss/pgledger/blob/df5541dcf25f416a6a24...
I have a mental TODO to add a query function to make this simpler.