Metadata-Version: 2.4
Name: larzledger
Version: 0.1.0
Summary: Exact double-entry accounting in pure Python: balanced debits/credits, normal-side balances, trial balance. Decimal money, zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzledger
Project-URL: Repository, https://github.com/larz-scripter/larzledger
Project-URL: Issues, https://github.com/larz-scripter/larzledger/issues
Keywords: accounting,double-entry,ledger,bookkeeping,finance,fintech,money,trial-balance,decimal,zero-dependency,pure-python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Accounting
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
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](https://github.com/larz-scripter/larzmoney) `Money` objects. No
  dependency, no database — bring your own storage.

## Install

```bash
pip install larzledger
```

## Usage

```python
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

```bash
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](https://github.com/larz-scripter/larzmoney)**,
**[larzpdf](https://github.com/larz-scripter/larzpdf)**), and 30+ more at
[github.com/larz-scripter](https://github.com/larz-scripter).

## License

MIT © larz-scripter
