Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hledger.Data.Account
Contents
Description
An Account
has a name, a list of subaccounts, an optional parent
account, and subaccounting-excluding and -including balances.
Synopsis
- nullacct :: Account BalanceData
- accountFromBalances :: AccountName -> PeriodData a -> Account a
- accountFromPostings :: (Posting -> Maybe Day) -> [Posting] -> Account BalanceData
- accountsFromPostings :: (Posting -> Maybe Day) -> [Posting] -> [Account BalanceData]
- accountTree :: Monoid a => AccountName -> [AccountName] -> Account a
- accountTreeFromBalanceAndNames :: AccountName -> PeriodData a -> [AccountName] -> Account a
- showAccounts :: Show a => Account a -> String
- showAccountsBoringFlag :: Account a -> String
- printAccounts :: Show a => Account a -> IO ()
- lookupAccount :: AccountName -> [Account a] -> Maybe (Account a)
- parentAccounts :: Account a -> [Account a]
- accountsLevels :: Account a -> [[Account a]]
- mapAccounts :: (Account a -> Account a) -> Account a -> Account a
- mapPeriodData :: (PeriodData a -> PeriodData a) -> Account a -> Account a
- anyAccounts :: (Account a -> Bool) -> Account a -> Bool
- filterAccounts :: (Account a -> Bool) -> Account a -> [Account a]
- sumAccounts :: Account BalanceData -> Account BalanceData
- clipAccounts :: Int -> Account a -> Account a
- clipAccountsAndAggregate :: Monoid a => DepthSpec -> [Account a] -> [Account a]
- pruneAccounts :: (Account a -> Bool) -> Account a -> Maybe (Account a)
- flattenAccounts :: Account a -> [Account a]
- mergeAccounts :: Account a -> Account b -> Account (These a b)
- accountSetDeclarationInfo :: Journal -> Account a -> Account a
- sortAccountNamesByDeclaration :: Journal -> Bool -> [AccountName] -> [AccountName]
- sortAccountTreeByDeclaration :: Account a -> Account a
- sortAccountTreeOn :: Ord b => (Account a -> b) -> Account a -> Account a
- tests_Account :: TestTree
Documentation
accountFromBalances :: AccountName -> PeriodData a -> Account a Source #
Construct an 'Account" from an account name and balances. Other fields are left blank.
accountFromPostings :: (Posting -> Maybe Day) -> [Posting] -> Account BalanceData Source #
Derive 1. an account tree and 2. each account's total exclusive and inclusive changes associated with dates from a list of postings and a function for associating a date to each posting (usually representing the start dates of report subperiods). This is the core of the balance command (and of *ledger). The accounts are returned as a tree.
accountsFromPostings :: (Posting -> Maybe Day) -> [Posting] -> [Account BalanceData] Source #
Derive 1. an account tree and 2. each account's total exclusive and inclusive changes associated with dates from a list of postings and a function for associating a date to each posting (usually representing the start dates of report subperiods). 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 :: Monoid a => AccountName -> [AccountName] -> Account a Source #
Convert a list of account names to a tree of Account objects, with just the account names filled in and an empty balance. A single root account with the given name is added.
accountTreeFromBalanceAndNames :: AccountName -> PeriodData a -> [AccountName] -> Account a Source #
Convert a list of account names to a tree of Account objects, with just the account names filled in. Each account is given the same supplied balance. A single root account with the given name is added.
showAccountsBoringFlag :: Account a -> String Source #
lookupAccount :: AccountName -> [Account a] -> Maybe (Account a) Source #
Search an account list by name.
parentAccounts :: Account a -> [Account a] Source #
Get this account's parent accounts, from the nearest up to the root.
accountsLevels :: Account a -> [[Account a]] Source #
List the accounts at each level of the account tree.
mapAccounts :: (Account a -> Account a) -> Account a -> Account a Source #
Map a (non-tree-structure-modifying) function over this and sub accounts.
mapPeriodData :: (PeriodData a -> PeriodData a) -> Account a -> Account a Source #
Apply a function to all PeriodData
within this and sub accounts.
anyAccounts :: (Account a -> Bool) -> Account a -> Bool Source #
Is the predicate true on any of this account or its subaccounts ?
filterAccounts :: (Account a -> Bool) -> Account a -> [Account a] Source #
Filter an account tree (to a list).
sumAccounts :: Account BalanceData -> Account BalanceData Source #
Recalculate all the subaccount-inclusive balances in this tree.
clipAccountsAndAggregate :: Monoid a => DepthSpec -> [Account a] -> [Account a] 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). If the depth is Nothing, return the original accounts
pruneAccounts :: (Account a -> Bool) -> Account a -> Maybe (Account a) Source #
Remove all leaf accounts and subtrees matching a predicate.
flattenAccounts :: Account a -> [Account a] 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!
mergeAccounts :: Account a -> Account b -> Account (These a b) Source #
Merge two account trees and their subaccounts.
This assumes that the top-level Account
s have the same name.
accountSetDeclarationInfo :: Journal -> Account a -> Account a Source #
Add extra info for this account derived from the Journal's account directives, if any (comment, tags, declaration order..).
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 a -> Account a 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.
sortAccountTreeOn :: Ord b => (Account a -> b) -> Account a -> Account a Source #
Sort each group of siblings in an account tree by projecting through a provided function.