One Ledger Per Member/Vendor: Refactoring Django Ledger Architecture #331
codefilterPH
started this conversation in
Ideas
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
I recently refactored part of my Django Ledger implementation related to customer/member/vendor transaction handling and ledger lifecycle management.
Previously, the system created a new
LedgerModelfor nearly every transaction type (savings deposits, withdrawals, share capital payments, loan payments, vendor transactions, etc.). While technically functional, it eventually produced multiple fragmented ledgers per member/vendor, which became difficult to manage operationally and felt inconsistent with traditional accounting subledger practices.Previous Structure
After refactoring, each member/vendor now maintains a single reusable canonical ledger that acts as the long-term transactional container:
Refactor Details
The implementation changes included:
create_ledger()to reuse an existing ledger viaget_or_create()ledger_xidconvention such as:Creating a migration/maintenance management command capable of:
Why This Feels More Appropriate
This structure aligns more naturally with real-world accounting and counterparty-based financial systems, particularly for:
Operationally, it also simplifies:
I also came across earlier discussions suggesting that ledgers are often more effective when treated as persistent reusable subledgers per customer/vendor/member, rather than ephemeral containers generated per transaction workflow. That perspective strongly influenced this redesign.
So far, the refactor has made the accounting structure significantly cleaner and easier to reason about, especially in cooperative, lending, and member-centric financial workflows.
Would appreciate hearing how others using Django Ledger are handling customer/member/vendor ledger architecture in coop, lending, banking, ERP, or subscription-style systems.
![Uploading ledger.png…]()
All reactions