chart_of_accounts
Chart of accounts: organizes all accounts by category.
Classes:
-
ChartOfAccounts–A chart of accounts organizes all accounts by category.
-
ChartOfAccountsBuilder–Builder for creating a ChartOfAccounts instance.
-
IncomeSummaryAccount–Represent the income summary account.
-
RetainedEarningsAccount–Represent the retained earnings account.
ChartOfAccounts
dataclass
ChartOfAccounts(
assets: list[TAccount] = list(),
equities: list[TAccount] = list(),
liabilities: list[TAccount] = list(),
income: list[TAccount] = list(),
expenses: list[TAccount] = list(),
income_summary_account: IncomeSummaryAccount = IncomeSummaryAccount(),
retained_earnings_account: RetainedEarningsAccount = RetainedEarningsAccount(),
)
A chart of accounts organizes all accounts by category.
::
+----------------------------------------------+
| Chart of Accounts |
+----------------------------------------------+
| Assets | What the entity owns |
| Liabilities | What the entity owes |
| Equity | Owner's residual interest |
| Income | Revenue earned (temporary) |
| Expenses | Costs incurred (temporary) |
+----------------------------------------------+
| Accounting equation: |
| Assets = Liabilities + Equity |
| |
| At period end, Income and Expenses close to |
| Retained Earnings (Equity) via Income Summary |
+----------------------------------------------+
Methods:
-
all_accounts–Yield every account including nested sub-accounts (depth-first).
all_accounts
all_accounts() -> Generator[TAccount, None, None]
Yield every account including nested sub-accounts (depth-first).
Unlike __iter__, this expands composite accounts so that both the
composite and all of its descendants are yielded. Useful for lookups
by name when the target may be a sub-account.
ChartOfAccountsBuilder
ChartOfAccountsBuilder()
Builder for creating a ChartOfAccounts instance.
Usage::
coa = (
ChartOfAccountsBuilder()
.add_asset_account(cash)
.add_liability_account(deposits)
.add_equity_account(equity)
.add_income_account(interest_income)
.add_expense_account(interest_expense)
.build()
)
Methods:
-
add_asset_account–Add an asset account to the builder.
-
add_equity_account–Add an equity account to the builder.
-
add_expense_account–Add an expense account to the builder.
-
add_income_account–Add an income account to the builder.
-
add_liability_account–Add a liability account to the builder.
-
build–Build and return a ChartOfAccounts instance.
add_asset_account
add_asset_account(
account: TAccount,
) -> ChartOfAccountsBuilder
Add an asset account to the builder.
add_equity_account
add_equity_account(
account: TAccount,
) -> ChartOfAccountsBuilder
Add an equity account to the builder.
add_expense_account
add_expense_account(
account: TAccount,
) -> ChartOfAccountsBuilder
Add an expense account to the builder.
add_income_account
add_income_account(
account: TAccount,
) -> ChartOfAccountsBuilder
Add an income account to the builder.
add_liability_account
add_liability_account(
account: TAccount,
) -> ChartOfAccountsBuilder
Add a liability account to the builder.
IncomeSummaryAccount
IncomeSummaryAccount()
Bases: TAccount
Represent the income summary account.
A temporary account used during period-end closing. All income and expense account balances are transferred here, and the net result is then closed to Retained Earnings.
Methods:
-
balance–Return the net balance of this account.
-
credit–Add credit amount to account.
-
debit–Add debit amount to account.
-
has_contra_account–Check if this account has any contra accounts attached.
-
posting_accounts–Yield all accounts that can directly receive debit/credit postings.
Attributes:
-
credit_value(float) –Return the credit value of the account.
-
debit_value(float) –Return the debit value of the account.
-
parent(TAccount | None) –Get the parent account.
-
sub_accounts(Generator[TAccount, None, None]) –Yield direct child accounts. Empty for simple accounts.
credit_value
property
writable
credit_value: float
Return the credit value of the account.
debit_value
property
writable
debit_value: float
Return the debit value of the account.
sub_accounts
property
sub_accounts: Generator[TAccount, None, None]
Yield direct child accounts. Empty for simple accounts.
balance
balance() -> float
Return the net balance of this account.
Debit-normal accounts: balance = debits - credits. Credit-normal accounts: balance = credits - debits.
credit
credit(amount: float) -> None
Add credit amount to account.
debit
debit(amount: float) -> None
Add debit amount to account.
has_contra_account
has_contra_account() -> bool
Check if this account has any contra accounts attached.
posting_accounts
posting_accounts() -> Generator[TAccount, None, None]
Yield all accounts that can directly receive debit/credit postings.
For a simple account, yields itself. For a composite account, recursively yields the lowest-level accounts in the hierarchy that are not themselves composites with children.
The ledger uses this when building closing entries to ensure postings go to accounts that accept direct value changes.
RetainedEarningsAccount
RetainedEarningsAccount()
Bases: TAccount
Represent the retained earnings account.
Accumulated net income that has not been distributed. During period-end closing, the Income Summary balance is transferred here.
Methods:
-
balance–Return the net balance of this account.
-
credit–Add credit amount to account.
-
debit–Add debit amount to account.
-
has_contra_account–Check if this account has any contra accounts attached.
-
posting_accounts–Yield all accounts that can directly receive debit/credit postings.
Attributes:
-
credit_value(float) –Return the credit value of the account.
-
debit_value(float) –Return the debit value of the account.
-
parent(TAccount | None) –Get the parent account.
-
sub_accounts(Generator[TAccount, None, None]) –Yield direct child accounts. Empty for simple accounts.
credit_value
property
writable
credit_value: float
Return the credit value of the account.
debit_value
property
writable
debit_value: float
Return the debit value of the account.
sub_accounts
property
sub_accounts: Generator[TAccount, None, None]
Yield direct child accounts. Empty for simple accounts.
balance
balance() -> float
Return the net balance of this account.
Debit-normal accounts: balance = debits - credits. Credit-normal accounts: balance = credits - debits.
credit
credit(amount: float) -> None
Add credit amount to account.
debit
debit(amount: float) -> None
Add debit amount to account.
has_contra_account
has_contra_account() -> bool
Check if this account has any contra accounts attached.
posting_accounts
posting_accounts() -> Generator[TAccount, None, None]
Yield all accounts that can directly receive debit/credit postings.
For a simple account, yields itself. For a composite account, recursively yields the lowest-level accounts in the hierarchy that are not themselves composites with children.
The ledger uses this when building closing entries to ensure postings go to accounts that accept direct value changes.