hledger-lib-1.3: Core data types, parsers and functionality for the hledger accounting tools

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]
- nameTreeToAccount :: AccountName -> FastTree 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]
- lookupAccount :: AccountName -> [Account] -> Maybe Account
- printAccounts :: Account -> IO ()
- showAccounts :: Account -> String
- showAccountsBoringFlag :: Account -> String
- showAccountDebug :: PrintfType t => Account -> t
- tests_Hledger_Data_Account :: Test

# 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.)

nameTreeToAccount :: AccountName -> FastTree AccountName -> Account #

Convert an AccountName tree to an Account tree

tieAccountParents :: Account -> Account #

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

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 ?

sumAccounts :: Account -> Account #

Add subaccount-inclusive balances to an account tree.

clipAccounts :: Int -> Account -> Account #

Remove all subaccounts below a certain depth.

clipAccountsAndAggregate :: Int -> [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).

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!

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

Filter an account tree (to a list).

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

Search an account list by name.

printAccounts :: Account -> IO () #

showAccounts :: Account -> String #

showAccountsBoringFlag :: Account -> String #

showAccountDebug :: PrintfType t => Account -> t #

tests_Hledger_Data_Account :: Test #

# Orphan instances

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