larzledger
Exact double-entry accounting in pure Python. Zero dependencies.
A correct ledger: every transaction is balanced debits and credits (rejected if
they don't balance), account balances follow real accounting's normal-side rules,
and money is exact Decimal — never a float, so the books never drift by a
cent.
from larzledger import Ledger
led = Ledger(currency="$")
led.account("cash", "asset")
led.account("revenue", "income")
led.account("rent", "expense")
led.transaction("Sale").debit("cash", "250.00").credit("revenue", "250.00").commit()
led.post("Rent", debit=("rent", "1200.00"), credit=("cash", "1200.00"))
led.balance("cash") # Decimal('-950.00')
led.trial_balance() # debits == credits, guaranteed
led.accounting_equation_holds() # True
Why
- Actually double-entry. Debits must equal credits or the transaction is refused — the core invariant that keeps books trustworthy.
- Exact money.
Decimalthroughout; floats are rejected on purpose. Balances, trial balance, and the accounting equation always reconcile to the cent. - Real accounting semantics. Asset/expense accounts are debit-normal; liability/equity/income are credit-normal — balances read positive on the right side.
- Money-native, zero-dep. Amounts accept strings, ints,
Decimal, or larzmoneyMoneyobjects. No dependency, no database — bring your own storage.
Install
pip install larzledger
Usage
led.account(name, "asset"|"liability"|"equity"|"income"|"expense")
# transaction builder (any number of legs; must balance)
led.transaction("desc").debit("a", "10").credit("b", "10").commit()
# convenience for simple entries (amounts can be dicts of account->amount)
led.post("Split", debit={"rent": "50", "cash": "50"}, credit={"revenue": "100"})
# reporting
led.balance("cash")
led.trial_balance() # [(name, type, debit, credit), ...]
led.total("asset") # sum of an account type
led.statement("cash") # every posting touching an account
led.accounting_equation_holds() # assets == liabilities + equity + income - expense
led.format("1234.5") # "$1,234.50"
Tests
python -m unittest discover -s tests -v # 17 tests, zero deps
The Larz stack
Part of a family of pure-Python, zero-dependency libraries — money-native (larzmoney, larzpdf), and 30+ more at github.com/larz-scripter.
License
MIT © larz-scripter
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzledger-0.1.0.tar.gz.
File metadata
- Download URL: larzledger-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5791da3944aadeabb6ec92d378d630a218d108d666586833111dd0f1d279f2fc
|
|
| MD5 |
7912a38e2d5a650c7e518c3a4a993d53
|
|
| BLAKE2b-256 |
49d358a36bbf8c163d6d4c18952f63aeaab0ef2b1ba2ac93c1e46f9841a617fc
|
File details
Details for the file larzledger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzledger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eba7cdc0bb33492ef8800e5d4244ab1b12235634066cb370642a5eae6d7848ad
|
|
| MD5 |
4d55c44246b8da0c25cdfa9ac17bcddd
|
|
| BLAKE2b-256 |
7e90f0812e4e40893d1e574136bab1a6943fab1ea5ed51b7578f1da21e60dc8a
|