Hledger.Data.Account

hledger-lib-1.41: A library providing the core functionality of hledger

Safe Haskell | None
Language | Haskell2010

Hledger.Data.Account

Contents

- Orphan instances

Description

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

Synopsis

- nullacct :: Account
- accountsFromPostings :: [Posting] -> [Account]
- accountTree :: AccountName -> [AccountName] -> Account
- showAccounts :: Account -> String
- showAccountsBoringFlag :: Account -> String
- printAccounts :: Account -> IO ()
- lookupAccount :: AccountName -> [Account] -> Maybe Account
- parentAccounts :: Account -> [Account]
- accountsLevels :: Account -> [[Account]]
- mapAccounts :: (Account -> Account) -> Account -> Account
- anyAccounts :: (Account -> Bool) -> Account -> Bool
- filterAccounts :: (Account -> Bool) -> Account -> [Account]
- sumAccounts :: Account -> Account
- clipAccounts :: Int -> Account -> Account
- clipAccountsAndAggregate :: DepthSpec -> [Account] -> [Account]
- pruneAccounts :: (Account -> Bool) -> Account -> Maybe Account
- flattenAccounts :: Account -> [Account]
- accountSetDeclarationInfo :: Journal -> Account -> Account
- sortAccountNamesByDeclaration :: Journal -> Bool -> [AccountName] -> [AccountName]
- sortAccountTreeByAmount :: NormalSign -> Account -> Account

# Documentation

nullacct :: Account #

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

Derive 1. an account tree and 2. each account's total exclusive and inclusive changes from a list of postings. This is the core of the balance command (and of *ledger). The accounts are returned as a list in flattened tree order, and also reference each other as a tree. (The first account is the root of the tree.)

accountTree :: AccountName -> [AccountName] -> Account #

Convert a list of account names to a tree of Account objects, with just the account names filled in. A single root account with the given name is added.

showAccounts :: Account -> String #

showAccountsBoringFlag :: Account -> String #

printAccounts :: Account -> IO () #

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

Search an account list by name.

parentAccounts :: Account -> [Account] #

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

accountsLevels :: Account -> [[Account]] #

List the accounts at each level of the account tree.

mapAccounts :: (Account -> Account) -> Account -> Account #

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

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

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

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

Filter an account tree (to a list).

sumAccounts :: Account -> Account #

Add subaccount-inclusive balances to an account tree.

clipAccounts :: Int -> Account -> Account #

Remove all subaccounts below a certain depth.

clipAccountsAndAggregate :: DepthSpec -> [Account] -> [Account] #

Remove subaccounts below the specified depth, aggregating their balance at the depth limit (accounts at the depth limit will have any sub-balances merged into their exclusive balance). If the depth is Nothing, return the original accounts

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

Remove all leaf accounts and subtrees matching a predicate.

flattenAccounts :: Account -> [Account] #

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

accountSetDeclarationInfo :: Journal -> Account -> Account #

Add extra info for this account derived from the Journal's account directives, if any (comment, tags, declaration order..).

sortAccountNamesByDeclaration :: Journal -> Bool -> [AccountName] -> [AccountName] #

Sort account names by the order in which they were declared in the journal, at each level of the account tree (ie within each group of siblings). Undeclared accounts are sorted last and alphabetically. This is hledger's default sort for reports organised by account. The account list is converted to a tree temporarily, adding any missing parents; these can be kept (suitable for a tree-mode report) or removed (suitable for a flat-mode report).

sortAccountTreeByAmount :: NormalSign -> Account -> Account #

Sort each group of siblings in an account tree by inclusive amount, so that the accounts with largest normal balances are listed first. The provided normal balance sign determines whether normal balances are negative or positive, affecting the sort order. Ie, if balances are normally negative, then the most negative balances sort first, and vice versa.

# Orphan instances

Show Account # |
Instance details Methods showsPrec :: Int -> Account -> ShowS # show :: Account -> String # showList :: [Account] -> ShowS #
Eq Account # |
Instance details Methods (==) :: Account -> Account -> Bool # (/=) :: Account -> Account -> Bool #