hledger-lib
Safe HaskellNone
LanguageGHC2021

Hledger.Data.AccountType

Description

Helpers for working with AccountTypes. Subtypes (Cash, Conversion, Gain, UnrealisedGain, Imbalance) are recognised as their parent type where appropriate.

Synopsis

Documentation

isAccountSubtypeOf :: AccountType -> AccountType -> Bool Source #

Check whether the first argument is a subtype of the second: either equal or one of the defined subtypes.

isAssetType :: AccountType -> Bool Source #

Is this an Asset or Cash (subtype of Asset) account type ?

isLiabilityType :: AccountType -> Bool Source #

Is this a Liability account type ?

isEquityType :: AccountType -> Bool Source #

Is this an Equity or Conversion (subtype of Equity) account type ?

isRevenueType :: AccountType -> Bool Source #

Is this a Revenue or Gain (subtype of Revenue) account type ?

isExpenseType :: AccountType -> Bool Source #

Is this an Expense account type ?

accountTypeName :: AccountType -> Text Source #

An account type's long-form name (its one-letter code is its show value).

parseAccountType :: Bool -> Text -> Either String AccountType Source #

Case-insensitively parse an account type's one-letter code, or if permitted, its long-form name (or another accepted spelling of that). On failure, returns the unparseable text.

accountTypeChoices :: Bool -> String Source #

The account type codes, and if permitted their long-form names, for showing in messages.

data LotDirection Source #

Which way lots flow in a lot-tracking account. In a Long account (assets) a positive posting opens a lot and a negative one closes it; in a Short account (liabilities, holding short positions) it is the reverse: a negative posting opens a short lot and a positive one closes (covers) it.

Constructors

Long 
Short 

Instances

Instances details
Eq LotDirection Source # 
Instance details

Defined in Hledger.Data.AccountType

Methods

(==) :: LotDirection -> LotDirection -> Bool

(/=) :: LotDirection -> LotDirection -> Bool

Ord LotDirection Source # 
Instance details

Defined in Hledger.Data.AccountType

Show LotDirection Source # 
Instance details

Defined in Hledger.Data.AccountType

Methods

showsPrec :: Int -> LotDirection -> ShowS

show :: LotDirection -> String

showList :: [LotDirection] -> ShowS

accountTypeLotDirection :: AccountType -> Maybe LotDirection Source #

The lot direction of an account type: Long for assets (and Cash), Short for liabilities, none for other types, which don't hold lots.

lotDirectionSign :: LotDirection -> Quantity Source #

The sign of a posting that opens a lot in this direction: 1 or -1. Multiplying a posting quantity by this gives its lot flow: positive when it opens or receives a lot, negative when it closes or sends one.