Skip to main content

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 Decimalnever 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. Decimal throughout; 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 larzmoney Money objects. 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

larzledger-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzledger-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

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

Hashes for larzledger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5791da3944aadeabb6ec92d378d630a218d108d666586833111dd0f1d279f2fc
MD5 7912a38e2d5a650c7e518c3a4a993d53
BLAKE2b-256 49d358a36bbf8c163d6d4c18952f63aeaab0ef2b1ba2ac93c1e46f9841a617fc

See more details on using hashes here.

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

Hashes for larzledger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eba7cdc0bb33492ef8800e5d4244ab1b12235634066cb370642a5eae6d7848ad
MD5 4d55c44246b8da0c25cdfa9ac17bcddd
BLAKE2b-256 7e90f0812e4e40893d1e574136bab1a6943fab1ea5ed51b7578f1da21e60dc8a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page