piecash.core.account module

class piecash.core.account.AccountType(value)[source]

Bases: enum.Enum

An enumeration.

class piecash.core.account.Account(name, type, commodity, parent=None, description='', commodity_scu=None, hidden=0, placeholder=0, code='', book=None, children=None)[source]

Bases: piecash._declbase.DeclarativeBaseGuid

A GnuCash Account which is specified by its name, type and commodity.

type

type of the Account

Type

str

sign

1 for accounts with positive balances, -1 for accounts with negative balances

Type

int

code

code of the Account

Type

str

commodity

the commodity of the account

Type

piecash.core.commodity.Commodity

commodity_scu

smallest currency unit for the account

Type

int

non_std_scu

1 if the scu of the account is NOT the same as the commodity

Type

int

description

description of the account

Type

str

name

name of the account

Type

str

fullname

full name of the account (including name of parent accounts separated by ‘:’)

Type

str

placeholder

1 if the account is a placeholder (should not be involved in transactions)

Type

int

hidden

1 if the account is hidden

Type

int

is_template

True if the account is a template account (ie commodity=template/template)

Type

bool

parent

the parent account of the account (None for the root account of a book)

Type

Account

children

the list of the children accounts

Type

list of Account

splits

the list of the splits linked to the account

Type

list of piecash.core.transaction.Split

lots

the list of lots to which the account is linked

Type

list of piecash.business.Lot

book

the book if the account is the root account (else None)

Type

piecash.core.book.Book

budget_amounts

list of budget amounts of the account

Type

list of piecash.budget.BudgetAmount

scheduled_transaction

scheduled transaction linked to the account

Type

piecash.core.transaction.ScheduledTransaction

object_to_validate(change)[source]

yield the objects to validate when the object is modified (change=”new” “deleted” or “dirty”).

For instance, if the object is a Split, if it changes, we want to revalidate not the split but its transaction and its lot (if any). split.object_to_validate should yeild both split.transaction and split.lot

validate()[source]

This must be reimplemented for object requiring validation

observe_commodity(key, value)[source]

Ensure update of commodity_scu when commodity is changed

get_balance(recurse=True, commodity=None, natural_sign=True, at_date=None)[source]

Returns the balance of the account (including its children accounts if recurse=True) expressed in account’s commodity/currency. If this is a stock/fund account, it will return the number of shares held. If this is a currency account, it will be in account’s currency. In case of recursion, the commodity of children accounts will be transformed to the commodity of the father account using the latest price (if no price is available to convert , it is considered as 0). If natural_sign is True, the sign of the balance is reverted for the account with type {‘LIABILITY’, ‘PAYABLE’, ‘CREDIT’, ‘INCOME’, ‘EQUITY’}

recurse

True if the balance should include children accounts (default to True)

Type

bool, optional

commodity

the currency into which to get the balance (default to None, i.e. the currency of the account)

Type

piecash.core.commodity.Commodity

natural_sign

True if the balance sign is reversed for accounts of type {‘LIABILITY’, ‘PAYABLE’, ‘CREDIT’, ‘INCOME’, ‘EQUITY’} (default to True)

Type

bool, optional

at_date

the sum() balance of the account at a given date based on transaction post date

Type

datetime.datetime

Returns

the balance of the account