Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- tieAccountParents :: Account -> Account
- parentAccounts :: Account -> [Account]
- accountsLevels :: Account -> [[Account]]
- mapAccounts :: (Account -> Account) -> Account -> Account
- anyAccounts :: (Account -> Bool) -> Account -> Bool
- sumAccounts :: Account -> Account
- clipAccounts :: Int -> Account -> Account
- clipAccountsAndAggregate :: Int -> [Account] -> [Account]
- pruneAccounts :: (Account -> Bool) -> Account -> Maybe Account
- flattenAccounts :: Account -> [Account]
- filterAccounts :: (Account -> Bool) -> Account -> [Account]
- sortAccountTreeByAmount :: NormalSign -> Account -> Account
- accountSetDeclarationOrder :: Journal -> Account -> Account
- sortAccountNamesByDeclaration :: Journal -> Bool -> [AccountName] -> [AccountName]
- sortAccountTreeByDeclaration :: Account -> Account
- accountDeclarationOrderAndName :: Account -> (Int, AccountName)
- lookupAccount :: AccountName -> [Account] -> Maybe Account
- printAccounts :: Account -> IO ()
- showAccounts :: Account -> String
- showAccountsBoringFlag :: Account -> String
- showAccountDebug :: PrintfType t => Account -> t
Documentation
accountsFromPostings :: [Posting] -> [Account] Source #
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 Source #
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.
tieAccountParents :: Account -> Account Source #
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 -> Account Source #
Map a (non-tree-structure-modifying) function over this and sub accounts.
anyAccounts :: (Account -> Bool) -> Account -> Bool Source #
Is the predicate true on any of this account or its subaccounts ?
sumAccounts :: Account -> Account Source #
Add subaccount-inclusive balances to an account tree.
clipAccountsAndAggregate :: Int -> [Account] -> [Account] Source #
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).
pruneAccounts :: (Account -> Bool) -> Account -> Maybe Account Source #
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 tree's structure 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).
sortAccountTreeByAmount :: NormalSign -> Account -> Account Source #
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.
accountSetDeclarationOrder :: Journal -> Account -> Account Source #
Look up an account's declaration order, if any, from the Journal and set it. This is the relative position of its account directive among the other account directives.
sortAccountNamesByDeclaration :: Journal -> Bool -> [AccountName] -> [AccountName] Source #
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).
sortAccountTreeByDeclaration :: Account -> Account Source #
Sort each group of siblings in an account tree by declaration order, then account name. So each group will contain first the declared accounts, in the same order as their account directives were parsed, and then the undeclared accounts, sorted by account name.
lookupAccount :: AccountName -> [Account] -> Maybe Account Source #
Search an account list by name.
printAccounts :: Account -> IO () Source #
showAccounts :: Account -> String Source #
showAccountDebug :: PrintfType t => Account -> t Source #