hledger-lib-1.19.1: A reusable library providing the core functionality of hledger

Safe Haskell | None
Language | Haskell2010

Hledger.Data.AccountName

Description

`AccountName`s are strings like `assets:cash:petty`, with multiple components separated by `:`. From a set of these we derive the account hierarchy.

Synopsis

- accountLeafName :: AccountName -> Text
- accountNameComponents :: AccountName -> [Text]
- accountNameDrop :: Int -> AccountName -> AccountName
- accountNameFromComponents :: [Text] -> AccountName
- accountNameLevel :: AccountName -> Int
- accountNameToAccountOnlyRegex :: AccountName -> Regexp
- accountNameToAccountOnlyRegexCI :: AccountName -> Regexp
- accountNameToAccountRegex :: AccountName -> Regexp
- accountNameToAccountRegexCI :: AccountName -> Regexp
- accountNameTreeFrom :: [AccountName] -> Tree AccountName
- accountSummarisedName :: AccountName -> Text
- acctsep :: Text
- acctsepchar :: Char
- clipAccountName :: Maybe Int -> AccountName -> AccountName
- clipOrEllipsifyAccountName :: Maybe Int -> AccountName -> AccountName
- elideAccountName :: Int -> AccountName -> AccountName
- escapeName :: AccountName -> String
- expandAccountName :: AccountName -> [AccountName]
- expandAccountNames :: [AccountName] -> [AccountName]
- isAccountNamePrefixOf :: AccountName -> AccountName -> Bool
- isSubAccountNameOf :: AccountName -> AccountName -> Bool
- parentAccountName :: AccountName -> AccountName
- parentAccountNames :: AccountName -> [AccountName]
- subAccountNamesFrom :: [AccountName] -> AccountName -> [AccountName]
- topAccountNames :: [AccountName] -> [AccountName]
- unbudgetedAccountName :: Text
- tests_AccountName :: TestTree

# Documentation

accountLeafName :: AccountName -> Text Source #

accountNameComponents :: AccountName -> [Text] Source #

accountNameDrop :: Int -> AccountName -> AccountName Source #

Remove some number of account name components from the front of the account name. If the special "unbudgeted" top-level account is present, it is preserved and dropping affects the rest of the account name.

accountNameFromComponents :: [Text] -> AccountName Source #

accountNameLevel :: AccountName -> Int Source #

accountNameToAccountOnlyRegex :: AccountName -> Regexp Source #

Convert an account name to a regular expression matching it but not its subaccounts.

accountNameToAccountOnlyRegexCI :: AccountName -> Regexp Source #

Convert an account name to a regular expression matching it but not its subaccounts, case insensitively.

accountNameToAccountRegex :: AccountName -> Regexp Source #

Convert an account name to a regular expression matching it and its subaccounts.

accountNameToAccountRegexCI :: AccountName -> Regexp Source #

Convert an account name to a regular expression matching it and its subaccounts, case insensitively.

accountNameTreeFrom :: [AccountName] -> Tree AccountName Source #

Convert a list of account names to a tree.

accountSummarisedName :: AccountName -> Text Source #

Truncate all account name components but the last to two characters.

acctsep :: Text Source #

acctsepchar :: Char Source #

clipAccountName :: Maybe Int -> AccountName -> AccountName Source #

Keep only the first n components of an account name, where n is a positive integer. If n is Just 0, returns the empty string, if n is Nothing, return the full name.

clipOrEllipsifyAccountName :: Maybe Int -> AccountName -> AccountName Source #

Keep only the first n components of an account name, where n is a positive integer. If n is Just 0, returns "...", if n is Nothing, return the full name.

elideAccountName :: Int -> AccountName -> AccountName Source #

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!

escapeName :: AccountName -> String Source #

Escape an AccountName for use within a regular expression. >>> putStr $ escapeName "First?!*? %)*!`#" First?!#$*?$(*) !`^

expandAccountName :: AccountName -> [AccountName] Source #

"a:b:c" -> ["a","a:b","a:b:c"]

expandAccountNames :: [AccountName] -> [AccountName] Source #

Sorted unique account names implied by these account names, ie these plus all their parent accounts up to the root. Eg: ["a:b:c","d:e"] -> ["a","a:b","a:b:c","d","d:e"]

isAccountNamePrefixOf :: AccountName -> AccountName -> Bool Source #

Is the first account a parent or other ancestor of (and not the same as) the second ?

isSubAccountNameOf :: AccountName -> AccountName -> Bool Source #

parentAccountName :: AccountName -> AccountName Source #

parentAccountNames :: AccountName -> [AccountName] Source #

subAccountNamesFrom :: [AccountName] -> AccountName -> [AccountName] Source #

From a list of account names, select those which are direct subaccounts of the given account name.

topAccountNames :: [AccountName] -> [AccountName] Source #

"a:b:c","d:e"
  -> ["a","d"]

unbudgetedAccountName :: Text Source #

A top-level account prefixed to some accounts in budget reports. Defined here so it can be ignored by accountNameDrop.

tests_AccountName :: TestTree Source #