Skip to content
Hugh Jeremy edited this page Mar 20, 2019 · 4 revisions

Documentation > Tree

Trees present the entire chart of Accounts of an Entity in a single hierarchical object.

Each Account is nested under its parent, and in turn lists all its children, all providing Balances and Recursive Balances.

Trees are trimmed for permissions. If the user requesting the tree only has read access to a subset of Accounts, they will only receive a tree containing those accounts, with placeholder objects filling the place of Accounts they are not permitted to read.

Each Account in the Tree is presented as a Tree Node.

Properties

.session - Session

The Session used to initialise this Tree


.entity - Entity

The Entity to which the Accounts described by this Tree belong.


.balance_time - datetime

The time at which the balances in this Tree hold.

Example: datetime.datetime(2019, 1, 18, 21, 4, 43, 557821)


.generated_time - datetime

The time at which this Tree was generated by the Amatino API. Transactions and other data created after this time are excluded.

Example: datetime.datetime(2019, 1, 18, 21, 4, 43, 557821)


.denomination - Denomination

The denominating unit of this Tree, either a GlobalUnit or a CustomUnit. Accessing the .denomination property will cause a synchronous call to the API. Successive accesses will return cached data.


.global_unit_id - Optional[int]

The integer identifier of the GlobalUnit that denominates this Tree, or None if this Tree is denominated in a CustomUnit.

Example: 5


.custom_unit_id - Optional[int]

The integer identifier of the CustomUnit that denominates this Tree, or None if this Tree is denominated in a GlobalUnit.

Example: None


.tree - List[TreeNode]

A list of TreeNode objects, each representing a top-level Account node in the hierarchy of Accounts this Tree describes. If the Entity in question has no accounts, this list will be empty.

Example: See TreeNode


.has_accounts - bool

True if this Tree has at least one TreeNode in the .tree property.

Example: True


.assets - List[TreeNode]

A list of TreeNode objects, each representing a top-level asset Account node in the hierarchy of Accounts this Tree describes. If the Entity in question has no asset accounts, this list will be empty.

Example: See TreeNode


.has_assets - bool

True if this Tree has at least one asset TreeNode in the .asset property.

Example: True


.liabilities - List[TreeNode]

A list of TreeNode objects, each representing a top-level liability Account node in the hierarchy of Accounts this Tree describes. If the Entity in question has no liability accounts, this list will be empty.

Example: See TreeNode


.has_liabilities - bool

True if this Tree has at least one liability TreeNode in the .liability property.

Example: False


.equities - List[TreeNode]

A list of TreeNode objects, each representing a top-level equity Account node in the hierarchy of Accounts this Tree describes. If the Entity in question has no equity accounts, this list will be empty.

Example: See TreeNode


.has_equities - bool

True if this Tree has at least one equity TreeNode in the .equity property.

Example: False


.expenses - List[TreeNode]

A list of TreeNode objects, each representing a top-level expense Account node in the hierarchy of Accounts this Tree describes. If the Entity in question has no expense accounts, this list will be empty.

Example: See TreeNode


.has_expenses - bool

True if this Tree has at least one equity TreeNode in the .expenses property.

Example: False


.income - List[TreeNode]

A list of TreeNode objects, each representing a top-level income Account node in the hierarchy of Accounts this Tree describes. If the Entity in question has no income accounts, this list will be empty.

Example: See TreeNode


.has_income - bool

True if this Tree has at least one income TreeNode in the .income property.

Example: True


.total_assets - Decimal

The sum of the recursive balances of all top-level asset accounts in this Tree.


.total_expenses - Decimal

The sum of the recursive balances of all top-level expense accounts in this Tree.


.total_liabilities - Decimal

The sum of the recursive balances of all top-level liability accounts in this Tree.


.total_income - Decimal

The sum of the recursive balances of all top-level income accounts in this Tree.


.total_equity - Decimal

The sum of the recursive balances of all top-level equity accounts in this Tree.


Methods

.nodes_of_type() -> List[TreeNode]

Return the top level Tree Nodes in this Tree having the supplied Amatino Type.

Parameters

  1. am_type: AMType

classmethod .retrieve() -> Tree

Return a new Tree instance.

Parameters

  1. entity - Entity
  2. balance_time - datetime
  3. denomination - Denomination

Example

tree = Tree.retrieve(
  entity=mega_corp,
  balance_time=datetime.utcnow()
  denomination=USD
)

Clone this wiki locally