AccountName
s are strings like assets:cash:petty
.
From a set of these we derive the account hierarchy.
- accountNameComponents :: AccountName -> [String]
- accountNameFromComponents :: [String] -> AccountName
- accountLeafName :: AccountName -> String
- accountNameLevel :: AccountName -> Int
- expandAccountNames :: [AccountName] -> [AccountName]
- topAccountNames :: [AccountName] -> [AccountName]
- parentAccountName :: AccountName -> AccountName
- parentAccountNames :: AccountName -> [AccountName]
- isAccountNamePrefixOf :: AccountName -> AccountName -> Bool
- isSubAccountNameOf :: AccountName -> AccountName -> Bool
- subAccountNamesFrom :: [AccountName] -> AccountName -> [AccountName]
- accountNameTreeFrom :: [AccountName] -> Tree AccountName
- elideAccountName :: Int -> AccountName -> AccountName
- matchpats :: [String] -> String -> Bool
- matchpats_balance :: [String] -> String -> Bool
- match_positive_pats :: [String] -> String -> Bool
- match_negative_pats :: [String] -> String -> Bool
Documentation
expandAccountNames :: [AccountName] -> [AccountName]Source
topAccountNames :: [AccountName] -> [AccountName]Source
subAccountNamesFrom :: [AccountName] -> AccountName -> [AccountName]Source
accountNameTreeFrom :: [AccountName] -> Tree AccountNameSource
We could almost get by with just the AccountName manipulations
above, but we need smarter structures to eg display the account
tree with boring accounts elided. This converts a list of
AccountName to a tree (later we will convert that to a tree of
Account
.)
elideAccountName :: Int -> AccountName -> AccountNameSource
Elide an account name to fit in the specified width. From the ledger 2.6 news:
What Ledger now does is that if an account name is too long, it will start abbreviating the first parts of the account name down to two letters in length. If this results in a string that is still too long, the front will be elided -- not the end. For example: Expenses:Cash ; OK, not too long Ex:Wednesday:Cash ; Expenses was abbreviated to fit Ex:We:Afternoon:Cash ; Expenses and Wednesday abbreviated ; Expenses:Wednesday:Afternoon:Lunch:Snack:Candy:Chocolate:Cash ..:Af:Lu:Sn:Ca:Ch:Cash ; Abbreviated and elided!
matchpats :: [String] -> String -> BoolSource
Check if a set of ledger account/description patterns matches the given account name or entry description. Patterns are case-insensitive regular expression strings; those beginning with - are anti-patterns.
matchpats_balance :: [String] -> String -> BoolSource
Similar to matchpats, but follows the special behaviour of ledger 2.6's balance command: positive patterns which do not contain : match the account leaf name, other patterns match the full account name.
match_positive_pats :: [String] -> String -> BoolSource
Do the positives in these patterns permit a match for this string ?
match_negative_pats :: [String] -> String -> BoolSource
Do the negatives in these patterns prevent a match for this string ?