piecash.core.account module — Python interface to GnuCash documents 0.15.0 documentation

# piecash.core.account module

class `piecash.core.account.` `AccountType`

  Bases: `enum.Enum`

  An enumeration.

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

  Bases: `piecash._declbase.DeclarativeBaseGuid`

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

  `type`

    str – type of the Account

  `sign`

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

  `code`

    str – code of the Account

  `commodity`

    `piecash.core.commodity.Commodity` – the commodity of the account

  `commodity_scu`

    int – smallest currency unit for the account

  `non_std_scu`

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

  `description`

    str – description of the account

  `name`

    str – name of the account

  `fullname`

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

  `placeholder`

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

  `hidden`

    int – 1 if the account is hidden

  `is_template`

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

  `parent`

    `Account` – the parent account of the account (None for the root account of a book)

  `children`

    list of `Account` – the list of the children accounts

  `splits`

    list of `piecash.core.transaction.Split` – the list of the splits linked to the account

  `lots`

    list of `piecash.business.Lot` – the list of lots to which the account is linked

  `book`

    `piecash.core.book.Book` – the book if the account is the root account (else None)

  `budget_amounts`

    list of `piecash.budget.BudgetAmount` – list of budget amounts of the account

  `scheduled_transaction`

    `piecash.core.transaction.ScheduledTransaction` – scheduled transaction linked to the account

  `object_to_validate`(change)

    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`()

    This must be reimplemented for object requiring validation

  `observe_commodity`(key, value)

    Ensure update of commodity_scu when commodity is changed

  `get_balance`(recurse=True, commodity=None)

    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)

    `recurse`

      bool, optional – True if the balance should include children accounts (default to True)

    `commodity`

      `piecash.core.commodity.Commodity` – the currency into which to get the balance (default to None, i.e. the currency of the account)

    Returns: | the balance of the account