hledger-lib-0.21.3: Core data types, parsers and utilities for the hledger accounting tool.

Safe HaskellNone

Hledger.Data.Account

Description

An Account has a name, a list of subaccounts, an optional parent account, and subaccounting-excluding and -including balances.

Synopsis

Documentation

accountsFromPostings :: [Posting] -> [Account]Source

Derive an account tree with balances from a set of postings. (*ledger's core feature.) The accounts are returned in a list, but retain their tree structure; the first one is the root of the tree.

nameTreeToAccount :: AccountName -> FastTree AccountName -> AccountSource

Convert an AccountName tree to an Account tree

tieAccountParents :: Account -> AccountSource

Tie the knot so all subaccounts' parents are set correctly.

parentAccounts :: Account -> [Account]Source

Get this account's parent accounts, from the nearest up to the root.

accountsLevels :: Account -> [[Account]]Source

List the accounts at each level of the account tree.

mapAccounts :: (Account -> Account) -> Account -> AccountSource

Map a (non-tree-structure-modifying) function over this and sub accounts.

anyAccounts :: (Account -> Bool) -> Account -> BoolSource

Is the predicate true on any of this account or its subaccounts ?

sumAccounts :: Account -> AccountSource

Add subaccount-inclusive balances to an account tree. -- , also noting -- whether it has an interesting balance or interesting subs to help -- with eliding later.

clipAccounts :: Int -> Account -> AccountSource

Remove all subaccounts below a certain depth.

pruneAccounts :: (Account -> Bool) -> Account -> Maybe AccountSource

Remove all leaf accounts and subtrees matching a predicate.

flattenAccounts :: Account -> [Account]Source

Flatten an account tree into a list, which is sometimes convenient. Note since accounts link to their parents/subs, the account tree remains intact and can still be used. It's a tree/list!

filterAccounts :: (Account -> Bool) -> Account -> [Account]Source

Filter an account tree (to a list).

lookupAccount :: AccountName -> [Account] -> Maybe AccountSource

Search an account list by name.