Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hledger
Synopsis
- trace :: String -> a -> a
- data Color
- data ColorIntensity
- traceMarkerIO :: String -> IO ()
- traceMarker :: String -> a -> a
- traceEventIO :: String -> IO ()
- traceEvent :: String -> a -> a
- traceStack :: String -> a -> a
- traceShowM :: (Show a, Applicative f) => a -> f ()
- traceM :: Applicative f => String -> f ()
- traceShowId :: Show a => a -> a
- traceShow :: Show a => a -> b -> b
- traceId :: String -> String
- putTraceMsg :: String -> IO ()
- traceIO :: String -> IO ()
- ppShow :: Show a => a -> String
- color :: ColorIntensity -> Color -> String -> String
- bgColor :: ColorIntensity -> Color -> String -> String
- testName :: Test -> String
- flattenTests :: Test -> [Test]
- filterTests :: (Test -> Bool) -> Test -> Test
- is :: (Eq a, Show a) => a -> a -> Assertion
- assertParse :: (Show t, Show e) => Either (ParseError t e) a -> Assertion
- assertParseFailure :: Either (ParseError t e) a -> Assertion
- assertParseEqual :: (Show a, Eq a, Show t, Show e) => Either (ParseError t e) a -> a -> Assertion
- printParseError :: Show a => a -> IO ()
- type SystemString = String
- fromSystemString :: SystemString -> String
- toSystemString :: String -> SystemString
- error' :: String -> a
- userError' :: String -> IOError
- usageError :: String -> a
- type Replacement = String
- type Regexp = String
- regexMatches :: Regexp -> String -> Bool
- regexMatchesCI :: Regexp -> String -> Bool
- regexReplaceBy :: Regexp -> (String -> String) -> String -> String
- regexReplaceByCI :: Regexp -> (String -> String) -> String -> String
- regexReplace :: Regexp -> Replacement -> String -> String
- regexReplaceCI :: Regexp -> Replacement -> String -> String
- regexReplaceMemo :: Regexp -> Replacement -> String -> String
- regexReplaceCIMemo :: Regexp -> Replacement -> String -> String
- newtype FastTree a = T (Map a (FastTree a))
- root :: Tree a -> a
- subs :: Tree a -> Forest a
- branches :: Tree a -> Forest a
- leaves :: Tree a -> [a]
- subtreeat :: Eq a => a -> Tree a -> Maybe (Tree a)
- subtreeinforest :: Eq a => a -> [Tree a] -> Maybe (Tree a)
- treeprune :: Int -> Tree a -> Tree a
- treemap :: (a -> b) -> Tree a -> Tree b
- treefilter :: (a -> Bool) -> Tree a -> Tree a
- treeany :: (a -> Bool) -> Tree a -> Bool
- showtree :: Show a => Tree a -> String
- showforest :: Show a => Forest a -> String
- emptyTree :: FastTree a
- mergeTrees :: Ord a => FastTree a -> FastTree a -> FastTree a
- treeFromPath :: [a] -> FastTree a
- treeFromPaths :: Ord a => [[a]] -> FastTree a
- data Ledger = Ledger {}
- data NormalBalance
- data Account = Account {
- aname :: AccountName
- aebalance :: MixedAmount
- asubs :: [Account]
- anumpostings :: Int
- aibalance :: MixedAmount
- aparent :: Maybe Account
- aboring :: Bool
- data Reader = Reader {}
- type StorageFormat = String
- type ParsedJournal = Journal
- data Journal = Journal {
- jparsedefaultyear :: Maybe Year
- jparsedefaultcommodity :: Maybe (CommoditySymbol, AmountStyle)
- jparseparentaccounts :: [AccountName]
- jparsealiases :: [AccountAlias]
- jparsetimeclockentries :: [TimeclockEntry]
- jaccounts :: [AccountName]
- jcommodities :: Map CommoditySymbol Commodity
- jinferredcommodities :: Map CommoditySymbol AmountStyle
- jmarketprices :: [MarketPrice]
- jmodifiertxns :: [ModifierTransaction]
- jperiodictxns :: [PeriodicTransaction]
- jtxns :: [Transaction]
- jfinalcommentlines :: Text
- jfiles :: [(FilePath, Text)]
- jlastreadtime :: ClockTime
- data MarketPrice = MarketPrice {}
- data TimeclockEntry = TimeclockEntry {}
- data TimeclockCode
- = SetBalance
- | SetRequiredHours
- | In
- | Out
- | FinalOut
- data PeriodicTransaction = PeriodicTransaction {
- ptperiodicexpr :: Text
- ptpostings :: [Posting]
- data ModifierTransaction = ModifierTransaction {
- mtvalueexpr :: Text
- mtpostings :: [Posting]
- data Transaction = Transaction {}
- data GenericSourcePos
- data Posting = Posting {
- pdate :: Maybe Day
- pdate2 :: Maybe Day
- pstatus :: Status
- paccount :: AccountName
- pamount :: MixedAmount
- pcomment :: Text
- ptype :: PostingType
- ptags :: [Tag]
- pbalanceassertion :: BalanceAssertion
- ptransaction :: Maybe Transaction
- porigin :: Maybe Posting
- type BalanceAssertion = Maybe (Amount, GenericSourcePos)
- data Status
- type Tag = (TagName, TagValue)
- type TagValue = Text
- type TagName = Text
- data PostingType
- newtype MixedAmount = Mixed [Amount]
- data Amount = Amount {}
- data Commodity = Commodity {}
- type CommoditySymbol = Text
- data DigitGroupStyle = DigitGroups Char [Int]
- data AmountStyle = AmountStyle {}
- data Price
- type Quantity = Decimal
- data Side
- data AccountAlias
- type AccountName = Text
- data Interval
- data Period
- type WeekDay = Int
- type MonthDay = Int
- type YearDay = Int
- type MonthWeek = Int
- type YearWeek = Int
- type Quarter = Int
- type Month = Int
- type Year = Integer
- data DateSpan = DateSpan (Maybe Day) (Maybe Day)
- data WhichDate
- type SmartDate = (String, String, String)
- periodAsDateSpan :: Period -> DateSpan
- dateSpanAsPeriod :: DateSpan -> Period
- simplifyPeriod :: Period -> Period
- isLastDayOfMonth :: (Eq a1, Eq a2, Num a1, Num a2) => Integer -> a1 -> a2 -> Bool
- isStandardPeriod :: Period -> Bool
- showPeriod :: Period -> String
- periodStart :: Period -> Maybe Day
- periodEnd :: Period -> Maybe Day
- periodNext :: Period -> Period
- periodPrevious :: Period -> Period
- periodNextIn :: DateSpan -> Period -> Period
- periodPreviousIn :: DateSpan -> Period -> Period
- periodMoveTo :: Day -> Period -> Period
- periodGrow :: Period -> Period
- periodShrink :: Day -> Period -> Period
- mondayBefore :: Day -> Day
- yearMonthContainingWeekStarting :: Day -> (Integer, Int)
- quarterContainingMonth :: Integral a => a -> a
- firstMonthOfQuarter :: Num a => a -> a
- startOfFirstWeekInMonth :: Integer -> Int -> Day
- type ErroringJournalParser m a = StateT Journal (ParsecT MPErr Text (ExceptT String m)) a
- type JournalParser m a = StateT Journal (ParsecT MPErr Text m) a
- type TextParser m a = ParsecT MPErr Text m a
- type SimpleTextParser = Parsec MPErr Text
- type SimpleStringParser a = Parsec MPErr String a
- choice' :: [TextParser m a] -> TextParser m a
- choiceInState :: [StateT s (ParsecT MPErr Text m) a] -> StateT s (ParsecT MPErr Text m) a
- surroundedBy :: Applicative m => m openclose -> m a -> m a
- parsewith :: Parsec e Text a -> Text -> Either (ParseError Char e) a
- parsewithString :: Parsec e String a -> String -> Either (ParseError Char e) a
- parseWithState :: Monad m => st -> StateT st (ParsecT MPErr Text m) a -> Text -> m (Either (ParseError Char MPErr) a)
- parseWithState' :: Stream s => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseError (Token s) e) a
- fromparse :: (Show t, Show e) => Either (ParseError t e) a -> a
- parseerror :: (Show t, Show e) => ParseError t e -> a
- showParseError :: (Show t, Show e) => ParseError t e -> String
- showDateParseError :: (Show t, Show e) => ParseError t e -> String
- nonspace :: TextParser m Char
- spacenonewline :: (Stream s, Char ~ Token s) => ParsecT MPErr s m Char
- restofline :: TextParser m String
- eolof :: TextParser m ()
- lowercase :: String -> String
- uppercase :: String -> String
- strip :: String -> String
- lstrip :: String -> String
- rstrip :: String -> String
- chomp :: String -> String
- stripbrackets :: String -> String
- elideLeft :: Int -> String -> String
- elideRight :: Int -> String -> String
- formatString :: Bool -> Maybe Int -> Maybe Int -> String -> String
- underline :: String -> String
- quoteIfNeeded :: String -> String
- singleQuoteIfNeeded :: String -> String
- escapeQuotes :: String -> String
- words' :: String -> [String]
- unwords' :: [String] -> String
- unbracket :: String -> String
- concatTopPadded :: [String] -> String
- concatBottomPadded :: [String] -> String
- concatOneLine :: [String] -> String
- vConcatLeftAligned :: [String] -> String
- vConcatRightAligned :: [String] -> String
- padtop :: Int -> String -> String
- padbottom :: Int -> String -> String
- padleft :: Int -> String -> String
- padright :: Int -> String -> String
- cliptopleft :: Int -> Int -> String -> String
- fitto :: Int -> Int -> String -> String
- fitString :: Maybe Int -> Maybe Int -> Bool -> Bool -> String -> String
- fitStringMulti :: Maybe Int -> Maybe Int -> Bool -> Bool -> String -> String
- padLeftWide :: Int -> String -> String
- padRightWide :: Int -> String -> String
- takeWidth :: Int -> String -> String
- strWidth :: String -> Int
- stripAnsi :: String -> String
- charWidth :: Char -> Int
- textstrip :: Text -> Text
- textlstrip :: Text -> Text
- textrstrip :: Text -> Text
- textElideRight :: Int -> Text -> Text
- quoteIfSpaced :: Text -> Text
- quotechars :: [Char]
- whitespacechars :: [Char]
- escapeDoubleQuotes :: Text -> Text
- escapeSingleQuotes :: Text -> Text
- stripquotes :: Text -> Text
- isSingleQuoted :: Text -> Bool
- isDoubleQuoted :: Text -> Bool
- textUnbracket :: Text -> Text
- textConcatTopPadded :: [Text] -> Text
- difforzero :: (Num a, Ord a) => a -> a -> a
- fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text
- textPadLeftWide :: Int -> Text -> Text
- textPadRightWide :: Int -> Text -> Text
- textTakeWidth :: Int -> Text -> Text
- textWidth :: Text -> Int
- pprint :: Show a => a -> IO ()
- traceWith :: (a -> String) -> a -> a
- ptrace :: String -> TextParser m ()
- debugLevel :: Int
- dbg0 :: Show a => String -> a -> a
- dbg1 :: Show a => String -> a -> a
- dbg2 :: Show a => String -> a -> a
- dbg3 :: Show a => String -> a -> a
- dbg4 :: Show a => String -> a -> a
- dbg5 :: Show a => String -> a -> a
- dbg6 :: Show a => String -> a -> a
- dbg7 :: Show a => String -> a -> a
- dbg8 :: Show a => String -> a -> a
- dbg9 :: Show a => String -> a -> a
- dbg0IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg1IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg2IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg3IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg4IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg5IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg6IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg7IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg8IO :: (MonadIO m, Show a) => String -> a -> m ()
- dbg9IO :: (MonadIO m, Show a) => String -> a -> m ()
- tracePrettyAt :: Show a => Int -> String -> a -> a
- tracePrettyAtIO :: (MonadIO m, Show a) => Int -> String -> a -> m ()
- log0 :: Show a => String -> a -> a
- logPrettyAt :: Show a => Int -> String -> a -> a
- dbgppshow :: Show a => Int -> String -> a -> a
- dbgExit :: Show a => String -> a -> a
- pdbg :: Int -> String -> TextParser m ()
- dbglog :: Show a => String -> a -> a
- first3 :: (a, b, c) -> a
- second3 :: (a, b, c) -> b
- third3 :: (a, b, c) -> c
- first4 :: (a, b, c, d) -> a
- second4 :: (a, b, c, d) -> b
- third4 :: (a, b, c, d) -> c
- fourth4 :: (a, b, c, d) -> d
- first5 :: (a, b, c, d, e) -> a
- second5 :: (a, b, c, d, e) -> b
- third5 :: (a, b, c, d, e) -> c
- fourth5 :: (a, b, c, d, e) -> d
- fifth5 :: (a, b, c, d, e) -> e
- first6 :: (a, b, c, d, e, f) -> a
- second6 :: (a, b, c, d, e, f) -> b
- third6 :: (a, b, c, d, e, f) -> c
- fourth6 :: (a, b, c, d, e, f) -> d
- fifth6 :: (a, b, c, d, e, f) -> e
- sixth6 :: (a, b, c, d, e, f) -> f
- splitAtElement :: Eq a => a -> [a] -> [[a]]
- getCurrentLocalTime :: IO LocalTime
- getCurrentZonedTime :: IO ZonedTime
- isLeft :: Either a b -> Bool
- isRight :: Either a b -> Bool
- applyN :: Int -> (a -> a) -> a -> a
- expandPath :: FilePath -> FilePath -> IO FilePath
- firstJust :: Eq a => [Maybe a] -> Maybe a
- readFile' :: FilePath -> IO Text
- readFileAnyLineEnding :: FilePath -> IO Text
- readFileOrStdinAnyLineEnding :: String -> IO Text
- maximum' :: Integral a => [a] -> a
- sumStrict :: Num a => [a] -> a
- maximumStrict :: Ord a => [a] -> a
- minimumStrict :: Ord a => [a] -> a
- sequence' :: Monad f => [f a] -> f [a]
- mapM' :: Monad f => (a -> f b) -> [a] -> f [b]
- type RawOpts = [(String, String)]
- setopt :: String -> String -> RawOpts -> RawOpts
- setboolopt :: String -> RawOpts -> RawOpts
- inRawOpts :: String -> RawOpts -> Bool
- boolopt :: String -> RawOpts -> Bool
- maybestringopt :: String -> RawOpts -> Maybe String
- stringopt :: String -> RawOpts -> String
- listofstringopt :: String -> RawOpts -> [String]
- maybeintopt :: String -> RawOpts -> Maybe Int
- intopt :: String -> RawOpts -> Int
- nonsimplecommoditychars :: [Char]
- quoteCommoditySymbolIfNeeded :: Text -> Text
- commodity :: [Char]
- commoditysymbols :: [(String, CommoditySymbol)]
- comm :: String -> CommoditySymbol
- conversionRate :: CommoditySymbol -> CommoditySymbol -> Double
- tests_Hledger_Data_Commodity :: Test
- amountstyle :: AmountStyle
- amount :: Amount
- nullamt :: Amount
- missingamt :: Amount
- num :: Quantity -> Amount
- hrs :: Quantity -> Amount
- usd :: DecimalRaw Integer -> Amount
- eur :: DecimalRaw Integer -> Amount
- gbp :: DecimalRaw Integer -> Amount
- at :: Amount -> Amount -> Amount
- (@@) :: Amount -> Amount -> Amount
- amountWithCommodity :: CommoditySymbol -> Amount -> Amount
- costOfAmount :: Amount -> Amount
- divideAmount :: Amount -> Quantity -> Amount
- isNegativeAmount :: Amount -> Bool
- isZeroAmount :: Amount -> Bool
- isReallyZeroAmount :: Amount -> Bool
- setAmountPrecision :: Int -> Amount -> Amount
- withPrecision :: Amount -> Int -> Amount
- showAmountDebug :: Amount -> String
- showAmountWithoutPrice :: Amount -> String
- showAmount :: Amount -> String
- cshowAmount :: Amount -> String
- showAmountWithZeroCommodity :: Amount -> String
- maxprecision :: Int
- maxprecisionwithpoint :: Int
- canonicaliseAmount :: Map CommoditySymbol AmountStyle -> Amount -> Amount
- amountValue :: Journal -> Day -> Amount -> Amount
- nullmixedamt :: MixedAmount
- missingmixedamt :: MixedAmount
- mixed :: [Amount] -> MixedAmount
- normaliseMixedAmount :: MixedAmount -> MixedAmount
- normaliseMixedAmountSquashPricesForDisplay :: MixedAmount -> MixedAmount
- amounts :: MixedAmount -> [Amount]
- filterMixedAmount :: (Amount -> Bool) -> MixedAmount -> MixedAmount
- filterMixedAmountByCommodity :: CommoditySymbol -> MixedAmount -> MixedAmount
- costOfMixedAmount :: MixedAmount -> MixedAmount
- divideMixedAmount :: MixedAmount -> Quantity -> MixedAmount
- averageMixedAmounts :: [MixedAmount] -> MixedAmount
- isNegativeMixedAmount :: MixedAmount -> Maybe Bool
- isZeroMixedAmount :: MixedAmount -> Bool
- isReallyZeroMixedAmount :: MixedAmount -> Bool
- isReallyZeroMixedAmountCost :: MixedAmount -> Bool
- showMixedAmount :: MixedAmount -> String
- showMixedAmountWithZeroCommodity :: MixedAmount -> String
- showMixedAmountOneLine :: MixedAmount -> String
- ltraceamount :: String -> MixedAmount -> MixedAmount
- setMixedAmountPrecision :: Int -> MixedAmount -> MixedAmount
- showMixedAmountWithPrecision :: Int -> MixedAmount -> String
- showMixedAmountDebug :: MixedAmount -> String
- showMixedAmountWithoutPrice :: MixedAmount -> String
- cshowMixedAmountWithoutPrice :: MixedAmount -> String
- showMixedAmountOneLineWithoutPrice :: MixedAmount -> String
- cshowMixedAmountOneLineWithoutPrice :: MixedAmount -> String
- canonicaliseMixedAmount :: Map CommoditySymbol AmountStyle -> MixedAmount -> MixedAmount
- mixedAmountValue :: Journal -> Day -> MixedAmount -> MixedAmount
- tests_Hledger_Data_Amount :: Test
- acctsepchar :: Char
- acctsep :: Text
- accountNameComponents :: AccountName -> [Text]
- accountNameFromComponents :: [Text] -> AccountName
- accountLeafName :: AccountName -> Text
- accountSummarisedName :: AccountName -> Text
- accountNameLevel :: AccountName -> Int
- accountNameDrop :: Int -> AccountName -> AccountName
- expandAccountNames :: [AccountName] -> [AccountName]
- expandAccountName :: 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
- nullaccountnametree :: IsString a => Tree a
- elideAccountName :: Int -> AccountName -> AccountName
- clipAccountName :: Int -> AccountName -> AccountName
- clipOrEllipsifyAccountName :: Int -> AccountName -> AccountName
- escapeName :: AccountName -> Regexp
- accountNameToAccountRegex :: AccountName -> Regexp
- accountNameToAccountOnlyRegex :: AccountName -> Regexp
- accountRegexToAccountName :: Regexp -> AccountName
- isAccountRegex :: String -> Bool
- tests_Hledger_Data_AccountName :: Test
- data ReportItemField
- data StringFormatComponent
- data StringFormat
- parseStringFormat :: String -> Either String StringFormat
- defaultStringFormatStyle :: [StringFormatComponent] -> StringFormat
- tests_Hledger_Data_StringFormat :: Test
- showDate :: Day -> String
- showDateSpan :: DateSpan -> String
- getCurrentDay :: IO Day
- getCurrentMonth :: IO Int
- getCurrentYear :: IO Integer
- elapsedSeconds :: Fractional a => UTCTime -> UTCTime -> a
- spanStart :: DateSpan -> Maybe Day
- spanEnd :: DateSpan -> Maybe Day
- spansSpan :: [DateSpan] -> DateSpan
- splitSpan :: Interval -> DateSpan -> [DateSpan]
- daysInSpan :: DateSpan -> Maybe Integer
- spanContainsDate :: DateSpan -> Day -> Bool
- periodContainsDate :: Period -> Day -> Bool
- spansIntersect :: [DateSpan] -> DateSpan
- spanIntersect :: DateSpan -> DateSpan -> DateSpan
- spanDefaultsFrom :: DateSpan -> DateSpan -> DateSpan
- spansUnion :: [DateSpan] -> DateSpan
- spanUnion :: DateSpan -> DateSpan -> DateSpan
- parsePeriodExpr :: Day -> Text -> Either (ParseError Char MPErr) (Interval, DateSpan)
- maybePeriod :: Day -> Text -> Maybe (Interval, DateSpan)
- fixSmartDateStr :: Day -> Text -> String
- fixSmartDateStrEither :: Day -> Text -> Either (ParseError Char MPErr) String
- fixSmartDateStrEither' :: Day -> Text -> Either (ParseError Char MPErr) Day
- fixSmartDate :: Day -> SmartDate -> Day
- prevday :: Day -> Day
- parsedateM :: String -> Maybe Day
- parsedate :: String -> Day
- smartdate :: SimpleTextParser SmartDate
- datesepchars :: [Char]
- datesepchar :: TextParser m Char
- failIfInvalidYear :: Monad m => String -> m ()
- failIfInvalidMonth :: Monad m => String -> m ()
- failIfInvalidDay :: Monad m => String -> m ()
- mkdatespan :: String -> String -> DateSpan
- nulldatespan :: DateSpan
- nulldate :: Day
- nullposting :: Posting
- posting :: Posting
- post :: AccountName -> Amount -> Posting
- originalPosting :: Posting -> Posting
- showPosting :: Posting -> String
- showComment :: Text -> String
- isReal :: Posting -> Bool
- isVirtual :: Posting -> Bool
- isBalancedVirtual :: Posting -> Bool
- hasAmount :: Posting -> Bool
- isAssignment :: Posting -> Bool
- accountNamesFromPostings :: [Posting] -> [AccountName]
- sumPostings :: [Posting] -> MixedAmount
- removePrices :: Posting -> Posting
- postingDate :: Posting -> Day
- postingDate2 :: Posting -> Day
- postingStatus :: Posting -> Status
- transactionPayee :: Transaction -> Text
- transactionNote :: Transaction -> Text
- payeeAndNoteFromDescription :: Text -> (Text, Text)
- postingAllTags :: Posting -> [Tag]
- transactionAllTags :: Transaction -> [Tag]
- relatedPostings :: Posting -> [Posting]
- isPostingInDateSpan :: DateSpan -> Posting -> Bool
- isPostingInDateSpan' :: WhichDate -> DateSpan -> Posting -> Bool
- isEmptyPosting :: Posting -> Bool
- postingsDateSpan :: [Posting] -> DateSpan
- postingsDateSpan' :: WhichDate -> [Posting] -> DateSpan
- accountNamePostingType :: AccountName -> PostingType
- accountNameWithoutPostingType :: AccountName -> AccountName
- accountNameWithPostingType :: PostingType -> AccountName -> AccountName
- joinAccountNames :: AccountName -> AccountName -> AccountName
- concatAccountNames :: [AccountName] -> AccountName
- accountNameApplyAliases :: [AccountAlias] -> AccountName -> AccountName
- accountNameApplyAliasesMemo :: [AccountAlias] -> AccountName -> AccountName
- tests_Hledger_Data_Posting :: Test
- sourceFilePath :: GenericSourcePos -> FilePath
- sourceFirstLine :: GenericSourcePos -> Int
- showGenericSourcePos :: GenericSourcePos -> String
- nullsourcepos :: GenericSourcePos
- nulltransaction :: Transaction
- showTransaction :: Transaction -> String
- showTransactionUnelided :: Transaction -> String
- showTransactionUnelidedOneLineAmounts :: Transaction -> String
- showPostingLine :: Posting -> String
- showPostingLines :: Posting -> [String]
- showAccountName :: Maybe Int -> PostingType -> AccountName -> String
- hasRealPostings :: Transaction -> Bool
- realPostings :: Transaction -> [Posting]
- assignmentPostings :: Transaction -> [Posting]
- virtualPostings :: Transaction -> [Posting]
- balancedVirtualPostings :: Transaction -> [Posting]
- transactionsPostings :: [Transaction] -> [Posting]
- transactionPostingBalances :: Transaction -> (MixedAmount, MixedAmount, MixedAmount)
- isTransactionBalanced :: Maybe (Map CommoditySymbol AmountStyle) -> Transaction -> Bool
- balanceTransaction :: Maybe (Map CommoditySymbol AmountStyle) -> Transaction -> Either String Transaction
- balanceTransactionUpdate :: MonadError String m => (AccountName -> MixedAmount -> m ()) -> Maybe (Map CommoditySymbol AmountStyle) -> Transaction -> m Transaction
- transactionDate2 :: Transaction -> Day
- txnTieKnot :: Transaction -> Transaction
- txnUntieKnot :: Transaction -> Transaction
- tests_Hledger_Data_Transaction :: Test
- data QueryOpt
- data Query
- parseQuery :: Day -> Text -> (Query, [QueryOpt])
- words'' :: [Text] -> Text -> [Text]
- simplifyQuery :: Query -> Query
- filterQuery :: (Query -> Bool) -> Query -> Query
- queryIsNull :: Query -> Bool
- queryIsDepth :: Query -> Bool
- queryIsDate :: Query -> Bool
- queryIsDate2 :: Query -> Bool
- queryIsDateOrDate2 :: Query -> Bool
- queryIsAcct :: Query -> Bool
- queryIsSym :: Query -> Bool
- queryIsReal :: Query -> Bool
- queryIsStatus :: Query -> Bool
- queryIsEmpty :: Query -> Bool
- queryIsStartDateOnly :: Bool -> Query -> Bool
- queryStartDate :: Bool -> Query -> Maybe Day
- queryEndDate :: Bool -> Query -> Maybe Day
- queryDateSpan :: Bool -> Query -> DateSpan
- queryDateSpan' :: Query -> DateSpan
- queryDepth :: Query -> Int
- inAccount :: [QueryOpt] -> Maybe (AccountName, Bool)
- inAccountQuery :: [QueryOpt] -> Maybe Query
- matchesAccount :: Query -> AccountName -> Bool
- matchesMixedAmount :: Query -> MixedAmount -> Bool
- matchesAmount :: Query -> Amount -> Bool
- matchesPosting :: Query -> Posting -> Bool
- matchesTransaction :: Query -> Transaction -> Bool
- tests_Hledger_Query :: Test
- timeclockEntriesToTransactions :: LocalTime -> [TimeclockEntry] -> [Transaction]
- entryFromTimeclockInOut :: TimeclockEntry -> TimeclockEntry -> Transaction
- tests_Hledger_Data_Timeclock :: Test
- 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]
- sortAccountTreeByAmount :: NormalBalance -> 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
- showMarketPrice :: MarketPrice -> String
- tests_Hledger_Data_MarketPrice :: Test
- nulljournal :: Journal
- journalFilePath :: Journal -> FilePath
- journalFilePaths :: Journal -> [FilePath]
- addTransaction :: Transaction -> Journal -> Journal
- addModifierTransaction :: ModifierTransaction -> Journal -> Journal
- addPeriodicTransaction :: PeriodicTransaction -> Journal -> Journal
- addMarketPrice :: MarketPrice -> Journal -> Journal
- journalTransactionAt :: Journal -> Integer -> Maybe Transaction
- journalNextTransaction :: Journal -> Transaction -> Maybe Transaction
- journalPrevTransaction :: Journal -> Transaction -> Maybe Transaction
- journalDescriptions :: Journal -> [Text]
- journalPostings :: Journal -> [Posting]
- journalAccountNamesUsed :: Journal -> [AccountName]
- journalAccountNamesImplied :: Journal -> [AccountName]
- journalAccountNamesDeclared :: Journal -> [AccountName]
- journalAccountNamesDeclaredOrUsed :: Journal -> [AccountName]
- journalAccountNamesDeclaredOrImplied :: Journal -> [AccountName]
- journalAccountNames :: Journal -> [AccountName]
- journalProfitAndLossAccountQuery :: Journal -> Query
- journalIncomeAccountQuery :: Journal -> Query
- journalExpenseAccountQuery :: Journal -> Query
- journalBalanceSheetAccountQuery :: Journal -> Query
- journalAssetAccountQuery :: Journal -> Query
- journalLiabilityAccountQuery :: Journal -> Query
- journalEquityAccountQuery :: Journal -> Query
- journalCashAccountQuery :: Journal -> Query
- filterJournalTransactions :: Query -> Journal -> Journal
- filterJournalPostings :: Query -> Journal -> Journal
- filterJournalAmounts :: Query -> Journal -> Journal
- filterTransactionAmounts :: Query -> Transaction -> Transaction
- filterPostingAmount :: Query -> Posting -> Posting
- filterTransactionPostings :: Query -> Transaction -> Transaction
- journalApplyAliases :: [AccountAlias] -> Journal -> Journal
- journalFinalise :: ClockTime -> FilePath -> Text -> Bool -> ParsedJournal -> Either String Journal
- journalNumberAndTieTransactions :: Journal -> Journal
- journalUntieTransactions :: Transaction -> Transaction
- journalCheckBalanceAssertions :: Journal -> Either String Journal
- journalBalanceTransactions :: Bool -> Journal -> Either String Journal
- journalApplyCommodityStyles :: Journal -> Journal
- commodityStylesFromAmounts :: [Amount] -> Map CommoditySymbol AmountStyle
- canonicalStyleFrom :: [AmountStyle] -> AmountStyle
- journalConvertAmountsToCost :: Journal -> Journal
- journalAmounts :: Journal -> [Amount]
- overJournalAmounts :: (Amount -> Amount) -> Journal -> Journal
- traverseJournalAmounts :: Applicative f => (Amount -> f Amount) -> Journal -> f Journal
- journalDateSpan :: Bool -> Journal -> DateSpan
- journalPivot :: Text -> Journal -> Journal
- matchpats :: [String] -> String -> Bool
- samplejournal :: Journal
- tests_Hledger_Data_Journal :: Test
- nullledger :: Ledger
- ledgerFromJournal :: Query -> Journal -> Ledger
- ledgerAccountNames :: Ledger -> [AccountName]
- ledgerAccount :: Ledger -> AccountName -> Maybe Account
- ledgerRootAccount :: Ledger -> Account
- ledgerTopAccounts :: Ledger -> [Account]
- ledgerLeafAccounts :: Ledger -> [Account]
- ledgerAccountsMatching :: [String] -> Ledger -> [Account]
- ledgerPostings :: Ledger -> [Posting]
- ledgerDateSpan :: Ledger -> DateSpan
- ledgerCommodities :: Ledger -> [CommoditySymbol]
- tests_ledgerFromJournal :: [Test]
- tests_Hledger_Data_Ledger :: Test
- runModifierTransaction :: Query -> ModifierTransaction -> Transaction -> Transaction
- mtvaluequery :: ModifierTransaction -> Day -> Query
- jdatespan :: Journal -> DateSpan
- runPeriodicTransaction :: PeriodicTransaction -> DateSpan -> [Transaction]
- tests_Hledger_Data :: Test
- data ReportOpts = ReportOpts {
- period_ :: Period
- interval_ :: Interval
- statuses_ :: [Status]
- cost_ :: Bool
- depth_ :: Maybe Int
- display_ :: Maybe DisplayExp
- date2_ :: Bool
- empty_ :: Bool
- no_elide_ :: Bool
- real_ :: Bool
- format_ :: Maybe FormatStr
- query_ :: String
- average_ :: Bool
- related_ :: Bool
- balancetype_ :: BalanceType
- accountlistmode_ :: AccountListMode
- drop_ :: Int
- row_total_ :: Bool
- no_total_ :: Bool
- value_ :: Bool
- pretty_tables_ :: Bool
- sort_amount_ :: Bool
- normalbalance_ :: Maybe NormalBalance
- color_ :: Bool
- forecast_ :: Bool
- auto_ :: Bool
- data AccountListMode
- data BalanceType
- type FormatStr = String
- defreportopts :: ReportOpts
- rawOptsToReportOpts :: RawOpts -> IO ReportOpts
- checkReportOpts :: ReportOpts -> ReportOpts
- simplifyStatuses :: Ord a => [a] -> [a]
- reportOptsToggleStatus :: Status -> ReportOpts -> ReportOpts
- transactionDateFn :: ReportOpts -> Transaction -> Day
- postingDateFn :: ReportOpts -> Posting -> Day
- whichDateFromOpts :: ReportOpts -> WhichDate
- tree_ :: ReportOpts -> Bool
- flat_ :: ReportOpts -> Bool
- journalSelectingAmountFromOpts :: ReportOpts -> Journal -> Journal
- queryFromOpts :: Day -> ReportOpts -> Query
- queryFromOptsOnly :: Day -> ReportOpts -> Query
- queryOptsFromOpts :: Day -> ReportOpts -> [QueryOpt]
- reportStartEndDates :: Journal -> ReportOpts -> IO (Maybe (Day, Day))
- reportStartDate :: Journal -> ReportOpts -> IO (Maybe Day)
- reportEndDate :: Journal -> ReportOpts -> IO (Maybe Day)
- specifiedStartEndDates :: ReportOpts -> IO (Maybe Day, Maybe Day)
- specifiedStartDate :: ReportOpts -> IO (Maybe Day)
- specifiedEndDate :: ReportOpts -> IO (Maybe Day)
- tests_Hledger_Reports_ReportOptions :: Test
- type AccountTransactionsReportItem = (Transaction, Transaction, Bool, String, MixedAmount, MixedAmount)
- type AccountTransactionsReport = (String, [AccountTransactionsReportItem])
- type TransactionsReportItem = (Transaction, Transaction, Bool, String, MixedAmount, MixedAmount)
- type TransactionsReport = (String, [TransactionsReportItem])
- triOrigTransaction :: (a, b, c, d, e, f) -> a
- triDate :: (a, Transaction, c, d, e, f) -> Day
- triAmount :: (a, b, c, d, e, f) -> e
- triBalance :: (a, b, c, d, e, f) -> f
- triCommodityAmount :: CommoditySymbol -> (a, b, c, d, MixedAmount, f) -> MixedAmount
- triCommodityBalance :: CommoditySymbol -> (a, b, c, d, e, MixedAmount) -> MixedAmount
- journalTransactionsReport :: ReportOpts -> Journal -> Query -> TransactionsReport
- accountTransactionsReport :: ReportOpts -> Journal -> Query -> Query -> AccountTransactionsReport
- transactionRegisterDate :: Query -> Query -> Transaction -> Day
- transactionsReportByCommodity :: TransactionsReport -> [(CommoditySymbol, TransactionsReport)]
- type PostingsReportItem = (Maybe Day, Maybe Day, Maybe String, Posting, MixedAmount)
- type PostingsReport = (String, [PostingsReportItem])
- postingsReport :: ReportOpts -> Query -> Journal -> PostingsReport
- mkpostingsReportItem :: Bool -> Bool -> WhichDate -> Maybe Day -> Posting -> MixedAmount -> PostingsReportItem
- tests_Hledger_Reports_PostingsReport :: Test
- type EntriesReportItem = Transaction
- type EntriesReport = [EntriesReportItem]
- entriesReport :: ReportOpts -> Query -> Journal -> EntriesReport
- tests_Hledger_Reports_EntriesReport :: Test
- data InputOpts = InputOpts {}
- definputopts :: InputOpts
- rawOptsToInputOpts :: RawOpts -> InputOpts
- runTextParser :: TextParser Identity a -> Text -> Either (ParseError Char MPErr) a
- rtp :: TextParser Identity a -> Text -> Either (ParseError Char MPErr) a
- runJournalParser :: Monad m => TextParser m a -> Text -> m (Either (ParseError Char MPErr) a)
- rjp :: Monad m => TextParser m a -> Text -> m (Either (ParseError Char MPErr) a)
- runErroringJournalParser :: Monad m => ErroringJournalParser m a -> Text -> m (Either String a)
- rejp :: Monad m => ErroringJournalParser m a -> Text -> m (Either String a)
- genericSourcePos :: SourcePos -> GenericSourcePos
- journalSourcePos :: SourcePos -> SourcePos -> GenericSourcePos
- parseAndFinaliseJournal :: ErroringJournalParser IO ParsedJournal -> Bool -> FilePath -> Text -> ExceptT String IO Journal
- parseAndFinaliseJournal' :: JournalParser Identity ParsedJournal -> Bool -> FilePath -> Text -> ExceptT String IO Journal
- setYear :: Year -> JournalParser m ()
- getYear :: JournalParser m (Maybe Year)
- setDefaultCommodityAndStyle :: (CommoditySymbol, AmountStyle) -> JournalParser m ()
- getDefaultCommodityAndStyle :: JournalParser m (Maybe (CommoditySymbol, AmountStyle))
- getDefaultAmountStyle :: JournalParser m (Maybe AmountStyle)
- getAmountStyle :: CommoditySymbol -> JournalParser m (Maybe AmountStyle)
- pushAccount :: AccountName -> JournalParser m ()
- pushParentAccount :: AccountName -> JournalParser m ()
- popParentAccount :: JournalParser m ()
- getParentAccount :: JournalParser m AccountName
- addAccountAlias :: MonadState Journal m => AccountAlias -> m ()
- getAccountAliases :: MonadState Journal m => m [AccountAlias]
- clearAccountAliases :: MonadState Journal m => m ()
- journalAddFile :: (FilePath, Text) -> Journal -> Journal
- parserErrorAt :: Monad m => SourcePos -> String -> ErroringJournalParser m a
- statusp :: TextParser m Status
- codep :: TextParser m String
- descriptionp :: JournalParser m String
- datep :: JournalParser m Day
- datetimep :: JournalParser m LocalTime
- secondarydatep :: Day -> JournalParser m Day
- modifiedaccountnamep :: JournalParser m AccountName
- accountnamep :: TextParser m AccountName
- spaceandamountormissingp :: Monad m => JournalParser m MixedAmount
- amountp :: Monad m => JournalParser m Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- signp :: TextParser m String
- multiplierp :: TextParser m Bool
- leftsymbolamountp :: Monad m => JournalParser m Amount
- rightsymbolamountp :: Monad m => JournalParser m Amount
- nosymbolamountp :: Monad m => JournalParser m Amount
- commoditysymbolp :: TextParser m CommoditySymbol
- quotedcommoditysymbolp :: TextParser m CommoditySymbol
- simplecommoditysymbolp :: TextParser m CommoditySymbol
- priceamountp :: Monad m => JournalParser m Price
- partialbalanceassertionp :: Monad m => JournalParser m BalanceAssertion
- fixedlotpricep :: Monad m => JournalParser m (Maybe Amount)
- numberp :: Maybe AmountStyle -> TextParser m (Quantity, Int, Maybe Char, Maybe DigitGroupStyle)
- fromRawNumber :: Maybe AmountStyle -> Bool -> (Maybe Char, [String], Maybe (Char, String)) -> (Quantity, Int, Maybe Char, Maybe DigitGroupStyle)
- rawnumberp :: TextParser m (Maybe Char, [String], Maybe (Char, String))
- whitespaceChar :: TextParser m Char
- multilinecommentp :: JournalParser m ()
- emptyorcommentlinep :: JournalParser m ()
- followingcommentp :: JournalParser m Text
- followingcommentandtagsp :: MonadIO m => Maybe Day -> ErroringJournalParser m (Text, [Tag], Maybe Day, Maybe Day)
- commentp :: JournalParser m Text
- linecommentp :: JournalParser m Text
- commentStartingWithp :: [Char] -> JournalParser m Text
- commentTags :: Text -> [Tag]
- tagsp :: SimpleTextParser [Tag]
- nontagp :: SimpleTextParser String
- tagp :: SimpleTextParser Tag
- tagnamep :: SimpleTextParser Text
- tagvaluep :: TextParser m Text
- postingdatesp :: Monad m => Maybe Day -> ErroringJournalParser m [(TagName, Day)]
- datetagp :: Monad m => Maybe Day -> ErroringJournalParser m (TagName, Day)
- bracketeddatetagsp :: Monad m => Maybe Day -> ErroringJournalParser m [(TagName, Day)]
- accountaliasp :: TextParser m AccountAlias
- postingp :: MonadIO m => Maybe Day -> ErroringJournalParser m Posting
- type PrefixedFilePath = FilePath
- defaultJournal :: IO Journal
- defaultJournalPath :: IO String
- readJournalFiles :: Maybe StorageFormat -> Maybe FilePath -> Bool -> [PrefixedFilePath] -> IO (Either String Journal)
- readJournalFile :: Maybe StorageFormat -> Maybe FilePath -> Bool -> PrefixedFilePath -> IO (Either String Journal)
- splitReaderPrefix :: PrefixedFilePath -> (Maybe String, FilePath)
- requireJournalFileExists :: FilePath -> IO ()
- ensureJournalFileExists :: FilePath -> IO ()
- readJournal' :: Text -> IO Journal
- readJournal :: Maybe StorageFormat -> Maybe FilePath -> Bool -> Maybe FilePath -> Text -> IO (Either String Journal)
- readJournalFilesWithOpts :: InputOpts -> [FilePath] -> IO (Either String Journal)
- tests_Hledger_Read :: Test
- type BalanceReportItem = (AccountName, AccountName, Int, MixedAmount)
- type BalanceReport = ([BalanceReportItem], MixedAmount)
- flatShowsExclusiveBalance :: Bool
- balanceReport :: ReportOpts -> Query -> Journal -> BalanceReport
- tests_Hledger_Reports_BalanceReport :: Test
- type MultiBalanceReportRow = (AccountName, AccountName, Int, [MixedAmount], MixedAmount, MixedAmount)
- newtype MultiBalanceReport = MultiBalanceReport ([DateSpan], [MultiBalanceReportRow], MultiBalanceReportTotals)
- singleBalanceReport :: ReportOpts -> Query -> Journal -> BalanceReport
- multiBalanceReport :: ReportOpts -> Query -> Journal -> MultiBalanceReport
- tests_Hledger_Reports_MultiBalanceReport :: Test
- tests_Hledger_Reports :: Test
- tests_Hledger :: Test
Documentation
The trace
function outputs the trace message given as its first argument,
before returning the second argument as its result.
For example, this returns the value of f x
but first outputs the message.
>>>
let x = 123; f = show
>>>
trace ("calling f with x = " ++ show x) (f x)
"calling f with x = 123 123"
The trace
function should only be used for debugging, or for monitoring
execution. The function is not referentially transparent: its type indicates
that it is a pure function but it has the side effect of outputting the
trace message.
ANSI colors: come in various intensities, which are controlled by
ColorIntensity
data ColorIntensity #
ANSI colors come in two intensities
Instances
traceMarkerIO :: String -> IO () #
The traceMarkerIO
function emits a marker to the eventlog, if eventlog
profiling is available and enabled at runtime.
Compared to traceMarker
, traceMarkerIO
sequences the event with respect to
other IO actions.
Since: base-4.7.0.0
traceMarker :: String -> a -> a #
The traceMarker
function emits a marker to the eventlog, if eventlog
profiling is available and enabled at runtime. The String
is the name of
the marker. The name is just used in the profiling tools to help you keep
clear which marker is which.
This function is suitable for use in pure code. In an IO context use
traceMarkerIO
instead.
Note that when using GHC's SMP runtime, it is possible (but rare) to get
duplicate events emitted if two CPUs simultaneously evaluate the same thunk
that uses traceMarker
.
Since: base-4.7.0.0
traceEventIO :: String -> IO () #
The traceEventIO
function emits a message to the eventlog, if eventlog
profiling is available and enabled at runtime.
Compared to traceEvent
, traceEventIO
sequences the event with respect to
other IO actions.
Since: base-4.5.0.0
traceEvent :: String -> a -> a #
The traceEvent
function behaves like trace
with the difference that
the message is emitted to the eventlog, if eventlog profiling is available
and enabled at runtime.
It is suitable for use in pure code. In an IO context use traceEventIO
instead.
Note that when using GHC's SMP runtime, it is possible (but rare) to get
duplicate events emitted if two CPUs simultaneously evaluate the same thunk
that uses traceEvent
.
Since: base-4.5.0.0
traceStack :: String -> a -> a #
like trace
, but additionally prints a call stack if one is
available.
In the current GHC implementation, the call stack is only
available if the program was compiled with -prof
; otherwise
traceStack
behaves exactly like trace
. Entries in the call
stack correspond to SCC
annotations, so it is a good idea to use
-fprof-auto
or -fprof-auto-calls
to add SCC annotations automatically.
Since: base-4.5.0.0
traceShowM :: (Show a, Applicative f) => a -> f () #
traceM :: Applicative f => String -> f () #
Like trace
but returning unit in an arbitrary Applicative
context. Allows
for convenient use in do-notation.
Note that the application of traceM
is not an action in the Applicative
context, as traceIO
is in the IO
type. While the fresh bindings in the
following example will force the traceM
expressions to be reduced every time
the do
-block is executed, traceM "not crashed"
would only be reduced once,
and the message would only be printed once. If your monad is in MonadIO
,
liftIO . traceIO
may be a better option.
>>>
:{
do x <- Just 3 traceM ("x: " ++ show x) y <- pure 12 traceM ("y: " ++ show y) pure (x*2 + y) :} x: 3 y: 12 Just 18
Since: base-4.7.0.0
traceShowId :: Show a => a -> a #
Like traceShow
but returns the shown value instead of a third value.
>>>
traceShowId (1+2+3, "hello" ++ "world")
(6,"helloworld") (6,"helloworld")
Since: base-4.7.0.0
Like trace
but returns the message instead of a third value.
>>>
traceId "hello"
"hello hello"
Since: base-4.7.0.0
putTraceMsg :: String -> IO () #
The traceIO
function outputs the trace message from the IO monad.
This sequences the output with respect to other IO actions.
Since: base-4.5.0.0
color :: ColorIntensity -> Color -> String -> String Source #
Wrap a string in ANSI codes to set and reset foreground colour.
bgColor :: ColorIntensity -> Color -> String -> String Source #
Wrap a string in ANSI codes to set and reset background colour.
flattenTests :: Test -> [Test] Source #
Flatten a Test containing TestLists into a list of single tests.
filterTests :: (Test -> Bool) -> Test -> Test Source #
Filter TestLists in a Test, recursively, preserving the structure.
is :: (Eq a, Show a) => a -> a -> Assertion Source #
Simple way to assert something is some expected value, with no label.
assertParse :: (Show t, Show e) => Either (ParseError t e) a -> Assertion Source #
Assert a parse result is successful, printing the parse error on failure.
assertParseFailure :: Either (ParseError t e) a -> Assertion Source #
Assert a parse result is successful, printing the parse error on failure.
assertParseEqual :: (Show a, Eq a, Show t, Show e) => Either (ParseError t e) a -> a -> Assertion Source #
Assert a parse result is some expected value, printing the parse error on failure.
printParseError :: Show a => a -> IO () Source #
type SystemString = String Source #
A string received from or being passed to the operating system, such as a file path, command-line argument, or environment variable name or value. With GHC versions before 7.2 on some platforms (posix) these are typically encoded. When converting, we assume the encoding is UTF-8 (cf http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html#UTF8).
fromSystemString :: SystemString -> String Source #
Convert a system string to an ordinary string, decoding from UTF-8 if it appears to be UTF8-encoded and GHC version is less than 7.2.
toSystemString :: String -> SystemString Source #
Convert a unicode string to a system string, encoding with UTF-8 if we are on a posix platform with GHC < 7.2.
userError' :: String -> IOError Source #
A SystemString-aware version of userError.
usageError :: String -> a Source #
A SystemString-aware version of error that adds a usage hint.
type Replacement = String Source #
A replacement pattern. May include numeric backreferences (N).
Regular expression. Extended regular expression-ish syntax ? But does not support eg (?i) syntax.
regexReplaceBy :: Regexp -> (String -> String) -> String -> String Source #
Replace all occurrences of the regexp, transforming each match with the given function.
regexReplace :: Regexp -> Replacement -> String -> String Source #
Replace all occurrences of the regexp with the replacement pattern. The replacement pattern supports numeric backreferences (N) but no other RE syntax.
regexReplaceCI :: Regexp -> Replacement -> String -> String Source #
regexReplaceMemo :: Regexp -> Replacement -> String -> String Source #
A memoising version of regexReplace. Caches the result for each search pattern, replacement pattern, target string tuple.
regexReplaceCIMemo :: Regexp -> Replacement -> String -> String Source #
An efficient-to-build tree suggested by Cale Gibbard, probably better than accountNameTreeFrom.
Instances
Eq a => Eq (FastTree a) Source # | |
Ord a => Ord (FastTree a) Source # | |
Show a => Show (FastTree a) Source # | |
subtreeat :: Eq a => a -> Tree a -> Maybe (Tree a) Source #
get the sub-tree rooted at the first (left-most, depth-first) occurrence of the specified node value
subtreeinforest :: Eq a => a -> [Tree a] -> Maybe (Tree a) Source #
get the sub-tree for the specified node value in the first tree in forest in which it occurs.
treefilter :: (a -> Bool) -> Tree a -> Tree a Source #
remove all subtrees whose nodes do not fulfill predicate
treeFromPath :: [a] -> FastTree a Source #
treeFromPaths :: Ord a => [[a]] -> FastTree a Source #
A Ledger has the journal it derives from, and the accounts derived from that. Accounts are accessible both list-wise and tree-wise, since each one knows its parent and subs; the first account is the root of the tree and always exists.
data NormalBalance Source #
Whether an account's balance is normally a positive number (in accounting terms, normally a debit balance), as for asset and expense accounts, or a negative number (in accounting terms, normally a credit balance), as for liability, equity and income accounts. Cf https://en.wikipedia.org/wiki/Normal_balance .
Constructors
NormalPositive | normally debit - assets, expenses... |
NormalNegative | normally credit - liabilities, equity, income... |
Instances
Eq NormalBalance Source # | |
Defined in Hledger.Data.Types Methods (==) :: NormalBalance -> NormalBalance -> Bool # (/=) :: NormalBalance -> NormalBalance -> Bool # | |
Data NormalBalance Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NormalBalance -> c NormalBalance # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NormalBalance # toConstr :: NormalBalance -> Constr # dataTypeOf :: NormalBalance -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NormalBalance) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NormalBalance) # gmapT :: (forall b. Data b => b -> b) -> NormalBalance -> NormalBalance # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NormalBalance -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NormalBalance -> r # gmapQ :: (forall d. Data d => d -> u) -> NormalBalance -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NormalBalance -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NormalBalance -> m NormalBalance # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NormalBalance -> m NormalBalance # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NormalBalance -> m NormalBalance # | |
Show NormalBalance Source # | |
Defined in Hledger.Data.Types Methods showsPrec :: Int -> NormalBalance -> ShowS # show :: NormalBalance -> String # showList :: [NormalBalance] -> ShowS # |
An account, with name, balances and links to parent/subaccounts which let you walk up or down the account tree.
Constructors
Account | |
Fields
|
Instances
A hledger journal reader is a triple of storage format name, a detector of that format, and a parser from that format to Journal.
Constructors
Reader | |
type StorageFormat = String Source #
The id of a data format understood by hledger, eg journal
or csv
.
The --output-format option selects one of these for output.
type ParsedJournal = Journal Source #
A journal in the process of being parsed, not yet finalised. The data is partial, and list fields are in reverse order.
A Journal, containing transactions and various other things. The basic data model for hledger.
This is used during parsing (as the type alias ParsedJournal), and then finalised/validated for use as a Journal. Some extra parsing-related fields are included for convenience, at least for now. In a ParsedJournal these are updated as parsing proceeds, in a Journal they represent the final state at end of parsing (used eg by the add command).
Constructors
Journal | |
Fields
|
Instances
data MarketPrice Source #
Constructors
MarketPrice | |
Fields
|
Instances
data TimeclockEntry Source #
Constructors
TimeclockEntry | |
Fields |
Instances
data TimeclockCode Source #
Constructors
SetBalance | |
SetRequiredHours | |
In | |
Out | |
FinalOut |
Instances
data PeriodicTransaction Source #
Constructors
PeriodicTransaction | |
Fields
|
Instances
data ModifierTransaction Source #
Constructors
ModifierTransaction | |
Fields
|
Instances
data Transaction Source #
Constructors
Transaction | |
Fields
|
Instances
data GenericSourcePos Source #
The position of parse errors (eg), like parsec's SourcePos but generic.
Constructors
GenericSourcePos FilePath Int Int | name, 1-based line number and 1-based column number. |
JournalSourcePos FilePath (Int, Int) | file name, inclusive range of 1-based line numbers (first, last). |
Instances
Constructors
Posting | |
Fields
|
Instances
type BalanceAssertion = Maybe (Amount, GenericSourcePos) Source #
The status of a transaction or posting, recorded with a status mark (nothing, !, or *). What these mean is ultimately user defined.
Instances
Bounded Status Source # | |
Enum Status Source # | |
Defined in Hledger.Data.Types | |
Eq Status Source # | |
Data Status Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Status -> c Status # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Status # toConstr :: Status -> Constr # dataTypeOf :: Status -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Status) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Status) # gmapT :: (forall b. Data b => b -> b) -> Status -> Status # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Status -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Status -> r # gmapQ :: (forall d. Data d => d -> u) -> Status -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Status -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Status -> m Status # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Status -> m Status # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Status -> m Status # | |
Ord Status Source # | |
Show Status Source # | |
Generic Status Source # | |
NFData Status Source # | |
Defined in Hledger.Data.Types | |
type Rep Status Source # | |
Defined in Hledger.Data.Types |
data PostingType Source #
Constructors
RegularPosting | |
VirtualPosting | |
BalancedVirtualPosting |
Instances
Eq PostingType Source # | |
Defined in Hledger.Data.Types | |
Data PostingType Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PostingType -> c PostingType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PostingType # toConstr :: PostingType -> Constr # dataTypeOf :: PostingType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PostingType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PostingType) # gmapT :: (forall b. Data b => b -> b) -> PostingType -> PostingType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PostingType -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PostingType -> r # gmapQ :: (forall d. Data d => d -> u) -> PostingType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PostingType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PostingType -> m PostingType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PostingType -> m PostingType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PostingType -> m PostingType # | |
Show PostingType Source # | |
Defined in Hledger.Data.Types Methods showsPrec :: Int -> PostingType -> ShowS # show :: PostingType -> String # showList :: [PostingType] -> ShowS # | |
Generic PostingType Source # | |
Defined in Hledger.Data.Types Associated Types type Rep PostingType :: * -> * # | |
NFData PostingType Source # | |
Defined in Hledger.Data.Types Methods rnf :: PostingType -> () # | |
type Rep PostingType Source # | |
Defined in Hledger.Data.Types type Rep PostingType = D1 (MetaData "PostingType" "Hledger.Data.Types" "hledger-lib-1.5.1-hjHiqpNUpEEUpWQVlyvLX" False) (C1 (MetaCons "RegularPosting" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "VirtualPosting" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "BalancedVirtualPosting" PrefixI False) (U1 :: * -> *))) |
newtype MixedAmount Source #
Instances
Constructors
Amount | |
Fields
|
Instances
Eq Amount Source # | |
Data Amount Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Amount -> c Amount # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Amount # toConstr :: Amount -> Constr # dataTypeOf :: Amount -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Amount) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Amount) # gmapT :: (forall b. Data b => b -> b) -> Amount -> Amount # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Amount -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Amount -> r # gmapQ :: (forall d. Data d => d -> u) -> Amount -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Amount -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Amount -> m Amount # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Amount -> m Amount # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Amount -> m Amount # | |
Num Amount # | |
Ord Amount Source # | |
Show Amount # | |
Generic Amount Source # | |
NFData Amount Source # | |
Defined in Hledger.Data.Types | |
type Rep Amount Source # | |
Defined in Hledger.Data.Types type Rep Amount = D1 (MetaData "Amount" "Hledger.Data.Types" "hledger-lib-1.5.1-hjHiqpNUpEEUpWQVlyvLX" False) (C1 (MetaCons "Amount" PrefixI True) ((S1 (MetaSel (Just "acommodity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CommoditySymbol) :*: S1 (MetaSel (Just "aquantity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Quantity)) :*: (S1 (MetaSel (Just "aprice") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Price) :*: (S1 (MetaSel (Just "astyle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 AmountStyle) :*: S1 (MetaSel (Just "amultiplier") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))))) |
Constructors
Commodity | |
Fields |
Instances
Eq Commodity Source # | |
Data Commodity Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Commodity -> c Commodity # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Commodity # toConstr :: Commodity -> Constr # dataTypeOf :: Commodity -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Commodity) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Commodity) # gmapT :: (forall b. Data b => b -> b) -> Commodity -> Commodity # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Commodity -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Commodity -> r # gmapQ :: (forall d. Data d => d -> u) -> Commodity -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Commodity -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Commodity -> m Commodity # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Commodity -> m Commodity # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Commodity -> m Commodity # | |
Show Commodity Source # | |
Generic Commodity Source # | |
NFData Commodity Source # | |
Defined in Hledger.Data.Types | |
type Rep Commodity Source # | |
Defined in Hledger.Data.Types type Rep Commodity = D1 (MetaData "Commodity" "Hledger.Data.Types" "hledger-lib-1.5.1-hjHiqpNUpEEUpWQVlyvLX" False) (C1 (MetaCons "Commodity" PrefixI True) (S1 (MetaSel (Just "csymbol") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CommoditySymbol) :*: S1 (MetaSel (Just "cformat") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe AmountStyle)))) |
type CommoditySymbol = Text Source #
data DigitGroupStyle Source #
A style for displaying digit groups in the integer part of a floating point number. It consists of the character used to separate groups (comma or period, whichever is not used as decimal point), and the size of each group, starting with the one nearest the decimal point. The last group size is assumed to repeat. Eg, comma between thousands is DigitGroups ',' [3].
Constructors
DigitGroups Char [Int] |
Instances
data AmountStyle Source #
Display style for an amount.
Constructors
AmountStyle | |
Fields
|
Instances
An amount's price (none, per unit, or total) in another commodity. Note the price should be a positive number, although this is not enforced.
Constructors
NoPrice | |
UnitPrice Amount | |
TotalPrice Amount |
Instances
Eq Price Source # | |
Data Price Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Price -> c Price # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Price # dataTypeOf :: Price -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Price) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Price) # gmapT :: (forall b. Data b => b -> b) -> Price -> Price # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Price -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Price -> r # gmapQ :: (forall d. Data d => d -> u) -> Price -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Price -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Price -> m Price # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Price -> m Price # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Price -> m Price # | |
Ord Price Source # | |
Generic Price Source # | |
NFData Price Source # | |
Defined in Hledger.Data.Types | |
type Rep Price Source # | |
Defined in Hledger.Data.Types type Rep Price = D1 (MetaData "Price" "Hledger.Data.Types" "hledger-lib-1.5.1-hjHiqpNUpEEUpWQVlyvLX" False) (C1 (MetaCons "NoPrice" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "UnitPrice" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Amount)) :+: C1 (MetaCons "TotalPrice" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Amount)))) |
Instances
Eq Side Source # | |
Data Side Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Side -> c Side # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Side # dataTypeOf :: Side -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Side) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Side) # gmapT :: (forall b. Data b => b -> b) -> Side -> Side # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Side -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Side -> r # gmapQ :: (forall d. Data d => d -> u) -> Side -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Side -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Side -> m Side # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Side -> m Side # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Side -> m Side # | |
Ord Side Source # | |
Read Side Source # | |
Show Side Source # | |
Generic Side Source # | |
NFData Side Source # | |
Defined in Hledger.Data.Types | |
type Rep Side Source # | |
data AccountAlias Source #
Constructors
BasicAlias AccountName AccountName | |
RegexAlias Regexp Replacement |
Instances
type AccountName = Text Source #
Constructors
NoInterval | |
Days Int | |
Weeks Int | |
Months Int | |
Quarters Int | |
Years Int | |
DayOfMonth Int | |
WeekdayOfMonth Int Int | |
DayOfWeek Int | |
DayOfYear Int Int |
Instances
Constructors
DayPeriod Day | |
WeekPeriod Day | |
MonthPeriod Year Month | |
QuarterPeriod Year Quarter | |
YearPeriod Year | |
PeriodBetween Day Day | |
PeriodFrom Day | |
PeriodTo Day | |
PeriodAll |
Instances
Instances
Eq DateSpan Source # | |
Data DateSpan Source # | |
Defined in Hledger.Data.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DateSpan -> c DateSpan # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DateSpan # toConstr :: DateSpan -> Constr # dataTypeOf :: DateSpan -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DateSpan) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DateSpan) # gmapT :: (forall b. Data b => b -> b) -> DateSpan -> DateSpan # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DateSpan -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DateSpan -> r # gmapQ :: (forall d. Data d => d -> u) -> DateSpan -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DateSpan -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DateSpan -> m DateSpan # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DateSpan -> m DateSpan # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DateSpan -> m DateSpan # | |
Ord DateSpan Source # | |
Defined in Hledger.Data.Types | |
Show DateSpan # | |
Generic DateSpan Source # | |
Default DateSpan Source # | |
Defined in Hledger.Data.Types | |
NFData DateSpan Source # | |
Defined in Hledger.Data.Types | |
type Rep DateSpan Source # | |
Defined in Hledger.Data.Types type Rep DateSpan = D1 (MetaData "DateSpan" "Hledger.Data.Types" "hledger-lib-1.5.1-hjHiqpNUpEEUpWQVlyvLX" False) (C1 (MetaCons "DateSpan" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Day)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Day)))) |
Constructors
PrimaryDate | |
SecondaryDate |
periodAsDateSpan :: Period -> DateSpan Source #
Convert Periods to DateSpans.
>>>
periodAsDateSpan (MonthPeriod 2000 1) == DateSpan (Just $ fromGregorian 2000 1 1) (Just $ fromGregorian 2000 2 1)
True
dateSpanAsPeriod :: DateSpan -> Period Source #
Convert DateSpans to Periods.
>>>
dateSpanAsPeriod $ DateSpan (Just $ fromGregorian 2000 1 1) (Just $ fromGregorian 2000 2 1)
MonthPeriod 2000 1
simplifyPeriod :: Period -> Period Source #
Convert PeriodBetweens to a more abstract period where possible.
>>>
simplifyPeriod $ PeriodBetween (fromGregorian 1 1 1) (fromGregorian 2 1 1)
YearPeriod 1>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2000 10 1) (fromGregorian 2001 1 1)
QuarterPeriod 2000 4>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2000 2 1) (fromGregorian 2000 3 1)
MonthPeriod 2000 2>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2016 7 25) (fromGregorian 2016 8 1)
WeekPeriod 2016-07-25>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2000 1 1) (fromGregorian 2000 1 2)
DayPeriod 2000-01-01>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2000 2 28) (fromGregorian 2000 3 1)
PeriodBetween 2000-02-28 2000-03-01>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2000 2 29) (fromGregorian 2000 3 1)
DayPeriod 2000-02-29>>>
simplifyPeriod $ PeriodBetween (fromGregorian 2000 12 31) (fromGregorian 2001 1 1)
DayPeriod 2000-12-31
isStandardPeriod :: Period -> Bool Source #
Is this period a "standard" period, referencing a particular day, week, month, quarter, or year ? Periods of other durations, or infinite duration, or not starting on a standard period boundary, are not.
showPeriod :: Period -> String Source #
Render a period as a compact display string suitable for user output.
>>>
showPeriod (WeekPeriod (fromGregorian 2016 7 25))
"2016/07/25w30"
periodNext :: Period -> Period Source #
Move a standard period to the following period of same duration. Non-standard periods are unaffected.
periodPrevious :: Period -> Period Source #
Move a standard period to the preceding period of same duration. Non-standard periods are unaffected.
periodNextIn :: DateSpan -> Period -> Period Source #
Move a standard period to the following period of same duration, staying within enclosing dates. Non-standard periods are unaffected.
periodPreviousIn :: DateSpan -> Period -> Period Source #
Move a standard period to the preceding period of same duration, staying within enclosing dates. Non-standard periods are unaffected.
periodMoveTo :: Day -> Period -> Period Source #
Move a standard period stepwise so that it encloses the given date. Non-standard periods are unaffected.
periodGrow :: Period -> Period Source #
Enlarge a standard period to the next larger enclosing standard period, if there is one. Eg, a day becomes the enclosing week. A week becomes whichever month the week's thursday falls into. A year becomes all (unlimited). Non-standard periods (arbitrary dates, or open-ended) are unaffected.
periodShrink :: Day -> Period -> Period Source #
Shrink a period to the next smaller standard period inside it, choosing the subperiod which contains today's date if possible, otherwise the first subperiod. It goes like this: unbounded periods and nonstandard periods (between two arbitrary dates) -> current year -> current quarter if it's in selected year, otherwise first quarter of selected year -> current month if it's in selected quarter, otherwise first month of selected quarter -> current week if it's in selected month, otherwise first week of selected month -> today if it's in selected week, otherwise first day of selected week, unless that's in previous month, in which case first day of month containing selected week. Shrinking a day has no effect.
mondayBefore :: Day -> Day Source #
quarterContainingMonth :: Integral a => a -> a Source #
firstMonthOfQuarter :: Num a => a -> a Source #
type ErroringJournalParser m a = StateT Journal (ParsecT MPErr Text (ExceptT String m)) a Source #
A parser of text in some monad, with a journal as state, that can throw an error string mid-parse.
type JournalParser m a = StateT Journal (ParsecT MPErr Text m) a Source #
A parser of text in some monad, with a journal as state.
choice' :: [TextParser m a] -> TextParser m a Source #
Backtracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail.
choiceInState :: [StateT s (ParsecT MPErr Text m) a] -> StateT s (ParsecT MPErr Text m) a Source #
Backtracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail.
surroundedBy :: Applicative m => m openclose -> m a -> m a Source #
parsewithString :: Parsec e String a -> String -> Either (ParseError Char e) a Source #
parseWithState :: Monad m => st -> StateT st (ParsecT MPErr Text m) a -> Text -> m (Either (ParseError Char MPErr) a) Source #
parseWithState' :: Stream s => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseError (Token s) e) a Source #
parseerror :: (Show t, Show e) => ParseError t e -> a Source #
showParseError :: (Show t, Show e) => ParseError t e -> String Source #
showDateParseError :: (Show t, Show e) => ParseError t e -> String Source #
nonspace :: TextParser m Char Source #
restofline :: TextParser m String Source #
eolof :: TextParser m () Source #
stripbrackets :: String -> String Source #
formatString :: Bool -> Maybe Int -> Maybe Int -> String -> String Source #
Clip and pad a string to a minimum & maximum width, andor leftright justify it. Works on multi-line strings too (but will rewrite non-unix line endings).
quoteIfNeeded :: String -> String Source #
Double-quote this string if it contains whitespace, single quotes or double-quotes, escaping the quotes as needed.
singleQuoteIfNeeded :: String -> String Source #
Single-quote this string if it contains whitespace or double-quotes. No good for strings containing single quotes.
escapeQuotes :: String -> String Source #
words' :: String -> [String] Source #
Quote-aware version of words - don't split on spaces which are inside quotes.
NB correctly handles "a'b" but not "'a'
". Can raise an error if parsing fails.
unwords' :: [String] -> String Source #
Quote-aware version of unwords - single-quote strings which contain whitespace
concatTopPadded :: [String] -> String Source #
Join several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width.
concatBottomPadded :: [String] -> String Source #
Join several multi-line strings as side-by-side rectangular strings of the same height, bottom-padded. Treats wide characters as double width.
concatOneLine :: [String] -> String Source #
Join multi-line strings horizontally, after compressing each of them to a single line with a comma and space between each original line.
vConcatLeftAligned :: [String] -> String Source #
Join strings vertically, left-aligned and right-padded.
vConcatRightAligned :: [String] -> String Source #
Join strings vertically, right-aligned and left-padded.
padtop :: Int -> String -> String Source #
Convert a multi-line string to a rectangular string top-padded to the specified height.
padbottom :: Int -> String -> String Source #
Convert a multi-line string to a rectangular string bottom-padded to the specified height.
padleft :: Int -> String -> String Source #
Convert a multi-line string to a rectangular string left-padded to the specified width. Treats wide characters as double width.
padright :: Int -> String -> String Source #
Convert a multi-line string to a rectangular string right-padded to the specified width. Treats wide characters as double width.
cliptopleft :: Int -> Int -> String -> String Source #
Clip a multi-line string to the specified width and height from the top left.
fitto :: Int -> Int -> String -> String Source #
Clip and pad a multi-line string to fill the specified width and height.
fitString :: Maybe Int -> Maybe Int -> Bool -> Bool -> String -> String Source #
General-purpose wide-char-aware single-line string layout function. It can left- or right-pad a short string to a minimum width. It can left- or right-clip a long string to a maximum width, optionally inserting an ellipsis (the third argument). It clips and pads on the right when the fourth argument is true, otherwise on the left. It treats wide characters as double width.
fitStringMulti :: Maybe Int -> Maybe Int -> Bool -> Bool -> String -> String Source #
A version of fitString that works on multi-line strings, separate for now to avoid breakage. This will rewrite any line endings to unix newlines.
padLeftWide :: Int -> String -> String Source #
Left-pad a string to the specified width. Treats wide characters as double width. Works on multi-line strings too (but will rewrite non-unix line endings).
padRightWide :: Int -> String -> String Source #
Right-pad a string to the specified width. Treats wide characters as double width. Works on multi-line strings too (but will rewrite non-unix line endings).
takeWidth :: Int -> String -> String Source #
Double-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg takeWidth 3 "りんご" = "り".
strWidth :: String -> Int Source #
Calculate the render width of a string, considering wide characters (counted as double width), ANSI escape codes (not counted), and line breaks (in a multi-line string, the longest line determines the width).
charWidth :: Char -> Int Source #
Get the designated render width of a character: 0 for a combining character, 1 for a regular character, 2 for a wide character. (Wide characters are rendered as exactly double width in apps and fonts that support it.) (From Pandoc.)
textlstrip :: Text -> Text Source #
Remove leading whitespace.
textrstrip :: Text -> Text Source #
Remove trailing whitespace.
quoteIfSpaced :: Text -> Text Source #
Wrap a string in double quotes, and -prefix any embedded single quotes, if it contains whitespace and is not already single- or double-quoted.
quotechars :: [Char] Source #
whitespacechars :: [Char] Source #
escapeDoubleQuotes :: Text -> Text Source #
escapeSingleQuotes :: Text -> Text Source #
stripquotes :: Text -> Text Source #
Strip one matching pair of single or double quotes on the ends of a string.
isSingleQuoted :: Text -> Bool Source #
isDoubleQuoted :: Text -> Bool Source #
textUnbracket :: Text -> Text Source #
textConcatTopPadded :: [Text] -> Text Source #
Join several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width.
difforzero :: (Num a, Ord a) => a -> a -> a Source #
fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text Source #
General-purpose wide-char-aware single-line text layout function. It can left- or right-pad a short string to a minimum width. It can left- or right-clip a long string to a maximum width, optionally inserting an ellipsis (the third argument). It clips and pads on the right when the fourth argument is true, otherwise on the left. It treats wide characters as double width.
textPadLeftWide :: Int -> Text -> Text Source #
Left-pad a text to the specified width. Treats wide characters as double width. Works on multi-line texts too (but will rewrite non-unix line endings).
textPadRightWide :: Int -> Text -> Text Source #
Right-pad a string to the specified width. Treats wide characters as double width. Works on multi-line strings too (but will rewrite non-unix line endings).
textTakeWidth :: Int -> Text -> Text Source #
Double-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg textTakeWidth 3 "りんご" = "り".
textWidth :: Text -> Int Source #
Calculate the designated render width of a string, taking into account wide characters and line breaks (the longest line within a multi-line string determines the width ).
traceWith :: (a -> String) -> a -> a Source #
Trace (print to stderr) a showable value using a custom show function.
ptrace :: String -> TextParser m () Source #
Parsec trace - show the current parsec position and next input, and the provided label if it's non-null.
debugLevel :: Int Source #
Global debug level, which controls the verbosity of debug output
on the console. The default is 0 meaning no debug output. The
--debug
command line flag sets it to 1, or --debug=N
sets it to
a higher value (note: not --debug N
for some reason). This uses
unsafePerformIO and can be accessed from anywhere and before normal
command-line processing. When running with :main in GHCI, you must
touch and reload this module to see the effect of a new --debug option.
After command-line processing, it is also available as the debug_
field of CliOpts
.
{--}
{--}
dbg1 :: Show a => String -> a -> a Source #
Pretty-print a message and the showable value to the console when the debug level is >= 1, then return it. Uses unsafePerformIO.
dbg0IO :: (MonadIO m, Show a) => String -> a -> m () Source #
Convenience aliases for tracePrettyAtIO. Like dbg, but convenient to insert in an IO monad. XXX These have a bug; they should use traceIO, not trace, otherwise GHC can occasionally over-optimise (cf lpaste a few days ago where it killed/blocked a child thread).
tracePrettyAt :: Show a => Int -> String -> a -> a Source #
Pretty-print a message and a showable value to the console if the debug level is at or above the specified level. At level 0, always prints. Otherwise, uses unsafePerformIO.
logPrettyAt :: Show a => Int -> String -> a -> a Source #
Log a message and a pretty-printed showable value to ./debug.log, if the debug level is at or above the specified level. At level 0, always logs. Otherwise, uses unsafePerformIO.
dbgppshow :: Show a => Int -> String -> a -> a Source #
print this string to the console before evaluating the expression, if the global debug level is at or above the specified level. Uses unsafePerformIO. dbgtrace :: Int -> String -> a -> a dbgtrace level | debugLevel >= level = trace | otherwise = flip const
Print a showable value to the console, with a message, if the debug level is at or above the specified level (uses unsafePerformIO). Values are displayed with show, all on one line, which is hard to read. dbgshow :: Show a => Int -> String -> a -> a dbgshow level | debugLevel >= level = ltrace | otherwise = flip const
Print a showable value to the console, with a message, if the debug level is at or above the specified level (uses unsafePerformIO). Values are displayed with ppShow, each field/constructor on its own line.
dbgExit :: Show a => String -> a -> a Source #
Like dbg, then exit the program. Uses unsafePerformIO.
pdbg :: Int -> String -> TextParser m () Source #
Print a message and parsec debug info (parse position and next input) to the console when the debug level is at or above this level. Uses unsafePerformIO. pdbgAt :: GenParser m => Float -> String -> m ()
dbglog :: Show a => String -> a -> a Source #
Like dbg, but writes the output to "debug.log" in the current directory. Uses unsafePerformIO. Can fail due to log file contention if called too quickly ("*** Exception: debug.log: openFile: resource busy (file is locked)").
splitAtElement :: Eq a => a -> [a] -> [[a]] Source #
applyN :: Int -> (a -> a) -> a -> a Source #
Apply a function the specified number of times. Possibly uses O(n) stack ?
expandPath :: FilePath -> FilePath -> IO FilePath Source #
Convert a possibly relative, possibly tilde-containing file path to an absolute one, given the current directory. ~username is not supported. Leave "-" unchanged. Can raise an error.
readFile' :: FilePath -> IO Text Source #
Read a file in universal newline mode, handling any of the usual line ending conventions.
readFileAnyLineEnding :: FilePath -> IO Text Source #
Read a file in universal newline mode, handling any of the usual line ending conventions.
readFileOrStdinAnyLineEnding :: String -> IO Text Source #
Read the given file, or standard input if the path is "-", using universal newline mode.
maximum' :: Integral a => [a] -> a Source #
Total version of maximum, for integral types, giving 0 for an empty list.
maximumStrict :: Ord a => [a] -> a Source #
Strict version of maximum that doesn’t leak space
minimumStrict :: Ord a => [a] -> a Source #
Strict version of minimum that doesn’t leak space
sequence' :: Monad f => [f a] -> f [a] Source #
This is a version of sequence based on difference lists. It is slightly faster but we mostly use it because it uses the heap instead of the stack. This has the advantage that Neil Mitchell’s trick of limiting the stack size to discover space leaks doesn’t show this as a false positive.
type RawOpts = [(String, String)] Source #
The result of running cmdargs: an association list of option names to string values.
commoditysymbols :: [(String, CommoditySymbol)] Source #
comm :: String -> CommoditySymbol Source #
Look up one of the sample commodities' symbol by name.
conversionRate :: CommoditySymbol -> CommoditySymbol -> Double Source #
Find the conversion rate between two commodities. Currently returns 1.
missingamt :: Amount Source #
A temporary value for parsed transactions which had no amount specified.
amountWithCommodity :: CommoditySymbol -> Amount -> Amount Source #
Convert an amount to the specified commodity, ignoring and discarding any assigned prices and assuming an exchange rate of 1.
costOfAmount :: Amount -> Amount Source #
Convert an amount to the commodity of its assigned price, if any. Notes:
- price amounts must be MixedAmounts with exactly one component Amount (or there will be a runtime error) XXX
- price amounts should be positive, though this is not currently enforced
isNegativeAmount :: Amount -> Bool Source #
Is this amount negative ? The price is ignored.
isZeroAmount :: Amount -> Bool Source #
Does this amount appear to be zero when displayed with its given precision ?
isReallyZeroAmount :: Amount -> Bool Source #
Is this amount "really" zero, regardless of the display precision ?
showAmountDebug :: Amount -> String Source #
Get a string representation of an amount for debugging, appropriate to the current debug level. 9 shows maximum detail.
showAmountWithoutPrice :: Amount -> String Source #
Get the string representation of an amount, without any @ price.
showAmount :: Amount -> String Source #
Get the string representation of an amount, based on its commodity's display settings. String representations equivalent to zero are converted to just "0". The special "missing" amount is displayed as the empty string.
cshowAmount :: Amount -> String Source #
Colour version. For a negative amount, adds ANSI codes to change the colour, currently to hard-coded red.
showAmountWithZeroCommodity :: Amount -> String Source #
Like showAmount, but show a zero amount's commodity if it has one.
maxprecision :: Int Source #
For rendering: a special precision value which means show all available digits.
maxprecisionwithpoint :: Int Source #
For rendering: a special precision value which forces display of a decimal point.
canonicaliseAmount :: Map CommoditySymbol AmountStyle -> Amount -> Amount Source #
Canonicalise an amount's display style using the provided commodity style map.
amountValue :: Journal -> Day -> Amount -> Amount Source #
Find the market value of this amount on the given date, in it's default valuation commodity, based on recorded market prices. If no default valuation commodity can be found, the amount is left unchanged.
nullmixedamt :: MixedAmount Source #
The empty mixed amount.
missingmixedamt :: MixedAmount Source #
A temporary value for parsed transactions which had no amount specified.
mixed :: [Amount] -> MixedAmount Source #
Convert amounts in various commodities into a normalised MixedAmount.
normaliseMixedAmount :: MixedAmount -> MixedAmount Source #
Simplify a mixed amount's component amounts:
- amounts in the same commodity are combined unless they have different prices or total prices
- multiple zero amounts, all with the same non-null commodity, are replaced by just the last of them, preserving the commodity and amount style (all but the last zero amount are discarded)
- multiple zero amounts with multiple commodities, or no commodities, are replaced by one commodity-less zero amount
- an empty amount list is replaced by one commodity-less zero amount
- the special "missing" mixed amount remains unchanged
normaliseMixedAmountSquashPricesForDisplay :: MixedAmount -> MixedAmount Source #
Like normaliseMixedAmount, but combine each commodity's amounts into just one by throwing away all prices except the first. This is only used as a rendering helper, and could show a misleading price.
amounts :: MixedAmount -> [Amount] Source #
Get a mixed amount's component amounts.
filterMixedAmount :: (Amount -> Bool) -> MixedAmount -> MixedAmount Source #
Filter a mixed amount's component amounts by a predicate.
filterMixedAmountByCommodity :: CommoditySymbol -> MixedAmount -> MixedAmount Source #
Return an unnormalised MixedAmount containing exactly one Amount with the specified commodity and the quantity of that commodity found in the original. NB if Amount's quantity is zero it will be discarded next time the MixedAmount gets normalised.
costOfMixedAmount :: MixedAmount -> MixedAmount Source #
Convert a mixed amount's component amounts to the commodity of their assigned price, if any.
divideMixedAmount :: MixedAmount -> Quantity -> MixedAmount Source #
Divide a mixed amount's quantities by a constant.
averageMixedAmounts :: [MixedAmount] -> MixedAmount Source #
Calculate the average of some mixed amounts.
isNegativeMixedAmount :: MixedAmount -> Maybe Bool Source #
Is this mixed amount negative, if it can be normalised to a single commodity ?
isZeroMixedAmount :: MixedAmount -> Bool Source #
Does this mixed amount appear to be zero when displayed with its given precision ?
isReallyZeroMixedAmount :: MixedAmount -> Bool Source #
Is this mixed amount "really" zero ? See isReallyZeroAmount.
isReallyZeroMixedAmountCost :: MixedAmount -> Bool Source #
Is this mixed amount "really" zero, after converting to cost commodities where possible ?
showMixedAmount :: MixedAmount -> String Source #
Get the string representation of a mixed amount, after normalising it to one amount per commodity. Assumes amounts have no or similar prices, otherwise this can show misleading prices.
showMixedAmountWithZeroCommodity :: MixedAmount -> String Source #
Like showMixedAmount, but zero amounts are shown with their commodity if they have one.
showMixedAmountOneLine :: MixedAmount -> String Source #
Get the one-line string representation of a mixed amount.
ltraceamount :: String -> MixedAmount -> MixedAmount Source #
Compact labelled trace of a mixed amount, for debugging.
setMixedAmountPrecision :: Int -> MixedAmount -> MixedAmount Source #
Set the display precision in the amount's commodities.
showMixedAmountWithPrecision :: Int -> MixedAmount -> String Source #
Get the string representation of a mixed amount, showing each of its component amounts with the specified precision, ignoring their commoditys' display precision settings.
showMixedAmountDebug :: MixedAmount -> String Source #
Get an unambiguous string representation of a mixed amount for debugging.
showMixedAmountWithoutPrice :: MixedAmount -> String Source #
Get the string representation of a mixed amount, but without any @ prices.
cshowMixedAmountWithoutPrice :: MixedAmount -> String Source #
Colour version.
showMixedAmountOneLineWithoutPrice :: MixedAmount -> String Source #
Get the one-line string representation of a mixed amount, but without any @ prices.
cshowMixedAmountOneLineWithoutPrice :: MixedAmount -> String Source #
Colour version.
canonicaliseMixedAmount :: Map CommoditySymbol AmountStyle -> MixedAmount -> MixedAmount Source #
Canonicalise a mixed amount's display styles using the provided commodity style map.
mixedAmountValue :: Journal -> Day -> MixedAmount -> MixedAmount Source #
acctsepchar :: Char Source #
accountNameComponents :: AccountName -> [Text] Source #
accountNameFromComponents :: [Text] -> AccountName Source #
accountLeafName :: AccountName -> Text Source #
accountSummarisedName :: AccountName -> Text Source #
Truncate all account name components but the last to two characters.
accountNameLevel :: AccountName -> Int Source #
accountNameDrop :: Int -> AccountName -> AccountName Source #
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"]
expandAccountName :: AccountName -> [AccountName] Source #
"a:b:c" -> ["a","a:b","a:b:c"]
topAccountNames :: [AccountName] -> [AccountName] Source #
- "a:b:c","d:e"
- -> ["a","d"]
parentAccountNames :: AccountName -> [AccountName] Source #
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 #
subAccountNamesFrom :: [AccountName] -> AccountName -> [AccountName] Source #
From a list of account names, select those which are direct subaccounts of the given account name.
accountNameTreeFrom :: [AccountName] -> Tree AccountName Source #
Convert a list of account names to a tree.
nullaccountnametree :: IsString a => Tree a Source #
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!
clipAccountName :: Int -> AccountName -> AccountName Source #
Keep only the first n components of an account name, where n is a positive integer. If n is 0, returns the empty string.
clipOrEllipsifyAccountName :: Int -> AccountName -> AccountName Source #
Keep only the first n components of an account name, where n is a positive integer. If n is 0, returns "...".
escapeName :: AccountName -> Regexp Source #
accountNameToAccountRegex :: AccountName -> Regexp Source #
Convert an account name to a regular expression matching it and its subaccounts.
accountNameToAccountOnlyRegex :: AccountName -> Regexp Source #
Convert an account name to a regular expression matching it but not its subaccounts.
accountRegexToAccountName :: Regexp -> AccountName Source #
Convert an exact account-matching regular expression to a plain account name.
isAccountRegex :: String -> Bool Source #
Does this string look like an exact account-matching regular expression ?
data ReportItemField Source #
An id identifying which report item field to interpolate. These are drawn from several hledger report types, so are not all applicable for a given report.
Constructors
AccountField | A posting or balance report item's account name |
DefaultDateField | A posting or register or entry report item's date |
DescriptionField | A posting or register or entry report item's description |
TotalField | A balance or posting report item's balance or running total. Always rendered right-justified. |
DepthSpacerField | A balance report item's indent level (which may be different from the account name depth). Rendered as this number of spaces, multiplied by the minimum width spec if any. |
FieldNo Int | A report item's nth field. May be unimplemented. |
Instances
Eq ReportItemField Source # | |
Defined in Hledger.Data.StringFormat Methods (==) :: ReportItemField -> ReportItemField -> Bool # (/=) :: ReportItemField -> ReportItemField -> Bool # | |
Show ReportItemField Source # | |
Defined in Hledger.Data.StringFormat Methods showsPrec :: Int -> ReportItemField -> ShowS # show :: ReportItemField -> String # showList :: [ReportItemField] -> ShowS # |
data StringFormatComponent Source #
Constructors
FormatLiteral String | Literal text to be rendered as-is |
FormatField Bool (Maybe Int) (Maybe Int) ReportItemField | A data field to be formatted and interpolated. Parameters:
|
Instances
Eq StringFormatComponent Source # | |
Defined in Hledger.Data.StringFormat Methods (==) :: StringFormatComponent -> StringFormatComponent -> Bool # (/=) :: StringFormatComponent -> StringFormatComponent -> Bool # | |
Show StringFormatComponent Source # | |
Defined in Hledger.Data.StringFormat Methods showsPrec :: Int -> StringFormatComponent -> ShowS # show :: StringFormatComponent -> String # showList :: [StringFormatComponent] -> ShowS # |
data StringFormat Source #
A format specification/template to use when rendering a report line item as text.
A format is a sequence of components; each is either a literal string, or a hledger report item field with specified width and justification whose value will be interpolated at render time.
A component's value may be a multi-line string (or a multi-commodity amount), in which case the final string will be either single-line or a top or bottom-aligned multi-line string depending on the StringFormat variant used.
Currently this is only used in the balance command's single-column mode, which provides a limited StringFormat renderer.
Constructors
OneLine [StringFormatComponent] | multi-line values will be rendered on one line, comma-separated |
TopAligned [StringFormatComponent] | values will be top-aligned (and bottom-padded to the same height) |
BottomAligned [StringFormatComponent] | values will be bottom-aligned (and top-padded) |
Instances
Eq StringFormat Source # | |
Defined in Hledger.Data.StringFormat | |
Show StringFormat Source # | |
Defined in Hledger.Data.StringFormat Methods showsPrec :: Int -> StringFormat -> ShowS # show :: StringFormat -> String # showList :: [StringFormat] -> ShowS # |
parseStringFormat :: String -> Either String StringFormat Source #
Parse a string format specification, or return a parse error.
showDateSpan :: DateSpan -> String Source #
Render a datespan as a display string, abbreviating into a compact form if possible.
getCurrentDay :: IO Day Source #
Get the current local date.
getCurrentMonth :: IO Int Source #
Get the current local month number.
getCurrentYear :: IO Integer Source #
Get the current local year.
elapsedSeconds :: Fractional a => UTCTime -> UTCTime -> a Source #
spansSpan :: [DateSpan] -> DateSpan Source #
Get overall span enclosing multiple sequentially ordered spans.
splitSpan :: Interval -> DateSpan -> [DateSpan] Source #
Split a DateSpan into one or more consecutive whole spans of the specified length which enclose it. If no interval is specified, the original span is returned.
Examples:
>>>
let t i d1 d2 = splitSpan i $ mkdatespan d1 d2
>>>
t NoInterval "2008/01/01" "2009/01/01"
[DateSpan 2008]>>>
t (Quarters 1) "2008/01/01" "2009/01/01"
[DateSpan 2008q1,DateSpan 2008q2,DateSpan 2008q3,DateSpan 2008q4]>>>
splitSpan (Quarters 1) nulldatespan
[DateSpan -]>>>
t (Days 1) "2008/01/01" "2008/01/01" -- an empty datespan
[DateSpan 2008/01/01-2007/12/31]>>>
t (Quarters 1) "2008/01/01" "2008/01/01"
[DateSpan 2008/01/01-2007/12/31]>>>
t (Months 1) "2008/01/01" "2008/04/01"
[DateSpan 2008/01,DateSpan 2008/02,DateSpan 2008/03]>>>
t (Months 2) "2008/01/01" "2008/04/01"
[DateSpan 2008/01/01-2008/02/29,DateSpan 2008/03/01-2008/04/30]>>>
t (Weeks 1) "2008/01/01" "2008/01/15"
[DateSpan 2007/12/31w01,DateSpan 2008/01/07w02,DateSpan 2008/01/14w03]>>>
t (Weeks 2) "2008/01/01" "2008/01/15"
[DateSpan 2007/12/31-2008/01/13,DateSpan 2008/01/14-2008/01/27]>>>
t (DayOfMonth 2) "2008/01/01" "2008/04/01"
[DateSpan 2007/12/02-2008/01/01,DateSpan 2008/01/02-2008/02/01,DateSpan 2008/02/02-2008/03/01,DateSpan 2008/03/02-2008/04/01]>>>
t (WeekdayOfMonth 2 4) "2011/01/01" "2011/02/15"
[DateSpan 2010/12/09-2011/01/12,DateSpan 2011/01/13-2011/02/09,DateSpan 2011/02/10-2011/03/09]>>>
t (DayOfWeek 2) "2011/01/01" "2011/01/15"
[DateSpan 2010/12/28-2011/01/03,DateSpan 2011/01/04-2011/01/10,DateSpan 2011/01/11-2011/01/17]>>>
t (DayOfYear 11 29) "2011/10/01" "2011/10/15"
[DateSpan 2010/11/29-2011/11/28]>>>
t (DayOfYear 11 29) "2011/12/01" "2012/12/15"
[DateSpan 2011/11/29-2012/11/28,DateSpan 2012/11/29-2013/11/28]
daysInSpan :: DateSpan -> Maybe Integer Source #
Count the days in a DateSpan, or if it is open-ended return Nothing.
periodContainsDate :: Period -> Day -> Bool Source #
Does the period include the given date ? (Here to avoid import cycle).
spansIntersect :: [DateSpan] -> DateSpan Source #
Calculate the intersection of a number of datespans.
spanIntersect :: DateSpan -> DateSpan -> DateSpan Source #
Calculate the intersection of two datespans.
spanDefaultsFrom :: DateSpan -> DateSpan -> DateSpan Source #
Fill any unspecified dates in the first span with the dates from the second one. Sort of a one-way spanIntersect.
spansUnion :: [DateSpan] -> DateSpan Source #
Calculate the union of a number of datespans.
parsePeriodExpr :: Day -> Text -> Either (ParseError Char MPErr) (Interval, DateSpan) Source #
Parse a period expression to an Interval and overall DateSpan using the provided reference date, or return a parse error.
fixSmartDateStr :: Day -> Text -> String Source #
Convert a smart date string to an explicit yyyy/mm/dd string using the provided reference date, or raise an error.
fixSmartDateStrEither :: Day -> Text -> Either (ParseError Char MPErr) String Source #
A safe version of fixSmartDateStr.
fixSmartDateStrEither' :: Day -> Text -> Either (ParseError Char MPErr) Day Source #
fixSmartDate :: Day -> SmartDate -> Day Source #
Convert a SmartDate to an absolute date using the provided reference date.
Examples:
>>>
:set -XOverloadedStrings
>>>
let t = fixSmartDateStr (parsedate "2008/11/26")
>>>
t "0000-01-01"
"0000/01/01">>>
t "1999-12-02"
"1999/12/02">>>
t "1999.12.02"
"1999/12/02">>>
t "1999/3/2"
"1999/03/02">>>
t "19990302"
"1999/03/02">>>
t "2008/2"
"2008/02/01">>>
t "0020/2"
"0020/02/01">>>
t "1000"
"1000/01/01">>>
t "4/2"
"2008/04/02">>>
t "2"
"2008/11/02">>>
t "January"
"2008/01/01">>>
t "feb"
"2008/02/01">>>
t "today"
"2008/11/26">>>
t "yesterday"
"2008/11/25">>>
t "tomorrow"
"2008/11/27">>>
t "this day"
"2008/11/26">>>
t "last day"
"2008/11/25">>>
t "next day"
"2008/11/27">>>
t "this week" -- last monday
"2008/11/24">>>
t "last week" -- previous monday
"2008/11/17">>>
t "next week" -- next monday
"2008/12/01">>>
t "this month"
"2008/11/01">>>
t "last month"
"2008/10/01">>>
t "next month"
"2008/12/01">>>
t "this quarter"
"2008/10/01">>>
t "last quarter"
"2008/07/01">>>
t "next quarter"
"2009/01/01">>>
t "this year"
"2008/01/01">>>
t "last year"
"2007/01/01">>>
t "next year"
"2009/01/01"
t "last wed" "20081119" t "next friday" "20081128" t "next january" "20090101"
parsedate :: String -> Day Source #
Parse a YYYY-MM-DD or YYYYMMDD date string to a Day, or raise an error. For testing/debugging.
>>>
parsedate "2008/02/03"
2008-02-03
smartdate :: SimpleTextParser SmartDate Source #
Parse a date in any of the formats allowed in ledger's period expressions, and maybe some others:
2004 2004/10 2004/10/1 10/1 21 october, oct yesterday, today, tomorrow this/next/last week/day/month/quarter/year
Returns a SmartDate, to be converted to a full date later (see fixSmartDate). Assumes any text in the parse stream has been lowercased.
datesepchars :: [Char] Source #
datesepchar :: TextParser m Char Source #
failIfInvalidYear :: Monad m => String -> m () Source #
failIfInvalidMonth :: Monad m => String -> m () Source #
failIfInvalidDay :: Monad m => String -> m () Source #
mkdatespan :: String -> String -> DateSpan Source #
Make a datespan from two valid date strings parseable by parsedate (or raise an error). Eg: mkdatespan "201111" "20111231".
originalPosting :: Posting -> Posting Source #
showPosting :: Posting -> String Source #
showComment :: Text -> String Source #
isBalancedVirtual :: Posting -> Bool Source #
isAssignment :: Posting -> Bool Source #
accountNamesFromPostings :: [Posting] -> [AccountName] Source #
Sorted unique account names referenced by these postings.
sumPostings :: [Posting] -> MixedAmount Source #
removePrices :: Posting -> Posting Source #
Remove all prices of a posting
postingDate :: Posting -> Day Source #
Get a posting's (primary) date - it's own primary date if specified, otherwise the parent transaction's primary date, or the null date if there is no parent transaction.
postingDate2 :: Posting -> Day Source #
Get a posting's secondary (secondary) date, which is the first of: posting's secondary date, transaction's secondary date, posting's primary date, transaction's primary date, or the null date if there is no parent transaction.
postingStatus :: Posting -> Status Source #
Get a posting's status. This is cleared or pending if those are explicitly set on the posting, otherwise the status of its parent transaction, or unmarked if there is no parent transaction. (Note the ambiguity, unmarked can mean "posting and transaction are both unmarked" or "posting is unmarked and don't know about the transaction".
transactionPayee :: Transaction -> Text Source #
transactionNote :: Transaction -> Text Source #
payeeAndNoteFromDescription :: Text -> (Text, Text) Source #
Parse a transaction's description into payee and note (aka narration) fields, assuming a convention of separating these with | (like Beancount). Ie, everything up to the first | is the payee, everything after it is the note. When there's no |, payee == note == description.
postingAllTags :: Posting -> [Tag] Source #
Tags for this posting including any inherited from its parent transaction.
transactionAllTags :: Transaction -> [Tag] Source #
Tags for this transaction including any from its postings.
relatedPostings :: Posting -> [Posting] Source #
isPostingInDateSpan :: DateSpan -> Posting -> Bool Source #
Does this posting fall within the given date span ?
isEmptyPosting :: Posting -> Bool Source #
postingsDateSpan :: [Posting] -> DateSpan Source #
Get the minimal date span which contains all the postings, or the null date span if there are none.
joinAccountNames :: AccountName -> AccountName -> AccountName Source #
Prefix one account name to another, preserving posting type indicators like concatAccountNames.
concatAccountNames :: [AccountName] -> AccountName Source #
Join account names into one. If any of them has () or [] posting type indicators, these (the first type encountered) will also be applied to the resulting account name.
accountNameApplyAliases :: [AccountAlias] -> AccountName -> AccountName Source #
Rewrite an account name using all matching aliases from the given list, in sequence. Each alias sees the result of applying the previous aliases.
accountNameApplyAliasesMemo :: [AccountAlias] -> AccountName -> AccountName Source #
Memoising version of accountNameApplyAliases, maybe overkill.
showTransaction :: Transaction -> String Source #
Show a journal transaction, formatted for the print command. ledger 2.x's standard format looks like this:
yyyymmdd[ *][ CODE] description......... [ ; comment...............] account name 1..................... ...$amount1[ ; comment...............] account name 2..................... ..$-amount1[ ; comment...............] pcodewidth = no limit -- 10 -- mimicking ledger layout. pdescwidth = no limit -- 20 -- I don't remember what these mean, pacctwidth = 35 minimum, no maximum -- they were important at the time. pamtwidth = 11 pcommentwidth = no limit -- 22
showPostingLine :: Posting -> String Source #
showPostingLines :: Posting -> [String] Source #
Produce posting line with all comment lines associated with it
showAccountName :: Maybe Int -> PostingType -> AccountName -> String Source #
Show an account name, clipped to the given width if any, and appropriately bracketed/parenthesised for the given posting type.
hasRealPostings :: Transaction -> Bool Source #
realPostings :: Transaction -> [Posting] Source #
assignmentPostings :: Transaction -> [Posting] Source #
virtualPostings :: Transaction -> [Posting] Source #
balancedVirtualPostings :: Transaction -> [Posting] Source #
transactionsPostings :: [Transaction] -> [Posting] Source #
transactionPostingBalances :: Transaction -> (MixedAmount, MixedAmount, MixedAmount) Source #
Get the sums of a transaction's real, virtual, and balanced virtual postings.
isTransactionBalanced :: Maybe (Map CommoditySymbol AmountStyle) -> Transaction -> Bool Source #
Is this transaction balanced ? A balanced transaction's real (non-virtual) postings sum to 0, and any balanced virtual postings also sum to 0.
balanceTransaction :: Maybe (Map CommoditySymbol AmountStyle) -> Transaction -> Either String Transaction Source #
Ensure this transaction is balanced, possibly inferring a missing amount or conversion price(s), or return an error message. Balancing is affected by commodity display precisions, so those can (optionally) be provided.
this fails for example, if there are several missing amounts (possibly with balance assignments)
balanceTransactionUpdate Source #
Arguments
:: MonadError String m | |
=> (AccountName -> MixedAmount -> m ()) | update function |
-> Maybe (Map CommoditySymbol AmountStyle) | |
-> Transaction | |
-> m Transaction |
More general version of balanceTransaction
that takes an update
function
transactionDate2 :: Transaction -> Day Source #
txnTieKnot :: Transaction -> Transaction Source #
Ensure a transaction's postings refer back to it, so that eg relatedPostings works right.
txnUntieKnot :: Transaction -> Transaction Source #
Ensure a transaction's postings do not refer back to it, so that eg recursiveSize and GHCI's :sprint work right.
A query option changes a query's/report's behaviour and output in some way.
Constructors
QueryOptInAcctOnly AccountName | show an account register focussed on this account |
QueryOptInAcct AccountName | as above but include sub-accounts in the account register | QueryOptCostBasis -- ^ show amounts converted to cost where possible | QueryOptDate2 -- ^ show secondary dates instead of primary dates |
Instances
Eq QueryOpt Source # | |
Data QueryOpt Source # | |
Defined in Hledger.Query Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> QueryOpt -> c QueryOpt # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c QueryOpt # toConstr :: QueryOpt -> Constr # dataTypeOf :: QueryOpt -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c QueryOpt) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QueryOpt) # gmapT :: (forall b. Data b => b -> b) -> QueryOpt -> QueryOpt # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QueryOpt -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QueryOpt -> r # gmapQ :: (forall d. Data d => d -> u) -> QueryOpt -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> QueryOpt -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> QueryOpt -> m QueryOpt # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> QueryOpt -> m QueryOpt # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> QueryOpt -> m QueryOpt # | |
Show QueryOpt Source # | |
A query is a composition of search criteria, which can be used to match postings, transactions, accounts and more.
Constructors
Any | always match |
None | never match |
Not Query | negate this match |
Or [Query] | match if any of these match |
And [Query] | match if all of these match |
Code Regexp | match if code matches this regexp |
Desc Regexp | match if description matches this regexp |
Acct Regexp | match postings whose account matches this regexp |
Date DateSpan | match if primary date in this date span |
Date2 DateSpan | match if secondary date in this date span |
StatusQ Status | match txns/postings with this status |
Real Bool | match if "realness" (involves a real non-virtual account ?) has this value |
Amt OrdPlus Quantity | match if the amount's numeric quantity is less thangreater thanequal to/unsignedly equal to some value |
Sym Regexp | match if the entire commodity symbol is matched by this regexp |
Empty Bool | if true, show zero-amount postings/accounts which are usually not shown more of a query option than a query criteria ? |
Depth Int | match if account depth is less than or equal to this value. Depth is sometimes used like a query (for filtering report data) and sometimes like a query option (for controlling display) |
Tag Regexp (Maybe Regexp) | match if a tag's name, and optionally its value, is matched by these respective regexps matching the regexp if provided, exists |
Instances
Eq Query Source # | |
Data Query Source # | |
Defined in Hledger.Query Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Query -> c Query # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Query # dataTypeOf :: Query -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Query) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Query) # gmapT :: (forall b. Data b => b -> b) -> Query -> Query # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Query -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Query -> r # gmapQ :: (forall d. Data d => d -> u) -> Query -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Query -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Query -> m Query # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Query -> m Query # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Query -> m Query # | |
Show Query Source # | |
parseQuery :: Day -> Text -> (Query, [QueryOpt]) Source #
Convert a query expression containing zero or more space-separated terms to a query and zero or more query options. A query term is either:
a search pattern, which matches on one or more fields, eg:
acct:REGEXP - match the account name with a regular expression desc:REGEXP - match the transaction description date:PERIODEXP - match the date with a period expression
The prefix indicates the field to match, or if there is no prefix account name is assumed.
a query option, which modifies the reporting behaviour in some way. There is currently one of these, which may appear only once:
inacct:FULLACCTNAME
The usual shell quoting rules are assumed. When a pattern contains whitespace, it (or the whole term including prefix) should be enclosed in single or double quotes.
Period expressions may contain relative dates, so a reference date is required to fully parse these.
Multiple terms are combined as follows: 1. multiple account patterns are OR'd together 2. multiple description patterns are OR'd together 3. multiple status patterns are OR'd together 4. then all terms are AND'd together
words'' :: [Text] -> Text -> [Text] Source #
Quote-and-prefix-aware version of words - don't split on spaces which are inside quotes, including quotes which may have one of the specified prefixes in front, and maybe an additional not: prefix in front of that.
simplifyQuery :: Query -> Query Source #
filterQuery :: (Query -> Bool) -> Query -> Query Source #
Remove query terms (or whole sub-expressions) not matching the given predicate from this query. XXX Semantics not completely clear.
queryIsNull :: Query -> Bool Source #
Does this query match everything ?
queryIsDepth :: Query -> Bool Source #
queryIsDate :: Query -> Bool Source #
queryIsDate2 :: Query -> Bool Source #
queryIsDateOrDate2 :: Query -> Bool Source #
queryIsAcct :: Query -> Bool Source #
queryIsSym :: Query -> Bool Source #
queryIsReal :: Query -> Bool Source #
queryIsStatus :: Query -> Bool Source #
queryIsEmpty :: Query -> Bool Source #
queryIsStartDateOnly :: Bool -> Query -> Bool Source #
Does this query specify a start date and nothing else (that would filter postings prior to the date) ? When the flag is true, look for a starting secondary date instead.
queryStartDate :: Bool -> Query -> Maybe Day Source #
What start date (or secondary date) does this query specify, if any ? For OR expressions, use the earliest of the dates. NOT is ignored.
queryEndDate :: Bool -> Query -> Maybe Day Source #
What end date (or secondary date) does this query specify, if any ? For OR expressions, use the latest of the dates. NOT is ignored.
queryDateSpan :: Bool -> Query -> DateSpan Source #
What date span (or secondary date span) does this query specify ? For OR expressions, use the widest possible span. NOT is ignored.
queryDateSpan' :: Query -> DateSpan Source #
What date span (or secondary date span) does this query specify ? For OR expressions, use the widest possible span. NOT is ignored.
queryDepth :: Query -> Int Source #
The depth limit this query specifies, or a large number if none.
inAccount :: [QueryOpt] -> Maybe (AccountName, Bool) Source #
The account we are currently focussed on, if any, and whether subaccounts are included. Just looks at the first query option.
inAccountQuery :: [QueryOpt] -> Maybe Query Source #
A query for the account(s) we are currently focussed on, if any. Just looks at the first query option.
matchesAccount :: Query -> AccountName -> Bool Source #
Does the match expression match this account ? A matching in: clause is also considered a match.
matchesMixedAmount :: Query -> MixedAmount -> Bool Source #
matchesAmount :: Query -> Amount -> Bool Source #
Does the match expression match this (simple) amount ?
matchesPosting :: Query -> Posting -> Bool Source #
Does the match expression match this posting ?
Note that for account match we try both original and effective account
matchesTransaction :: Query -> Transaction -> Bool Source #
Does the match expression match this transaction ?
timeclockEntriesToTransactions :: LocalTime -> [TimeclockEntry] -> [Transaction] Source #
Convert time log entries to journal transactions. When there is no clockout, add one with the provided current time. Sessions crossing midnight are split into days to give accurate per-day totals.
entryFromTimeclockInOut :: TimeclockEntry -> TimeclockEntry -> Transaction Source #
Convert a timeclock clockin and clockout entry to an equivalent journal transaction, representing the time expenditure. Note this entry is not balanced, since we omit the "assets:time" transaction for simpler output.
accountsFromPostings :: [Posting] -> [Account] Source #
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 Source #
Convert an AccountName tree to an Account tree
tieAccountParents :: Account -> Account Source #
Tie the knot so all subaccounts' parents are set correctly.
parentAccounts :: Account -> [Account] Source #
Get this account's parent accounts, from the nearest up to the root.
accountsLevels :: Account -> [[Account]] Source #
List the accounts at each level of the account tree.
mapAccounts :: (Account -> Account) -> Account -> Account Source #
Map a (non-tree-structure-modifying) function over this and sub accounts.
anyAccounts :: (Account -> Bool) -> Account -> Bool Source #
Is the predicate true on any of this account or its subaccounts ?
sumAccounts :: Account -> Account Source #
Add subaccount-inclusive balances to an account tree.
clipAccountsAndAggregate :: Int -> [Account] -> [Account] 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).
pruneAccounts :: (Account -> Bool) -> Account -> Maybe Account Source #
Remove all leaf accounts and subtrees matching a predicate.
flattenAccounts :: Account -> [Account] 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!
filterAccounts :: (Account -> Bool) -> Account -> [Account] Source #
Filter an account tree (to a list).
sortAccountTreeByAmount :: NormalBalance -> Account -> Account Source #
Sort each level of an account tree by inclusive amount, so that the accounts with largest normal balances are listed first. The provided normal balance sign determines whether normal balances are negative or positive.
lookupAccount :: AccountName -> [Account] -> Maybe Account Source #
Search an account list by name.
printAccounts :: Account -> IO () Source #
showAccounts :: Account -> String Source #
showAccountDebug :: PrintfType t => Account -> t Source #
showMarketPrice :: MarketPrice -> String Source #
Get the string representation of an market price, based on its commodity's display settings.
journalFilePath :: Journal -> FilePath Source #
journalFilePaths :: Journal -> [FilePath] Source #
addTransaction :: Transaction -> Journal -> Journal Source #
addMarketPrice :: MarketPrice -> Journal -> Journal Source #
journalTransactionAt :: Journal -> Integer -> Maybe Transaction Source #
Get the transaction with this index (its 1-based position in the input stream), if any.
journalNextTransaction :: Journal -> Transaction -> Maybe Transaction Source #
Get the transaction that appeared immediately after this one in the input stream, if any.
journalPrevTransaction :: Journal -> Transaction -> Maybe Transaction Source #
Get the transaction that appeared immediately before this one in the input stream, if any.
journalDescriptions :: Journal -> [Text] Source #
Unique transaction descriptions used in this journal.
journalPostings :: Journal -> [Posting] Source #
All postings from this journal's transactions, in order.
journalAccountNamesUsed :: Journal -> [AccountName] Source #
Sorted unique account names posted to by this journal's transactions.
journalAccountNamesImplied :: Journal -> [AccountName] Source #
Sorted unique account names implied by this journal's transactions - accounts posted to and all their implied parent accounts.
journalAccountNamesDeclared :: Journal -> [AccountName] Source #
Sorted unique account names declared by account directives in this journal.
journalAccountNamesDeclaredOrUsed :: Journal -> [AccountName] Source #
Sorted unique account names declared by account directives or posted to by transactions in this journal.
journalAccountNamesDeclaredOrImplied :: Journal -> [AccountName] Source #
Sorted unique account names declared by account directives, or posted to or implied as parents by transactions in this journal.
journalAccountNames :: Journal -> [AccountName] Source #
Convenience/compatibility alias for journalAccountNamesDeclaredOrImplied.
journalProfitAndLossAccountQuery :: Journal -> Query Source #
A query for Profit & Loss accounts in this journal. Cf http://en.wikipedia.org/wiki/Chart_of_accounts#Profit_.26_Loss_accounts.
journalIncomeAccountQuery :: Journal -> Query Source #
A query for Income (Revenue) accounts in this journal.
This is currently hard-coded to the case-insensitive regex ^(income|revenue)s?(:|$)
.
journalExpenseAccountQuery :: Journal -> Query Source #
A query for Expense accounts in this journal.
This is currently hard-coded to the case-insensitive regex ^expenses?(:|$)
.
journalBalanceSheetAccountQuery :: Journal -> Query Source #
A query for Asset, Liability & Equity accounts in this journal. Cf http://en.wikipedia.org/wiki/Chart_of_accounts#Balance_Sheet_Accounts.
journalAssetAccountQuery :: Journal -> Query Source #
A query for Asset accounts in this journal.
This is currently hard-coded to the case-insensitive regex ^assets?(:|$)
.
journalLiabilityAccountQuery :: Journal -> Query Source #
A query for Liability accounts in this journal.
This is currently hard-coded to the case-insensitive regex ^(debts?|liabilit(y|ies))(:|$)
.
journalEquityAccountQuery :: Journal -> Query Source #
A query for Equity accounts in this journal.
This is currently hard-coded to the case-insensitive regex ^equity(:|$)
.
journalCashAccountQuery :: Journal -> Query Source #
A query for Cash (-equivalent) accounts in this journal (ie,
accounts which appear on the cashflow statement.) This is currently
hard-coded to be all the Asset accounts except for those containing the
case-insensitive regex (receivable|:A/R|:fixed)
.
filterJournalTransactions :: Query -> Journal -> Journal Source #
Keep only transactions matching the query expression.
filterJournalPostings :: Query -> Journal -> Journal Source #
Keep only postings matching the query expression. This can leave unbalanced transactions.
filterJournalAmounts :: Query -> Journal -> Journal Source #
Within each posting's amount, keep only the parts matching the query. This can leave unbalanced transactions.
filterTransactionAmounts :: Query -> Transaction -> Transaction Source #
Filter out all parts of this transaction's amounts which do not match the query. This can leave the transaction unbalanced.
filterPostingAmount :: Query -> Posting -> Posting Source #
Filter out all parts of this posting's amount which do not match the query.
journalApplyAliases :: [AccountAlias] -> Journal -> Journal Source #
Apply additional account aliases (eg from the command-line) to all postings in a journal.
journalFinalise :: ClockTime -> FilePath -> Text -> Bool -> ParsedJournal -> Either String Journal Source #
Do post-parse processing on a parsed journal to make it ready for use. Reverse parsed data to normal order, canonicalise amount formats, check/ensure that transactions are balanced, and maybe check balance assertions.
journalUntieTransactions :: Transaction -> Transaction Source #
Untie all transaction-posting knots in this journal, so that eg recursiveSize and GHCI's :sprint can work on it.
journalCheckBalanceAssertions :: Journal -> Either String Journal Source #
Check any balance assertions in the journal and return an error message if any of them fail.
journalBalanceTransactions :: Bool -> Journal -> Either String Journal Source #
Fill in any missing amounts and check that all journal transactions balance, or return an error message. This is done after parsing all amounts and applying canonical commodity styles, since balancing depends on display precision. Reports only the first error encountered.
journalApplyCommodityStyles :: Journal -> Journal Source #
Choose and apply a consistent display format to the posting amounts in each commodity. Each commodity's format is specified by a commodity format directive, or otherwise inferred from posting amounts as in hledger < 0.28.
commodityStylesFromAmounts :: [Amount] -> Map CommoditySymbol AmountStyle Source #
Given a list of amounts in parse order, build a map from their commodity names to standard commodity display formats.
canonicalStyleFrom :: [AmountStyle] -> AmountStyle Source #
Given an ordered list of amount styles, choose a canonical style. That is: the style of the first, and the maximum precision of all.
journalConvertAmountsToCost :: Journal -> Journal Source #
Convert all this journal's amounts to cost by applying their prices, if any.
journalAmounts :: Journal -> [Amount] Source #
Get an ordered list of the amounts in this journal which will influence amount style canonicalisation. These are:
- amounts in market price directives (in parse order)
- amounts in postings (in parse order)
Amounts in default commodity directives also influence canonicalisation, but earlier, as amounts are parsed. Amounts in posting prices are not used for canonicalisation.
overJournalAmounts :: (Amount -> Amount) -> Journal -> Journal Source #
Maps over all of the amounts in the journal
traverseJournalAmounts :: Applicative f => (Amount -> f Amount) -> Journal -> f Journal Source #
Traverses over all ofthe amounts in the journal, in the order
indicated by journalAmounts
.
journalDateSpan :: Bool -> Journal -> DateSpan Source #
The fully specified date span enclosing the dates (primary or secondary) of all this journal's transactions and postings, or DateSpan Nothing Nothing if there are none.
journalPivot :: Text -> Journal -> Journal Source #
Apply the pivot transformation to all postings in a journal, replacing their account name by their value for the given field or tag.
matchpats :: [String] -> String -> Bool Source #
Check if a set of hledger account/description filter patterns matches the given account name or entry description. Patterns are case-insensitive regular expressions. Prefixed with not:, they become anti-patterns.
nullledger :: Ledger Source #
ledgerFromJournal :: Query -> Journal -> Ledger Source #
Filter a journal's transactions with the given query, then derive a ledger containing the chart of accounts and balances. If the query includes a depth limit, that will affect the ledger's journal but not the ledger's account tree.
ledgerAccountNames :: Ledger -> [AccountName] Source #
List a ledger's account names.
ledgerAccount :: Ledger -> AccountName -> Maybe Account Source #
Get the named account from a ledger.
ledgerRootAccount :: Ledger -> Account Source #
Get this ledger's root account, which is a dummy "root" account above all others. This should always be first in the account list, if somehow not this returns a null account.
ledgerTopAccounts :: Ledger -> [Account] Source #
List a ledger's top-level accounts (the ones below the root), in tree order.
ledgerLeafAccounts :: Ledger -> [Account] Source #
List a ledger's bottom-level (subaccount-less) accounts, in tree order.
ledgerAccountsMatching :: [String] -> Ledger -> [Account] Source #
Accounts in ledger whose name matches the pattern, in tree order.
ledgerPostings :: Ledger -> [Posting] Source #
List a ledger's postings, in the order parsed.
ledgerDateSpan :: Ledger -> DateSpan Source #
The (fully specified) date span containing all the ledger's (filtered) transactions, or DateSpan Nothing Nothing if there are none.
ledgerCommodities :: Ledger -> [CommoditySymbol] Source #
All commodities used in this ledger.
runModifierTransaction :: Query -> ModifierTransaction -> Transaction -> Transaction Source #
Builds a Transaction
transformer based on ModifierTransaction
.
Query
parameter allows injection of additional restriction on posting
match. Don't forget to call txnTieKnot
.
>>>
runModifierTransaction Any (ModifierTransaction "" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01 ping $1.00 pong $2.00>>>
runModifierTransaction Any (ModifierTransaction "miss" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01 ping $1.00>>>
runModifierTransaction None (ModifierTransaction "" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01 ping $1.00>>>
runModifierTransaction Any (ModifierTransaction "ping" ["pong" `post` amount{amultiplier=True, aquantity=3}]) nulltransaction{tpostings=["ping" `post` usd 2]}
0000/01/01 ping $2.00 pong $6.00
mtvaluequery :: ModifierTransaction -> Day -> Query Source #
Extract Query
equivalent of mtvalueexpr
from ModifierTransaction
>>>
mtvaluequery (ModifierTransaction "" []) undefined
Any>>>
mtvaluequery (ModifierTransaction "ping" []) undefined
Acct "ping">>>
mtvaluequery (ModifierTransaction "date:2016" []) undefined
Date (DateSpan 2016)>>>
mtvaluequery (ModifierTransaction "date:today" []) (read "2017-01-01")
Date (DateSpan 2017/01/01)
jdatespan :: Journal -> DateSpan Source #
DateSpan
of all dates mentioned in Journal
>>>
jdatespan nulljournal
DateSpan ->>>
jdatespan nulljournal{jtxns=[nulltransaction{tdate=read "2016-01-01"}] }
DateSpan 2016/01/01>>>
jdatespan nulljournal{jtxns=[nulltransaction{tdate=read "2016-01-01", tpostings=[nullposting{pdate=Just $ read "2016-02-01"}]}] }
DateSpan 2016/01/01-2016/02/01
runPeriodicTransaction :: PeriodicTransaction -> DateSpan -> [Transaction] Source #
Generate transactions from PeriodicTransaction
within a DateSpan
Note that new transactions require txnTieKnot
post-processing.
>>>
let gen str = mapM_ (putStr . show) $ runPeriodicTransaction (PeriodicTransaction str ["hi" `post` usd 1]) nulldatespan
>>>
gen "monthly from 2017/1 to 2017/4"
2017/01/01 hi $1.00 2017/02/01 hi $1.00 2017/03/01 hi $1.00>>>
gen "monthly from 2017/1 to 2017/5"
2017/01/01 hi $1.00 2017/02/01 hi $1.00 2017/03/01 hi $1.00 2017/04/01 hi $1.00>>>
gen "every 2nd day of month from 2017/02 to 2017/04"
2017/01/02 hi $1.00 2017/02/02 hi $1.00 2017/03/02 hi $1.00>>>
gen "monthly from 2017/1 to 2017/4"
2017/01/01 hi $1.00 2017/02/01 hi $1.00 2017/03/01 hi $1.00>>>
gen "every 30th day of month from 2017/1 to 2017/5"
2016/12/30 hi $1.00 2017/01/30 hi $1.00 2017/02/28 hi $1.00 2017/03/30 hi $1.00 2017/04/30 hi $1.00>>>
gen "every 2nd Thursday of month from 2017/1 to 2017/4"
2016/12/08 hi $1.00 2017/01/12 hi $1.00 2017/02/09 hi $1.00 2017/03/09 hi $1.00>>>
gen "every nov 29th from 2017 to 2019"
2016/11/29 hi $1.00 2017/11/29 hi $1.00 2018/11/29 hi $1.00>>>
gen "2017/1"
2017/01/01 hi $1.00>>>
gen ""
... Failed to parse ...>>>
gen "weekly from 2017"
*** Exception: Unable to generate transactions according to "weekly from 2017" as 2017-01-01 is not a first day of the week>>>
gen "monthly from 2017/5/4"
*** Exception: Unable to generate transactions according to "monthly from 2017/5/4" as 2017-05-04 is not a first day of the month>>>
gen "every quarter from 2017/1/2"
*** Exception: Unable to generate transactions according to "every quarter from 2017/1/2" as 2017-01-02 is not a first day of the quarter>>>
gen "yearly from 2017/1/14"
*** Exception: Unable to generate transactions according to "yearly from 2017/1/14" as 2017-01-14 is not a first day of the year
data ReportOpts Source #
Standard options for customising report filtering and output. Most of these correspond to standard hledger command-line options or query arguments, but not all. Some are used only by certain commands, as noted below.
Constructors
ReportOpts | |
Fields
|
Instances
Data ReportOpts Source # | |
Defined in Hledger.Reports.ReportOptions Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ReportOpts -> c ReportOpts # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ReportOpts # toConstr :: ReportOpts -> Constr # dataTypeOf :: ReportOpts -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ReportOpts) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ReportOpts) # gmapT :: (forall b. Data b => b -> b) -> ReportOpts -> ReportOpts # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ReportOpts -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ReportOpts -> r # gmapQ :: (forall d. Data d => d -> u) -> ReportOpts -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ReportOpts -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ReportOpts -> m ReportOpts # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ReportOpts -> m ReportOpts # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ReportOpts -> m ReportOpts # | |
Show ReportOpts Source # | |
Defined in Hledger.Reports.ReportOptions Methods showsPrec :: Int -> ReportOpts -> ShowS # show :: ReportOpts -> String # showList :: [ReportOpts] -> ShowS # | |
Default ReportOpts Source # | |
Defined in Hledger.Reports.ReportOptions Methods def :: ReportOpts # |
data AccountListMode Source #
Should accounts be displayed: in the command's default style, hierarchically, or as a flat list ?
Instances
data BalanceType Source #
Which "balance" is being shown in a balance report.
Constructors
PeriodChange | The change of balance in each period. |
CumulativeChange | The accumulated change across multiple periods. |
HistoricalBalance | The historical ending balance, including the effect of all postings before the report period. Unless altered by, a query, this is what you would see on a bank statement. |
Instances
Eq BalanceType Source # | |
Defined in Hledger.Reports.ReportOptions | |
Data BalanceType Source # | |
Defined in Hledger.Reports.ReportOptions Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BalanceType -> c BalanceType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BalanceType # toConstr :: BalanceType -> Constr # dataTypeOf :: BalanceType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BalanceType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BalanceType) # gmapT :: (forall b. Data b => b -> b) -> BalanceType -> BalanceType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BalanceType -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BalanceType -> r # gmapQ :: (forall d. Data d => d -> u) -> BalanceType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BalanceType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BalanceType -> m BalanceType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BalanceType -> m BalanceType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BalanceType -> m BalanceType # | |
Show BalanceType Source # | |
Defined in Hledger.Reports.ReportOptions Methods showsPrec :: Int -> BalanceType -> ShowS # show :: BalanceType -> String # showList :: [BalanceType] -> ShowS # | |
Default BalanceType Source # | |
Defined in Hledger.Reports.ReportOptions Methods def :: BalanceType # |
checkReportOpts :: ReportOpts -> ReportOpts Source #
Do extra validation of report options, raising an error if there's a problem.
simplifyStatuses :: Ord a => [a] -> [a] Source #
Reduce a list of statuses to just one of each status, and if all statuses are present return the empty list.
reportOptsToggleStatus :: Status -> ReportOpts -> ReportOpts Source #
Add/remove this status from the status list. Used by hledger-ui.
transactionDateFn :: ReportOpts -> Transaction -> Day Source #
Select the Transaction date accessor based on --date2.
postingDateFn :: ReportOpts -> Posting -> Day Source #
Select the Posting date accessor based on --date2.
whichDateFromOpts :: ReportOpts -> WhichDate Source #
Report which date we will report on based on --date2.
tree_ :: ReportOpts -> Bool Source #
Legacy-compatible convenience aliases for accountlistmode_.
flat_ :: ReportOpts -> Bool Source #
journalSelectingAmountFromOpts :: ReportOpts -> Journal -> Journal Source #
Convert this journal's postings' amounts to the cost basis amounts if specified by options.
queryFromOpts :: Day -> ReportOpts -> Query Source #
Convert report options and arguments to a query.
queryFromOptsOnly :: Day -> ReportOpts -> Query Source #
Convert report options to a query, ignoring any non-flag command line arguments.
queryOptsFromOpts :: Day -> ReportOpts -> [QueryOpt] Source #
Convert report options and arguments to query options.
reportStartEndDates :: Journal -> ReportOpts -> IO (Maybe (Day, Day)) Source #
The effective report start/end dates are the dates specified by options or queries, otherwise the earliest/latest transaction or posting date in the journal, otherwise (for an empty journal) nothing. Needs IO to parse smart dates in options/queries.
reportStartDate :: Journal -> ReportOpts -> IO (Maybe Day) Source #
reportEndDate :: Journal -> ReportOpts -> IO (Maybe Day) Source #
specifiedStartEndDates :: ReportOpts -> IO (Maybe Day, Maybe Day) Source #
The specified report start/end dates are the dates specified by options or queries, if any. Needs IO to parse smart dates in options/queries.
specifiedStartDate :: ReportOpts -> IO (Maybe Day) Source #
specifiedEndDate :: ReportOpts -> IO (Maybe Day) Source #
type AccountTransactionsReportItem = (Transaction, Transaction, Bool, String, MixedAmount, MixedAmount) Source #
type AccountTransactionsReport = (String, [AccountTransactionsReportItem]) Source #
An account transactions report represents transactions affecting a particular account (or possibly several accounts, but we don't use that). It is used eg by hledger-ui's and hledger-web's account register view, where we want to show one row per transaction, in the context of the current account. Report items consist of:
- the transaction, unmodified
- the transaction as seen in the context of the current account and query, which means:
- the transaction date is set to the "transaction context date", which can be different from the transaction's general date: if postings to the current account (and matched by the report query) have their own dates, it's the earliest of these dates.
- the transaction's postings are filtered, excluding any which are not matched by the report query
- a text description of the other account(s) posted to/from
- a flag indicating whether there's more than one other account involved
- the total increase/decrease to the current account
- the report transactions' running total after this transaction; or if historical balance is requested (-H), the historical running total. The historical running total includes transactions from before the report start date if one is specified, filtered by the report query. The historical running total may or may not be the account's historical running balance, depending on the report query.
Items are sorted by transaction register date (the earliest date the transaction posts to the current account), most recent first. Reporting intervals are currently ignored.
type TransactionsReportItem = (Transaction, Transaction, Bool, String, MixedAmount, MixedAmount) Source #
type TransactionsReport = (String, [TransactionsReportItem]) Source #
A transactions report includes a list of transactions (posting-filtered and unfiltered variants), a running balance, and some other information helpful for rendering a register view (a flag indicating multiple other accounts and a display string describing them) with or without a notion of current account(s). Two kinds of report use this data structure, see journalTransactionsReport and accountTransactionsReport below for detais.
triOrigTransaction :: (a, b, c, d, e, f) -> a Source #
triDate :: (a, Transaction, c, d, e, f) -> Day Source #
triBalance :: (a, b, c, d, e, f) -> f Source #
triCommodityAmount :: CommoditySymbol -> (a, b, c, d, MixedAmount, f) -> MixedAmount Source #
triCommodityBalance :: CommoditySymbol -> (a, b, c, d, e, MixedAmount) -> MixedAmount Source #
journalTransactionsReport :: ReportOpts -> Journal -> Query -> TransactionsReport Source #
Select transactions from the whole journal. This is similar to a "postingsReport" except with transaction-based report items which are ordered most recent first. XXX Or an EntriesReport - use that instead ? This is used by hledger-web's journal view.
accountTransactionsReport :: ReportOpts -> Journal -> Query -> Query -> AccountTransactionsReport Source #
transactionRegisterDate :: Query -> Query -> Transaction -> Day Source #
What is the transaction's date in the context of a particular account (specified with a query) and report query, as in an account register ? It's normally the transaction's general date, but if any posting(s) matched by the report query and affecting the matched account(s) have their own earlier dates, it's the earliest of these dates. Secondary transaction/posting dates are ignored.
transactionsReportByCommodity :: TransactionsReport -> [(CommoditySymbol, TransactionsReport)] Source #
Split a transactions report whose items may involve several commodities, into one or more single-commodity transactions reports.
type PostingsReport = (String, [PostingsReportItem]) Source #
A postings report is a list of postings with a running total, a label for the total field, and a little extra transaction info to help with rendering. This is used eg for the register command.
postingsReport :: ReportOpts -> Query -> Journal -> PostingsReport Source #
Select postings from the journal and add running balance and other information to make a postings report. Used by eg hledger's register command.
mkpostingsReportItem :: Bool -> Bool -> WhichDate -> Maybe Day -> Posting -> MixedAmount -> PostingsReportItem Source #
Generate one postings report line item, containing the posting, the current running balance, and optionally the posting date and/or the transaction description.
type EntriesReportItem = Transaction Source #
type EntriesReport = [EntriesReportItem] Source #
A journal entries report is a list of whole transactions as originally entered in the journal (mostly). This is used by eg hledger's print command and hledger-web's journal entries view.
entriesReport :: ReportOpts -> Query -> Journal -> EntriesReport Source #
Select transactions for an entries report.
Various options to use when reading journal files. Similar to CliOptions.inputflags, simplifies the journal-reading functions.
Constructors
InputOpts | |
Fields
|
Instances
Data InputOpts Source # | |
Defined in Hledger.Read.Common Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> InputOpts -> c InputOpts # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c InputOpts # toConstr :: InputOpts -> Constr # dataTypeOf :: InputOpts -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c InputOpts) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c InputOpts) # gmapT :: (forall b. Data b => b -> b) -> InputOpts -> InputOpts # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> InputOpts -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> InputOpts -> r # gmapQ :: (forall d. Data d => d -> u) -> InputOpts -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> InputOpts -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> InputOpts -> m InputOpts # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> InputOpts -> m InputOpts # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> InputOpts -> m InputOpts # | |
Show InputOpts Source # | |
Default InputOpts Source # | |
Defined in Hledger.Read.Common |
runTextParser :: TextParser Identity a -> Text -> Either (ParseError Char MPErr) a Source #
Run a string parser with no state in the identity monad.
rtp :: TextParser Identity a -> Text -> Either (ParseError Char MPErr) a Source #
Run a string parser with no state in the identity monad.
runJournalParser :: Monad m => TextParser m a -> Text -> m (Either (ParseError Char MPErr) a) Source #
Run a journal parser with a null journal-parsing state.
rjp :: Monad m => TextParser m a -> Text -> m (Either (ParseError Char MPErr) a) Source #
Run a journal parser with a null journal-parsing state.
runErroringJournalParser :: Monad m => ErroringJournalParser m a -> Text -> m (Either String a) Source #
Run an error-raising journal parser with a null journal-parsing state.
rejp :: Monad m => ErroringJournalParser m a -> Text -> m (Either String a) Source #
Run an error-raising journal parser with a null journal-parsing state.
parseAndFinaliseJournal :: ErroringJournalParser IO ParsedJournal -> Bool -> FilePath -> Text -> ExceptT String IO Journal Source #
Given a megaparsec ParsedJournal parser, balance assertion flag, file path and file content: parse and post-process a Journal, or give an error.
parseAndFinaliseJournal' :: JournalParser Identity ParsedJournal -> Bool -> FilePath -> Text -> ExceptT String IO Journal Source #
setYear :: Year -> JournalParser m () Source #
setDefaultCommodityAndStyle :: (CommoditySymbol, AmountStyle) -> JournalParser m () Source #
getDefaultAmountStyle :: JournalParser m (Maybe AmountStyle) Source #
Get amount style associated with default currency.
Returns AmountStyle
used to defined by a latest default commodity directive
prior to current position within this file or its parents.
getAmountStyle :: CommoditySymbol -> JournalParser m (Maybe AmountStyle) Source #
Lookup currency-specific amount style.
Returns AmountStyle
used in commodity directive within current journal
prior to current position or in its parents files.
pushAccount :: AccountName -> JournalParser m () Source #
pushParentAccount :: AccountName -> JournalParser m () Source #
popParentAccount :: JournalParser m () Source #
addAccountAlias :: MonadState Journal m => AccountAlias -> m () Source #
getAccountAliases :: MonadState Journal m => m [AccountAlias] Source #
clearAccountAliases :: MonadState Journal m => m () Source #
parserErrorAt :: Monad m => SourcePos -> String -> ErroringJournalParser m a Source #
Terminate parsing entirely, returning the given error message with the given parse position prepended.
statusp :: TextParser m Status Source #
codep :: TextParser m String Source #
datep :: JournalParser m Day Source #
Parse a date in YYYYMMDD format. Hyphen (-) and period (.) are also allowed as separators. The year may be omitted if a default year has been set. Leading zeroes may be omitted.
datetimep :: JournalParser m LocalTime Source #
Parse a date and time in YYYYMMDD HH:MM[:SS][+-ZZZZ] format. Hyphen (-) and period (.) are also allowed as date separators. The year may be omitted if a default year has been set. Seconds are optional. The timezone is optional and ignored (the time is always interpreted as a local time). Leading zeroes may be omitted (except in a timezone).
secondarydatep :: Day -> JournalParser m Day Source #
modifiedaccountnamep :: JournalParser m AccountName Source #
> parsewith twoorthreepartdatestringp "2016/01/2"
Right "2016012" twoorthreepartdatestringp = do n1 <- some digitChar c <- datesepchar n2 <- some digitChar mn3 optional $ char c> some digitChar return $ n1 ++ c:n2 ++ maybe "" (c:) mn3
Parse an account name, then apply any parent account prefix and/or account aliases currently in effect.
accountnamep :: TextParser m AccountName Source #
Parse an account name. Account names start with a non-space, may have single spaces inside them, and are terminated by two or more spaces (or end of input). Also they have one or more components of at least one character, separated by the account separator char. (This parser will also consume one following space, if present.)
spaceandamountormissingp :: Monad m => JournalParser m MixedAmount Source #
Parse whitespace then an amount, with an optional left or right currency symbol and optional price, or return the special "missing" marker amount.
amountp :: Monad m => JournalParser m Amount Source #
Parse a single-commodity amount, with optional symbol on the left or right, optional unit or total price, and optional (ignored) ledger-style balance assertion or fixed lot price declaration.
mamountp' :: String -> MixedAmount Source #
Parse a mixed amount from a string, or get an error.
signp :: TextParser m String Source #
multiplierp :: TextParser m Bool Source #
leftsymbolamountp :: Monad m => JournalParser m Amount Source #
rightsymbolamountp :: Monad m => JournalParser m Amount Source #
nosymbolamountp :: Monad m => JournalParser m Amount Source #
priceamountp :: Monad m => JournalParser m Price Source #
fixedlotpricep :: Monad m => JournalParser m (Maybe Amount) Source #
numberp :: Maybe AmountStyle -> TextParser m (Quantity, Int, Maybe Char, Maybe DigitGroupStyle) Source #
Parse a string representation of a number for its value and display attributes.
Some international number formats are accepted, eg either period or comma may be used for the decimal point, and the other of these may be used for separating digit groups in the integer part. See http://en.wikipedia.org/wiki/Decimal_separator for more examples.
This returns: the parsed numeric value, the precision (number of digits seen following the decimal point), the decimal point character used if any, and the digit group style if any.
fromRawNumber :: Maybe AmountStyle -> Bool -> (Maybe Char, [String], Maybe (Char, String)) -> (Quantity, Int, Maybe Char, Maybe DigitGroupStyle) Source #
rawnumberp :: TextParser m (Maybe Char, [String], Maybe (Char, String)) Source #
whitespaceChar :: TextParser m Char Source #
Parse a unicode char that represents any non-control space char (Zs general category).
multilinecommentp :: JournalParser m () Source #
emptyorcommentlinep :: JournalParser m () Source #
followingcommentp :: JournalParser m Text Source #
Parse a possibly multi-line comment following a semicolon.
followingcommentandtagsp :: MonadIO m => Maybe Day -> ErroringJournalParser m (Text, [Tag], Maybe Day, Maybe Day) Source #
Parse a possibly multi-line comment following a semicolon, and any tags and/or posting dates within it. Posting dates can be expressed with "date""date2" tags andor bracketed dates. The dates are parsed in full here so that errors are reported in the right position. Missing years can be inferred if a default date is provided.
>>>
rejp (followingcommentandtagsp (Just $ fromGregorian 2000 1 2)) "; a:b, date:3/4, [=5/6]"
Right ("a:b, date:3/4, [=5/6]\n",[("a","b"),("date","3/4")],Just 2000-03-04,Just 2000-05-06)
Year unspecified and no default provided -> unknown year error, at correct position: >>> rejp (followingcommentandtagsp Nothing) " ; xxx date:3/4n ; second line" Left ...1:22...partial date 3/4 found, but the current year is unknown...
Date tag value contains trailing text - forgot the comma, confused: the syntaxes ? We'll accept the leading date anyway >>> rejp (followingcommentandtagsp (Just $ fromGregorian 2000 1 2)) "; date:34=56" Right ("date:34=56n",[("date","34=56")],Just 2000-03-04,Nothing)
commentp :: JournalParser m Text Source #
linecommentp :: JournalParser m Text Source #
commentStartingWithp :: [Char] -> JournalParser m Text Source #
commentTags :: Text -> [Tag] Source #
Extract any tags (name:value ended by comma or newline) embedded in a string.
>>>
commentTags "a b:, c:c d:d, e"
[("b",""),("c","c d:d")]
>>>
commentTags "a [1/1/1] [1/1] [1], [=1/1/1] [=1/1] [=1] [1/1=1/1/1] [1=1/1/1] b:c"
[("b","c")]
- -[("date","111"),("date","11"),("date2","111"),("date2","11"),("date","11"),("date2","111"),("date","1"),("date2","11/1")]
>>>
commentTags "\na b:, \nd:e, f"
[("b",""),("d","e")]
tagsp :: SimpleTextParser [Tag] Source #
Parse all tags found in a string.
nontagp :: SimpleTextParser String Source #
Parse everything up till the first tag.
>>>
rtp nontagp "\na b:, \nd:e, f"
Right "\na "
tagp :: SimpleTextParser Tag Source #
Tags begin with a colon-suffixed tag name (a word beginning with a letter) and are followed by a tag value (any text up to a comma or newline, whitespace-stripped).
>>>
rtp tagp "a:b b , c AuxDate: 4/2"
Right ("a","b b")
tagnamep :: SimpleTextParser Text Source #
>>>
rtp tagnamep "a:"
Right "a"
tagvaluep :: TextParser m Text Source #
postingdatesp :: Monad m => Maybe Day -> ErroringJournalParser m [(TagName, Day)] Source #
Parse all posting dates found in a string. Posting dates can be expressed with datedate2 tags andor bracketed dates. The dates are parsed fully to give useful errors. Missing years can be inferred only if a default date is provided.
datetagp :: Monad m => Maybe Day -> ErroringJournalParser m (TagName, Day) Source #
Date tags are tags with name "date" or "date2". Their value is parsed as a date, using the provided default date if any for inferring a missing year if needed. Any error in date parsing is reported and terminates parsing.
>>>
rejp (datetagp Nothing) "date: 2000/1/2 "
Right ("date",2000-01-02)
>>>
rejp (datetagp (Just $ fromGregorian 2001 2 3)) "date2:3/4"
Right ("date2",2001-03-04)
>>>
rejp (datetagp Nothing) "date: 3/4"
Left ...1:9...partial date 3/4 found, but the current year is unknown...
bracketeddatetagsp :: Monad m => Maybe Day -> ErroringJournalParser m [(TagName, Day)] Source #
Parse Ledger-style bracketed posting dates ([DATE=DATE2]), as "date" and/or "date2" tags. Anything that looks like an attempt at this (a square-bracketed sequence of 0123456789/-.= containing at least one digit and one date separator) is also parsed, and will throw an appropriate error.
The dates are parsed in full here so that errors are reported in the right position. A missing year in DATE can be inferred if a default date is provided. A missing year in DATE2 will be inferred from DATE.
>>>
rejp (bracketeddatetagsp Nothing) "[2016/1/2=3/4]"
Right [("date",2016-01-02),("date2",2016-03-04)]
>>>
rejp (bracketeddatetagsp Nothing) "[1]"
Left ...not a bracketed date...
>>>
rejp (bracketeddatetagsp Nothing) "[2016/1/32]"
Left ...1:11:...bad date: 2016/1/32...
>>>
rejp (bracketeddatetagsp Nothing) "[1/31]"
Left ...1:6:...partial date 1/31 found, but the current year is unknown...
>>>
rejp (bracketeddatetagsp Nothing) "[0123456789/-.=/-.=]"
Left ...1:15:...bad date, different separators...
type PrefixedFilePath = FilePath Source #
A file path optionally prefixed by a reader name and colon (journal:, csv:, timedot:, etc.).
defaultJournal :: IO Journal Source #
Read the default journal file specified by the environment, or raise an error.
defaultJournalPath :: IO String Source #
Get the default journal file path specified by the environment.
Like ledger, we look first for the LEDGER_FILE environment
variable, and if that does not exist, for the legacy LEDGER
environment variable. If neither is set, or the value is blank,
return the hard-coded default, which is .hledger.journal
in the
users's home directory (or in the current directory, if we cannot
determine a home directory).
readJournalFiles :: Maybe StorageFormat -> Maybe FilePath -> Bool -> [PrefixedFilePath] -> IO (Either String Journal) Source #
readJournalFiles mformat mrulesfile assrt prefixedfiles
Read a Journal from each specified file path and combine them into one. Or, return the first error message.
Combining Journals means concatenating them, basically. The parse state resets at the start of each file, which means that directives & aliases do not cross file boundaries. (The final parse state saved in the Journal does span all files, however.)
As with readJournalFile,
file paths can optionally have a READER: prefix,
and the mformat
, mrulesfile, and
assrt@ arguments are supported
(and these are applied to all files).
readJournalFile :: Maybe StorageFormat -> Maybe FilePath -> Bool -> PrefixedFilePath -> IO (Either String Journal) Source #
readJournalFile mformat mrulesfile assrt prefixedfile
Read a Journal from this file, or from stdin if the file path is -, or return an error message. The file path can have a READER: prefix.
The reader (data format) is chosen based on (in priority order):
the mformat
argument;
the file path's READER: prefix, if any;
a recognised file name extension (in readJournal);
if none of these identify a known reader, all built-in readers are tried in turn.
A CSV conversion rules file (mrulesfiles
) can be specified to help convert CSV data.
Optionally, any balance assertions in the journal can be checked (assrt
).
splitReaderPrefix :: PrefixedFilePath -> (Maybe String, FilePath) Source #
If a filepath is prefixed by one of the reader names and a colon, split that off. Eg "csv:-" -> (Just "csv", "-").
requireJournalFileExists :: FilePath -> IO () Source #
If the specified journal file does not exist (and is not "-"), give a helpful error and quit.
ensureJournalFileExists :: FilePath -> IO () Source #
Ensure there is a journal file at the given path, creating an empty one if needed.
readJournal' :: Text -> IO Journal Source #
Read a Journal from the given text trying all readers in turn, or throw an error.
readJournal :: Maybe StorageFormat -> Maybe FilePath -> Bool -> Maybe FilePath -> Text -> IO (Either String Journal) Source #
readJournal mformat mrulesfile assrt mfile txt
Read a Journal from some text, or return an error message.
The reader (data format) is chosen based on (in priority order):
the mformat
argument;
a recognised file name extension in mfile
(if provided).
If none of these identify a known reader, all built-in readers are tried in turn
(returning the first one's error message if none of them succeed).
A CSV conversion rules file (mrulesfiles
) can be specified to help convert CSV data.
Optionally, any balance assertions in the journal can be checked (assrt
).
type BalanceReportItem = (AccountName, AccountName, Int, MixedAmount) Source #
type BalanceReport = ([BalanceReportItem], MixedAmount) Source #
A simple single-column balance report. It has:
- a list of items, one per account, each containing:
- the full account name
- the Ledger-style elided short account name (the leaf account name, prefixed by any boring parents immediately above); or with --flat, the full account name again
- the number of indentation steps for rendering a Ledger-style account tree, taking into account elided boring parents, --no-elide and --flat
- an amount
- the total of all amounts
flatShowsExclusiveBalance :: Bool Source #
When true (the default), this makes balance --flat reports and their implementation clearer. Single/multi-col balance reports currently aren't all correct if this is false.
balanceReport :: ReportOpts -> Query -> Journal -> BalanceReport Source #
Enabling this makes balance --flat --empty also show parent accounts without postings, in addition to those with postings and a zero balance. Disabling it shows only the latter. No longer supported, but leave this here for a bit. flatShowsPostinglessAccounts = True
Generate a simple balance report, containing the matched accounts and their balances (change of balance) during the specified period. This is like PeriodChangeReport with a single column (but more mature, eg this can do hierarchical display).
type MultiBalanceReportRow = (AccountName, AccountName, Int, [MixedAmount], MixedAmount, MixedAmount) Source #
newtype MultiBalanceReport Source #
A multi balance report is a balance report with one or more columns. It has:
- a list of each column's period (date span)
- a list of rows, each containing:
- the full account name
- the leaf account name
- the account's depth
- a list of amounts, one for each column
- the total of the row's amounts
- the average of the row's amounts
- the column totals and the overall total and average
The meaning of the amounts depends on the type of multi balance
report, of which there are three: periodic, cumulative and historical
(see BalanceType
and Hledger.Cli.Commands.Balance).
Constructors
MultiBalanceReport ([DateSpan], [MultiBalanceReportRow], MultiBalanceReportTotals) |
Instances
Show MultiBalanceReport Source # | |
Defined in Hledger.Reports.MultiBalanceReports Methods showsPrec :: Int -> MultiBalanceReport -> ShowS # show :: MultiBalanceReport -> String # showList :: [MultiBalanceReport] -> ShowS # |
singleBalanceReport :: ReportOpts -> Query -> Journal -> BalanceReport Source #
Generates a single column BalanceReport like balanceReport, but uses multiBalanceReport, so supports --historical. TODO Does not support boring parent eliding or --flat yet.
multiBalanceReport :: ReportOpts -> Query -> Journal -> MultiBalanceReport Source #
Generate a multicolumn balance report for the matched accounts, showing the change of balance, accumulated balance, or historical balance in each of the specified periods.
tests_Hledger :: Test Source #