accounting module

abcFinance is an implementation of an double entry book keeping system

Initialize the accounting system with, the name of the residual_account:

accounts = AccountingSystem('equity')

Create stock and flow account:

accounts.make_stock_account([‘cash’, ‘claims’]) accounts.make_flow_account([‘expenditure’])

In order to book give a list of credit and debit tuples. Each tuple should be an account and a value:

accounts.book(
    debit=[('cash', 50), ('claims', 50)],
    credit=[('equity', 100)])

get balance gives you the balance of an account:

assert accounts[‘cash’].get_balance() == (s.DEBIT, 50)

Balance sheet

accounts.book(debit=[(‘expenditure’, 20)], credit=[(‘cash’, 20)])

assert accounts.get_total_assets() == 80, accounts.get_total_assets()

accounts.print_profit_and_loss() print(‘–’) accounts.make_end_of_period()

accounts.print_profit_and_loss()

accounts.print_balance_sheet()

assert accounts[‘equity’].get_balance() == (s.CREDIT, 80)

class accounting.Account[source]

Bases: object

get_balance()[source]
print_balance()[source]
class accounting.AccountingSystem(residual_account_name='equity')[source]

Bases: object

The main class to be initialized

book(debit, credit, text='')[source]

Book a transaction.

Arguments:

debit, list of tuples (‘account’, amount)

credit, list of tuples (‘account’, amount)

text, for booking history

Example:

accounts.book(debit=[('inventory',20)], credit=[('cash',20)], text="Purchase of equipment")
get_total_assets()[source]

Return total assets.

make_end_of_period()[source]

Close flow accounts and credit/debit residual (equity) account

make_flow_account(names)[source]

Create flow accounts.

Args:
names, list of names for the accounts
make_stock_account(names)[source]

Create stock accounts.

Args:
names, list of names for the accounts
print_balance_sheet()[source]

Print a balance sheets

print_profit_and_loss()[source]

Print profit and loss statement

class accounting.s[source]

Bases: enum.Enum

An enumeration.

CREDIT = 1
DEBIT = 0