The pynomina Ledger Book model consists of four main classes:
These are the necessary classes which work together to represent a comprehensive financial ledger records.
The Book class represents the main container for all financial data. It includes:
The Account class represents a hierarchy of individual financial accounts within the ledger. It includes:
The Transaction class represents individual financial transactions. It includes:
The Split class represents the individual components of a transaction, showing how money moves between accounts. It includes:
Here's an example of how the ledger model is used in practice:
owner: Wolfgang Fahl
url: https://github.com/WolfgangFahl/pynomina/blob/main/nomina_examples/expenses2024.yaml
since: 2024-10-06
accounts:
Expenses:
account_id: Expenses
name: Expenses
account_type: EXPENSE
description: 'General Expenses'
currency: EUR
Expenses:Food:
account_id: Expenses:Food
name: Dining
account_type: EXPENSE
description: 'Expenses for Food'
currency: EUR
parent_account_id: Expenses
Cash in wallet:
account_id: Wallet
name: Cash in Wallet
account_type: EXPENSE
description: ''
currency: EUR
transactions:
Bakery2024-10-06_0900_1:
isodate: '2024-10-06'
description: Bread
splits:
- amount: -3.50
account_id: Cash in Wallet
- amount: 3.50
account_id: Expenses:Dining
memo: Fresh sourdough bread
Bakery2024-10-06_0900_2:
isodate: '2024-10-06'
description: Buns for Breakfast
splits:
- amount: -2.40
account_id: Cash in Wallet
- amount: 2.40
account_id: Expenses:Dining
memo: 4 whole grain buns
The ledger model is implemented in Python, utilizing dataclasses and type hinting for clear and maintainable code. The `@lod_storable` decorator is used to enable easy serialization and deserialization of the data in YAML and/or JSON and other formats. The core idea is that the records should be readily available an tabular "list of dicts (lod)" format.