Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 NormalSign
- data Account = Account {
- aname :: AccountName
- acode :: Maybe AccountCode
- aebalance :: MixedAmount
- asubs :: [Account]
- anumpostings :: Int
- aibalance :: MixedAmount
- aparent :: Maybe Account
- aboring :: Bool
- type StorageFormat = String
- type ParsedJournal = Journal
- data Journal = Journal {
- jparsedefaultyear :: Maybe Year
- jparsedefaultcommodity :: Maybe (CommoditySymbol, AmountStyle)
- jparseparentaccounts :: [AccountName]
- jparsealiases :: [AccountAlias]
- jparsetimeclockentries :: [TimeclockEntry]
- jaccounts :: [(AccountName, Maybe AccountCode)]
- 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 {
- ptperiodexpr :: Text
- ptinterval :: Interval
- ptspan :: DateSpan
- ptstatus :: Status
- ptcode :: Text
- ptdescription :: Text
- ptcomment :: Text
- pttags :: [Tag]
- 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 DateTag = (TagName, Day)
- 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 AccountCode = Int
- 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)
- nullperiodictransaction :: PeriodicTransaction
- 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
- showPeriodMonthAbbrev :: 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
- data CustomErr
- type JournalParser m a = StateT Journal (ParsecT CustomErr Text m) a
- type TextParser m a = ParsecT CustomErr Text m a
- type SimpleTextParser = Parsec CustomErr Text
- type SimpleStringParser a = Parsec CustomErr String a
- choice' :: [TextParser m a] -> TextParser m a
- choiceInState :: [StateT s (ParsecT CustomErr Text m) a] -> StateT s (ParsecT CustomErr 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 CustomErr Text m) a -> Text -> m (Either (ParseError Char CustomErr) 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
- showDateParseError :: (Show t, Show e) => ParseError t e -> String
- nonspace :: TextParser m Char
- isNonNewlineSpace :: Char -> Bool
- spacenonewline :: (Stream s, Char ~ Token s) => ParsecT CustomErr 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
- escapeDoubleQuotes :: Text -> Text
- stripquotes :: Text -> Text
- textUnbracket :: Text -> Text
- textConcatTopPadded :: [Text] -> Text
- fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text
- textPadLeftWide :: Int -> Text -> Text
- textPadRightWide :: Int -> Text -> Text
- textTakeWidth :: Int -> Text -> Text
- textWidth :: Text -> Int
- tests_Hledger_Utils_Text :: Test
- 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
- readFilePortably :: FilePath -> IO Text
- readFileOrStdinPortably :: String -> IO Text
- readHandlePortably :: Handle -> 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]
- tests_Hledger_Utils :: Test
- 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
- showDate :: Day -> String
- showDateSpan :: DateSpan -> String
- showDateSpanMonthAbbrev :: 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
- spanIntervalIntersect :: Interval -> DateSpan -> DateSpan -> DateSpan
- spanDefaultsFrom :: DateSpan -> DateSpan -> DateSpan
- spansUnion :: [DateSpan] -> DateSpan
- spanUnion :: DateSpan -> DateSpan -> DateSpan
- parsePeriodExpr :: Day -> Text -> Either (ParseError Char CustomErr) (Interval, DateSpan)
- parsePeriodExpr' :: Day -> Text -> (Interval, DateSpan)
- maybePeriod :: Day -> Text -> Maybe (Interval, DateSpan)
- fixSmartDateStr :: Day -> Text -> String
- fixSmartDateStrEither :: Day -> Text -> Either (ParseError Char CustomErr) String
- fixSmartDateStrEither' :: Day -> Text -> Either (ParseError Char CustomErr) Day
- fixSmartDate :: Day -> SmartDate -> Day
- prevday :: Day -> Day
- parsedateM :: String -> Maybe Day
- parsedate :: String -> Day
- smartdate :: TextParser m SmartDate
- datesepchars :: [Char]
- datesepchar :: TextParser m Char
- isDateSepChar :: Char -> Bool
- failIfInvalidYear :: Monad m => String -> m ()
- failIfInvalidMonth :: Monad m => String -> m ()
- failIfInvalidDay :: Monad m => String -> m ()
- periodexprp :: Day -> TextParser m (Interval, DateSpan)
- mkdatespan :: String -> String -> DateSpan
- nulldatespan :: DateSpan
- nulldate :: Day
- nonsimplecommoditychars :: [Char]
- isNonsimpleCommodityChar :: Char -> Bool
- 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
- styleAmount :: Map CommoditySymbol AmountStyle -> Amount -> Amount
- 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
- styleMixedAmount :: Map CommoditySymbol AmountStyle -> MixedAmount -> MixedAmount
- 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
- showMarketPrice :: MarketPrice -> String
- tests_Hledger_Data_MarketPrice :: Test
- acctsepchar :: Char
- acctsep :: Text
- accountNameComponents :: AccountName -> [Text]
- accountNameFromComponents :: [Text] -> AccountName
- accountLeafName :: AccountName -> Text
- accountSummarisedName :: AccountName -> Text
- accountNameLevel :: AccountName -> Int
- unbudgetedAccountName :: Text
- 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
- 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
- runModifierTransaction :: Query -> ModifierTransaction -> Transaction -> Transaction
- mtvaluequery :: ModifierTransaction -> Day -> Query
- jdatespan :: Journal -> DateSpan
- runPeriodicTransaction :: PeriodicTransaction -> DateSpan -> [Transaction]
- checkPeriodicTransactionStartDate :: Interval -> DateSpan -> Text -> Maybe String
- periodTransactionInterval :: PeriodicTransaction -> Maybe Interval
- 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
- 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
- journalCommodityStyles :: Journal -> Map CommoditySymbol AmountStyle
- 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
- nullacct :: Account
- accountsFromPostings :: [Posting] -> [Account]
- nameTreeToAccount :: AccountName -> FastTree AccountName -> Account
- tieAccountParents :: Account -> Account
- accountSetCodeFrom :: Journal -> 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 :: NormalSign -> Account -> Account
- sortAccountTreeByAccountCodeAndName :: Account -> Account
- accountCodeAndNameForSort :: Account -> (AccountCode, AccountName)
- lookupAccount :: AccountName -> [Account] -> Maybe Account
- printAccounts :: Account -> IO ()
- showAccounts :: Account -> String
- showAccountsBoringFlag :: Account -> String
- showAccountDebug :: PrintfType t => Account -> t
- tests_Hledger_Data_Account :: 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
- data ReportItemField
- data StringFormatComponent
- data StringFormat
- parseStringFormat :: String -> Either String StringFormat
- defaultStringFormatStyle :: [StringFormatComponent] -> StringFormat
- tests_Hledger_Data_StringFormat :: Test
- tests_Hledger_Data :: Test
- type PeriodicReportRow a = (AccountName, AccountName, Int, [a], a, a)
- data PeriodicReport a = PeriodicReport ([DateSpan], [PeriodicReportRow a], PeriodicReportRow a)
- type Average = MixedAmount
- type Total = MixedAmount
- type Balance = MixedAmount
- type Change = MixedAmount
- type Percentage = Decimal
- 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
- invert_ :: Bool
- normalbalance_ :: Maybe NormalSign
- color_ :: Bool
- forecast_ :: Bool
- data AccountListMode
- data BalanceType
- type FormatStr = String
- defreportopts :: ReportOpts
- rawOptsToReportOpts :: RawOpts -> IO ReportOpts
- checkReportOpts :: ReportOpts -> ReportOpts
- intervalFromRawOpts :: RawOpts -> Interval
- 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]
- reportSpan :: Journal -> ReportOpts -> IO DateSpan
- 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 {}
- data Reader = Reader {
- rFormat :: StorageFormat
- rExtensions :: [String]
- rParser :: InputOpts -> FilePath -> Text -> ExceptT String IO Journal
- rExperimental :: Bool
- definputopts :: InputOpts
- rawOptsToInputOpts :: RawOpts -> InputOpts
- runTextParser :: TextParser Identity a -> Text -> Either (ParseError Char CustomErr) a
- rtp :: TextParser Identity a -> Text -> Either (ParseError Char CustomErr) a
- runJournalParser :: Monad m => JournalParser m a -> Text -> m (Either (ParseError Char CustomErr) a)
- rjp :: Monad m => JournalParser m a -> Text -> m (Either (ParseError Char CustomErr) a)
- genericSourcePos :: SourcePos -> GenericSourcePos
- journalSourcePos :: SourcePos -> SourcePos -> GenericSourcePos
- generateAutomaticPostings :: Journal -> Journal
- parseAndFinaliseJournal :: JournalParser IO ParsedJournal -> InputOpts -> FilePath -> Text -> ExceptT String IO Journal
- parseAndFinaliseJournal' :: JournalParser Identity ParsedJournal -> InputOpts -> 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
- statusp :: TextParser m Status
- codep :: TextParser m Text
- descriptionp :: TextParser m Text
- datep :: JournalParser m Day
- datetimep :: JournalParser m LocalTime
- secondarydatep :: Day -> TextParser m Day
- modifiedaccountnamep :: JournalParser m AccountName
- accountnamep :: TextParser m AccountName
- singlespacedtextp :: TextParser m Text
- singlespacep :: ParsecT CustomErr Text m ()
- spaceandamountormissingp :: JournalParser m MixedAmount
- amountp :: JournalParser m Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- commoditysymbolp :: TextParser m CommoditySymbol
- priceamountp :: JournalParser m Price
- partialbalanceassertionp :: JournalParser m BalanceAssertion
- fixedlotpricep :: JournalParser m (Maybe Amount)
- numberp :: Maybe AmountStyle -> TextParser m (Quantity, Int, Maybe Char, Maybe DigitGroupStyle)
- fromRawNumber :: RawNumber -> Maybe Int -> Either String (Quantity, Int, Maybe Char, Maybe DigitGroupStyle)
- rawnumberp :: TextParser m (Either AmbiguousNumber RawNumber)
- multilinecommentp :: TextParser m ()
- emptyorcommentlinep :: TextParser m ()
- followingcommentp :: TextParser m Text
- transactioncommentp :: TextParser m (Text, [Tag])
- postingcommentp :: Maybe Year -> TextParser m (Text, [Tag], Maybe Day, Maybe Day)
- bracketeddatetagsp :: Maybe Year -> TextParser m [(TagName, Day)]
- postingp :: Maybe Year -> JournalParser m Posting
- type PrefixedFilePath = FilePath
- defaultJournal :: IO Journal
- defaultJournalPath :: IO String
- splitReaderPrefix :: PrefixedFilePath -> (Maybe String, FilePath)
- requireJournalFileExists :: FilePath -> IO ()
- ensureJournalFileExists :: FilePath -> IO ()
- readJournal' :: Text -> IO Journal
- readJournalFiles :: InputOpts -> [FilePath] -> IO (Either String Journal)
- readJournalFile :: InputOpts -> PrefixedFilePath -> IO (Either String Journal)
- readJournal :: InputOpts -> Maybe FilePath -> Text -> 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)
- multiBalanceReport :: ReportOpts -> Query -> Journal -> MultiBalanceReport
- mbrNormaliseSign :: NormalSign -> MultiBalanceReport -> MultiBalanceReport
- mbrNegate :: MultiBalanceReport -> MultiBalanceReport
- multiBalanceReportSpan :: MultiBalanceReport -> DateSpan
- balanceReportFromMultiBalanceReport :: ReportOpts -> Query -> Journal -> BalanceReport
- tableAsText :: ReportOpts -> (a -> String) -> Table String String a -> String
- tests_Hledger_Reports_MultiBalanceReport :: Test
- type BudgetReport = PeriodicReport (Maybe Change, Maybe BudgetGoal)
- type BudgetAverage = Average
- type BudgetTotal = Total
- type BudgetGoal = Change
- budgetReport :: ReportOpts -> Bool -> Bool -> DateSpan -> Day -> Journal -> BudgetReport
- budgetJournal :: Bool -> ReportOpts -> DateSpan -> Journal -> Journal
- budgetRollUp :: [AccountName] -> Bool -> Journal -> Journal
- combineBudgetAndActual :: MultiBalanceReport -> MultiBalanceReport -> BudgetReport
- budgetReportSpan :: BudgetReport -> DateSpan
- budgetReportAsText :: ReportOpts -> BudgetReport -> String
- budgetReportAsTable :: ReportOpts -> BudgetReport -> Table String String (Maybe MixedAmount, Maybe MixedAmount)
- maybeAccountNameDrop :: ReportOpts -> AccountName -> AccountName
- tests_Hledger_Reports_BudgetReport :: 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 NormalSign Source #
Whether an account's balance is normally a positive number (in accounting terms, a debit balance) or a negative number (credit balance). Assets and expenses are normally positive (debit), while liabilities, equity and income are normally negative (credit). https://en.wikipedia.org/wiki/Normal_balance
Instances
Eq NormalSign Source # | |
Defined in Hledger.Data.Types (==) :: NormalSign -> NormalSign -> Bool # (/=) :: NormalSign -> NormalSign -> Bool # | |
Data NormalSign Source # | |
Defined in Hledger.Data.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NormalSign -> c NormalSign # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NormalSign # toConstr :: NormalSign -> Constr # dataTypeOf :: NormalSign -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NormalSign) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NormalSign) # gmapT :: (forall b. Data b => b -> b) -> NormalSign -> NormalSign # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NormalSign -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NormalSign -> r # gmapQ :: (forall d. Data d => d -> u) -> NormalSign -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NormalSign -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NormalSign -> m NormalSign # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NormalSign -> m NormalSign # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NormalSign -> m NormalSign # | |
Show NormalSign Source # | |
Defined in Hledger.Data.Types showsPrec :: Int -> NormalSign -> ShowS # show :: NormalSign -> String # showList :: [NormalSign] -> ShowS # |
An account, with name, balances and links to parent/subaccounts which let you walk up or down the account tree.
Account | |
|
Instances
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).
Journal | |
|
Instances
data MarketPrice Source #
MarketPrice | |
|
Instances
data TimeclockEntry Source #
Instances
data TimeclockCode Source #
Instances
data PeriodicTransaction Source #
PeriodicTransaction | |
|
Instances
data ModifierTransaction Source #
Instances
data Transaction Source #
Transaction | |
|
Instances
data GenericSourcePos Source #
The position of parse errors (eg), like parsec's SourcePos but generic.
GenericSourcePos FilePath Int Int | file path, 1-based line number and 1-based column number. |
JournalSourcePos FilePath (Int, Int) | file path, inclusive range of 1-based line numbers (first, last). |
Instances
Posting | |
|
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 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 #
Instances
Eq PostingType Source # | |
Defined in Hledger.Data.Types (==) :: PostingType -> PostingType -> Bool # (/=) :: PostingType -> PostingType -> Bool # | |
Data PostingType Source # | |
Defined in Hledger.Data.Types 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 showsPrec :: Int -> PostingType -> ShowS # show :: PostingType -> String # showList :: [PostingType] -> ShowS # | |
Generic PostingType Source # | |
Defined in Hledger.Data.Types type Rep PostingType :: * -> * # from :: PostingType -> Rep PostingType x # to :: Rep PostingType x -> PostingType # | |
NFData PostingType Source # | |
Defined in Hledger.Data.Types rnf :: PostingType -> () # | |
type Rep PostingType Source # | |
Defined in Hledger.Data.Types type Rep PostingType = D1 (MetaData "PostingType" "Hledger.Data.Types" "hledger-lib-1.10-FqAYt0yboj6rHcXZ5x5Op" False) (C1 (MetaCons "RegularPosting" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "VirtualPosting" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "BalancedVirtualPosting" PrefixI False) (U1 :: * -> *))) |
newtype MixedAmount Source #
Instances
Amount | |
|
Instances
Eq Amount Source # | |
Data Amount Source # | |
Defined in Hledger.Data.Types 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.10-FqAYt0yboj6rHcXZ5x5Op" 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))))) |
Instances
Eq Commodity Source # | |
Data Commodity Source # | |
Defined in Hledger.Data.Types 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.10-FqAYt0yboj6rHcXZ5x5Op" 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].
Instances
data AmountStyle Source #
Display style for an amount.
AmountStyle | |
|
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.
Instances
Eq Price Source # | |
Data Price Source # | |
Defined in Hledger.Data.Types 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.10-FqAYt0yboj6rHcXZ5x5Op" 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 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 #
Instances
type AccountCode = Int Source #
type AccountName = Text Source #
NoInterval | |
Days Int | |
Weeks Int | |
Months Int | |
Quarters Int | |
Years Int | |
DayOfMonth Int | |
WeekdayOfMonth Int Int | |
DayOfWeek Int | |
DayOfYear Int Int |
Instances
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 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.10-FqAYt0yboj6rHcXZ5x5Op" 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)))) |
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"
showPeriodMonthAbbrev :: Period -> String Source #
Like showPeriod, but if it's a month period show just the 3 letter month name abbreviation for the current locale.
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 #
A custom error type for the parser. The type is specialized to
parsers of Text
streams.
type JournalParser m a = StateT Journal (ParsecT CustomErr 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 CustomErr Text m) a] -> StateT s (ParsecT CustomErr 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 CustomErr Text m) a -> Text -> m (Either (ParseError Char CustomErr) 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 #
showDateParseError :: (Show t, Show e) => ParseError t e -> String Source #
nonspace :: TextParser m Char Source #
isNonNewlineSpace :: Char -> Bool 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.
escapeDoubleQuotes :: Text -> Text Source #
stripquotes :: Text -> Text Source #
Strip one matching pair of single or double quotes on the ends of a string.
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.
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.
readFilePortably :: FilePath -> IO Text Source #
Read text from a file, handling any of the usual line ending conventions, using the system locale's text encoding, ignoring any utf8 BOM prefix (as seen in paypal's 2018 CSV, eg) if that encoding is utf8.
readFileOrStdinPortably :: String -> IO Text Source #
Like readFilePortably, but read from standard input if the path is "-".
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.
showDateSpan :: DateSpan -> String Source #
Render a datespan as a display string, abbreviating into a compact form if possible.
showDateSpanMonthAbbrev :: DateSpan -> String Source #
Like showDateSpan, but show month spans as just the abbreviated month name in the current locale.
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 consecutive whole spans of the specified interval which fully encompass the original span (and a little more when necessary). If no interval is specified, the original span is returned. If the original span is the null date span, ie unbounded, the null date span is returned. If the original span is empty, eg if the end date is <= the start date, no spans are 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
[]>>>
t (Quarters 1) "2008/01/01" "2008/01/01"
[]>>>
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.
For non-intersecting spans, gives an empty span beginning on the second's start date:
>>> mkdatespan "2018-01-01" "2018-01-03" spanIntersect
mkdatespan "2018-01-03" "2018-01-05"
DateSpan 20180103-20180102
spanIntervalIntersect :: Interval -> DateSpan -> DateSpan -> DateSpan Source #
Calculate the intersection of two DateSpans, adjusting the start date so the interval is preserved.
>>>
let intervalIntersect = spanIntervalIntersect (Days 3)
>>>
mkdatespan "2018-01-01" "2018-01-03" `intervalIntersect` mkdatespan "2018-01-01" "2018-01-05"
DateSpan 2018/01/01-2018/01/02>>>
mkdatespan "2018-01-01" "2018-01-05" `intervalIntersect` mkdatespan "2018-01-02" "2018-01-05"
DateSpan 2018/01/04>>>
mkdatespan "2018-01-01" "2018-01-05" `intervalIntersect` mkdatespan "2018-01-03" "2018-01-05"
DateSpan 2018/01/04>>>
mkdatespan "2018-01-01" "2018-01-05" `intervalIntersect` mkdatespan "2018-01-04" "2018-01-05"
DateSpan 2018/01/04>>>
mkdatespan "2018-01-01" "2018-01-05" `intervalIntersect` mkdatespan "2017-12-01" "2018-01-05"
DateSpan 2018/01/01-2018/01/04
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 CustomErr) (Interval, DateSpan) Source #
Parse a period expression to an Interval and overall DateSpan using the provided reference date, or return a parse error.
parsePeriodExpr' :: Day -> Text -> (Interval, DateSpan) Source #
Like parsePeriodExpr, but call error' on failure.
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 CustomErr) String Source #
A safe version of fixSmartDateStr.
fixSmartDateStrEither' :: Day -> Text -> Either (ParseError Char CustomErr) 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 :: TextParser m SmartDate Source #
Parse a date in any of the formats allowed in Ledger's period expressions, and some others. Assumes any text in the parse stream has been lowercased. Returns a SmartDate, to be converted to a full date later (see fixSmartDate).
Examples:
2004 (start of year, which must have 4+ digits) 2004/10 (start of month, which must be 1-12) 2004/10/1 (exact date, day must be 1-31) 10/1 (month and day in current year) 21 (day in current month) october, oct (start of month in current year) yesterday, today, tomorrow (-1, 0, 1 days from today) last/this/next day/week/month/quarter/year (-1, 0, 1 periods from the current period) 20181201 (8 digit YYYYMMDD with valid year month and day) 201812 (6 digit YYYYMM with valid year and month)
Note malformed digit sequences might give surprising results:
201813 (6 digits with an invalid month is parsed as start of 6-digit year) 20181301 (8 digits with an invalid month is parsed as start of 8-digit year) 20181232 (8 digits with an invalid day gives an error) 201801012 (9+ digits beginning with a valid YYYYMMDD gives an error)
Eg:
YYYYMMDD is parsed as year-month-date if those parts are valid (>=4 digits, 1-12, and 1-31 respectively): >>> parsewith (smartdate <* eof) "20181201" Right ("2018","12","01")
YYYYMM is parsed as year-month-01 if year and month are valid: >>> parsewith (smartdate <* eof) "201804" Right ("2018","04","01")
With an invalid month, it's parsed as a year: >>> parsewith (smartdate <* eof) "201813" Right ("201813","","")
A 9+ digit number beginning with valid YYYYMMDD gives an error: >>> parsewith (smartdate <* eof) "201801012" Left (...)
Big numbers not beginning with a valid YYYYMMDD are parsed as a year: >>> parsewith (smartdate <* eof) "201813012" Right ("201813012","","")
datesepchars :: [Char] Source #
datesepchar :: TextParser m Char Source #
isDateSepChar :: Char -> Bool Source #
failIfInvalidYear :: Monad m => String -> m () Source #
failIfInvalidMonth :: Monad m => String -> m () Source #
failIfInvalidDay :: Monad m => String -> m () Source #
periodexprp :: Day -> TextParser m (Interval, DateSpan) Source #
>>>
let p = parsePeriodExpr (parsedate "2008/11/26")
>>>
p "from Aug to Oct"
Right (NoInterval,DateSpan 2008/08/01-2008/09/30)>>>
p "aug to oct"
Right (NoInterval,DateSpan 2008/08/01-2008/09/30)>>>
p "every 3 days in Aug"
Right (Days 3,DateSpan 2008/08)>>>
p "daily from aug"
Right (Days 1,DateSpan 2008/08/01-)>>>
p "every week to 2009"
Right (Weeks 1,DateSpan -2008/12/31)>>>
p "every 2nd day of month"
Right (DayOfMonth 2,DateSpan -)>>>
p "every 2nd day"
Right (DayOfMonth 2,DateSpan -)>>>
p "every 2nd day 2009-"
Right (DayOfMonth 2,DateSpan 2009/01/01-)>>>
p "every 29th Nov"
Right (DayOfYear 11 29,DateSpan -)>>>
p "every 29th nov -2009"
Right (DayOfYear 11 29,DateSpan -2008/12/31)>>>
p "every nov 29th"
Right (DayOfYear 11 29,DateSpan -)>>>
p "every Nov 29th 2009-"
Right (DayOfYear 11 29,DateSpan 2009/01/01-)>>>
p "every 11/29 from 2009"
Right (DayOfYear 11 29,DateSpan 2009/01/01-)>>>
p "every 2nd Thursday of month to 2009"
Right (WeekdayOfMonth 2 4,DateSpan -2008/12/31)>>>
p "every 1st monday of month to 2009"
Right (WeekdayOfMonth 1 1,DateSpan -2008/12/31)>>>
p "every tue"
Right (DayOfWeek 2,DateSpan -)>>>
p "every 2nd day of week"
Right (DayOfWeek 2,DateSpan -)>>>
p "every 2nd day of month"
Right (DayOfMonth 2,DateSpan -)>>>
p "every 2nd day"
Right (DayOfMonth 2,DateSpan -)>>>
p "every 2nd day 2009-"
Right (DayOfMonth 2,DateSpan 2009/01/01-)>>>
p "every 2nd day of month 2009-"
Right (DayOfMonth 2,DateSpan 2009/01/01-)
mkdatespan :: String -> String -> DateSpan Source #
Make a datespan from two valid date strings parseable by parsedate (or raise an error). Eg: mkdatespan "201111" "20111231".
isNonsimpleCommodityChar :: Char -> Bool Source #
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.
amountstyle :: AmountStyle Source #
Default amount style
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.
styleAmount :: Map CommoditySymbol AmountStyle -> Amount -> Amount Source #
Given a map of standard amount display styles, apply the appropriate one to this amount. If there's no standard style for this amount's commodity, return the amount unchanged.
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 ?
styleMixedAmount :: Map CommoditySymbol AmountStyle -> MixedAmount -> MixedAmount Source #
Given a map of standard amount display styles, apply the appropriate ones to each individual amount.
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, without showing any transaction prices.
cshowMixedAmountWithoutPrice :: MixedAmount -> String Source #
Colour version of showMixedAmountWithoutPrice. Any individual Amount which is negative is wrapped in ANSI codes to make it display in red.
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 #
showMarketPrice :: MarketPrice -> String Source #
Get the string representation of an market price, based on its commodity's display settings.
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 #
unbudgetedAccountName :: Text Source #
A top-level account prefixed to some accounts in budget reports. Defined here so it can be ignored by accountNameDrop.
accountNameDrop :: Int -> AccountName -> AccountName Source #
Remove some number of account name components from the front of the account name. If the special "unbudgeted" top-level account is present, it is preserved and dropping affects the rest of the account name.
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 ?
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 #
:: 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.
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 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.
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 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.
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.
>>>
_ptgen "monthly from 2017/1 to 2017/4"
2017/01/01 ; recur: monthly from 2017/1 to 2017/4 a $1.00 2017/02/01 ; recur: monthly from 2017/1 to 2017/4 a $1.00 2017/03/01 ; recur: monthly from 2017/1 to 2017/4 a $1.00
>>>
_ptgen "monthly from 2017/1 to 2017/5"
2017/01/01 ; recur: monthly from 2017/1 to 2017/5 a $1.00 2017/02/01 ; recur: monthly from 2017/1 to 2017/5 a $1.00 2017/03/01 ; recur: monthly from 2017/1 to 2017/5 a $1.00 2017/04/01 ; recur: monthly from 2017/1 to 2017/5 a $1.00
>>>
_ptgen "every 2nd day of month from 2017/02 to 2017/04"
2017/01/02 ; recur: every 2nd day of month from 2017/02 to 2017/04 a $1.00 2017/02/02 ; recur: every 2nd day of month from 2017/02 to 2017/04 a $1.00 2017/03/02 ; recur: every 2nd day of month from 2017/02 to 2017/04 a $1.00
>>>
_ptgen "every 30th day of month from 2017/1 to 2017/5"
2016/12/30 ; recur: every 30th day of month from 2017/1 to 2017/5 a $1.00 2017/01/30 ; recur: every 30th day of month from 2017/1 to 2017/5 a $1.00 2017/02/28 ; recur: every 30th day of month from 2017/1 to 2017/5 a $1.00 2017/03/30 ; recur: every 30th day of month from 2017/1 to 2017/5 a $1.00 2017/04/30 ; recur: every 30th day of month from 2017/1 to 2017/5 a $1.00
>>>
_ptgen "every 2nd Thursday of month from 2017/1 to 2017/4"
2016/12/08 ; recur: every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00 2017/01/12 ; recur: every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00 2017/02/09 ; recur: every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00 2017/03/09 ; recur: every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00
>>>
_ptgen "every nov 29th from 2017 to 2019"
2016/11/29 ; recur: every nov 29th from 2017 to 2019 a $1.00 2017/11/29 ; recur: every nov 29th from 2017 to 2019 a $1.00 2018/11/29 ; recur: every nov 29th from 2017 to 2019 a $1.00
>>>
_ptgen "2017/1"
2017/01/01 ; recur: 2017/1 a $1.00
>>>
_ptgen ""
*** Exception: failed to parse... ...
>>>
_ptgen "weekly from 2017"
*** Exception: Unable to generate transactions according to "weekly from 2017" because 2017-01-01 is not a first day of the week
>>>
_ptgen "monthly from 2017/5/4"
*** Exception: Unable to generate transactions according to "monthly from 2017/5/4" because 2017-05-04 is not a first day of the month
>>>
_ptgen "every quarter from 2017/1/2"
*** Exception: Unable to generate transactions according to "every quarter from 2017/1/2" because 2017-01-02 is not a first day of the quarter
>>>
_ptgen "yearly from 2017/1/14"
*** Exception: Unable to generate transactions according to "yearly from 2017/1/14" because 2017-01-14 is not a first day of the year
>>>
let reportperiod="daily from 2018/01/03" in let (i,s) = parsePeriodExpr' nulldate reportperiod in runPeriodicTransaction (nullperiodictransaction{ptperiodexpr=reportperiod, ptspan=s, ptinterval=i, ptpostings=["a" `post` usd 1]}) (DateSpan (Just $ parsedate "2018-01-01") (Just $ parsedate "2018-01-03"))
[]
checkPeriodicTransactionStartDate :: Interval -> DateSpan -> Text -> Maybe String Source #
Check that this date span begins at a boundary of this interval, or return an explanatory error message including the provided period expression (from which the span and interval are derived).
periodTransactionInterval :: PeriodicTransaction -> Maybe Interval Source #
What is the interval of this PeriodicTransaction
s period expression, if it can be parsed ?
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.
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, standardise 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.
journalCommodityStyles :: Journal -> Map CommoditySymbol AmountStyle Source #
Get all the amount styles defined in this journal, either declared by a commodity directive or inferred from amounts, as a map from symbol to style. Styles declared by commodity directives take precedence, and these also are guaranteed to know their decimal point character.
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.
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.
accountSetCodeFrom :: Journal -> Account -> Account Source #
Look up an account's numeric code, if any, from the Journal and set it.
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 :: NormalSign -> 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, affecting the sort order. Ie, if balances are normally negative, then the most negative balances sort first, and vice versa.
sortAccountTreeByAccountCodeAndName :: Account -> Account Source #
Sort each level of an account tree first by the account code if any, with the empty account code sorting last, and then by the account name.
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 #
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.
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.
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 (==) :: ReportItemField -> ReportItemField -> Bool # (/=) :: ReportItemField -> ReportItemField -> Bool # | |
Show ReportItemField Source # | |
Defined in Hledger.Data.StringFormat showsPrec :: Int -> ReportItemField -> ShowS # show :: ReportItemField -> String # showList :: [ReportItemField] -> ShowS # |
data StringFormatComponent Source #
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 (==) :: StringFormatComponent -> StringFormatComponent -> Bool # (/=) :: StringFormatComponent -> StringFormatComponent -> Bool # | |
Show StringFormatComponent Source # | |
Defined in Hledger.Data.StringFormat 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.
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 (==) :: StringFormat -> StringFormat -> Bool # (/=) :: StringFormat -> StringFormat -> Bool # | |
Show StringFormat Source # | |
Defined in Hledger.Data.StringFormat 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.
type PeriodicReportRow a = (AccountName, AccountName, Int, [a], a, a) Source #
data PeriodicReport a Source #
A generic tabular report of some value, where each row corresponds to an account and each column is a date period. The column periods are usually consecutive subperiods formed by splitting the overall report period by some report interval (daily, weekly, etc.) Depending on the value type, this can be a report of balance changes, ending balances, budget performance, etc. Successor to MultiBalanceReport.
PeriodicReport ([DateSpan], [PeriodicReportRow a], PeriodicReportRow a) |
Instances
Show a => Show (PeriodicReport a) Source # | |
Defined in Hledger.Reports.ReportTypes showsPrec :: Int -> PeriodicReport a -> ShowS # show :: PeriodicReport a -> String # showList :: [PeriodicReport a] -> ShowS # |
= MixedAmount | The sum of |
= MixedAmount | An ending balance as of some date. |
= MixedAmount | A change in balance during a certain period. |
type Percentage = Decimal Source #
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.
ReportOpts | |
|
Instances
Data ReportOpts Source # | |
Defined in Hledger.Reports.ReportOptions 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 showsPrec :: Int -> ReportOpts -> ShowS # show :: ReportOpts -> String # showList :: [ReportOpts] -> ShowS # | |
Default ReportOpts Source # | |
Defined in Hledger.Reports.ReportOptions 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.
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
checkReportOpts :: ReportOpts -> ReportOpts Source #
Do extra validation of report options, raising an error if there's a problem.
intervalFromRawOpts :: RawOpts -> Interval Source #
Get the report interval, if any, specified by the last of -p/--period, -D--daily, -W--weekly, -M/--monthly etc. options.
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.
reportSpan :: Journal -> ReportOpts -> IO DateSpan Source #
The effective report span is the start and end dates specified by options or queries, or otherwise the earliest and latest transaction or posting dates in the journal. If no dates are specified by options/queries and the journal is empty, returns the null date span. 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.
InputOpts | |
|
Instances
Data InputOpts Source # | |
Defined in Hledger.Read.Common 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 |
A hledger journal reader is a triple of storage format name, a detector of that format, and a parser from that format to Journal.
Reader | |
|
runTextParser :: TextParser Identity a -> Text -> Either (ParseError Char CustomErr) a Source #
Run a string parser with no state in the identity monad.
rtp :: TextParser Identity a -> Text -> Either (ParseError Char CustomErr) a Source #
Run a string parser with no state in the identity monad.
runJournalParser :: Monad m => JournalParser m a -> Text -> m (Either (ParseError Char CustomErr) a) Source #
Run a journal parser with a null journal-parsing state.
rjp :: Monad m => JournalParser m a -> Text -> m (Either (ParseError Char CustomErr) a) Source #
Run a journal parser with a null journal-parsing state.
journalSourcePos :: SourcePos -> SourcePos -> GenericSourcePos Source #
Construct a generic start & end line parse position from start and end megaparsec SourcePos's.
generateAutomaticPostings :: Journal -> Journal Source #
Generate Automatic postings and add them to the current journal.
parseAndFinaliseJournal :: JournalParser IO ParsedJournal -> InputOpts -> FilePath -> Text -> ExceptT String IO Journal Source #
Given a megaparsec ParsedJournal parser, input options, file path and file content: parse and post-process a Journal, or give an error.
parseAndFinaliseJournal' :: JournalParser Identity ParsedJournal -> InputOpts -> 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 #
statusp :: TextParser m Status Source #
codep :: TextParser m Text Source #
descriptionp :: TextParser m Text 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 -> TextParser m Day Source #
modifiedaccountnamep :: JournalParser m AccountName Source #
Parse an account name (plus one following space if present), then apply any parent account prefix and/or account aliases currently in effect, in that order. (Ie first add the parent account prefix, then rewrite with aliases).
accountnamep :: TextParser m AccountName Source #
Parse an account name, plus one following space if present. 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 character, but we don't check that here.)
singlespacedtextp :: TextParser m Text Source #
Parse any text beginning with a non-whitespace character, until a double space or the end of input. Consumes one of the following spaces, if present.
singlespacep :: ParsecT CustomErr Text m () Source #
Parse one non-newline whitespace character that is not followed by another one.
spaceandamountormissingp :: 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 :: 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.
fixedlotpricep :: 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 :: RawNumber -> Maybe Int -> Either String (Quantity, Int, Maybe Char, Maybe DigitGroupStyle) Source #
Interpret a raw number as a decimal number.
Returns: - the decimal number - the precision (number of digits after the decimal point) - the decimal point character, if any - the digit group style, if any (digit group character and sizes of digit groups)
rawnumberp :: TextParser m (Either AmbiguousNumber RawNumber) Source #
Parse and interpret the structure of a number without external hints. Numbers are digit strings, possibly separated into digit groups by one of two types of separators. (1) Numbers may optionally have a decimal point, which may be either a period or comma. (2) Numbers may optionally contain digit group separators, which must all be either a period, a comma, or a space.
It is our task to deduce the identities of the decimal point and digit separator characters, based on the allowed syntax. For instance, we make use of the fact that a decimal point can occur at most once and must succeed all digit group separators.
>>>
parseTest rawnumberp "1,234,567.89"
Right (WithSeparators ',' ["1","234","567"] (Just ('.',"89")))>>>
parseTest rawnumberp "1,000"
Left (AmbiguousNumber "1" ',' "000")>>>
parseTest rawnumberp "1 000"
Right (WithSeparators ' ' ["1","000"] Nothing)
multilinecommentp :: TextParser m () Source #
emptyorcommentlinep :: TextParser m () Source #
followingcommentp :: TextParser m Text Source #
Parse the text of a (possibly multiline) comment following a journal item.
transactioncommentp :: TextParser m (Text, [Tag]) Source #
Parse a transaction comment and extract its tags.
The first line of a transaction may be followed by comments, which begin with semicolons and extend to the end of the line. Transaction comments may span multiple lines, but comment lines below the transaction must be preceeded by leading whitespace.
200011 ; a transaction comment starting on the same line ... ; extending to the next line account1 $1 account2
Tags are name-value pairs.
>>>
let getTags (_,tags) = tags
>>>
let parseTags = fmap getTags . rtp transactioncommentp
>>>
parseTags "; name1: val1, name2:all this is value2"
Right [("name1","val1"),("name2","all this is value2")]
A tag's name must be immediately followed by a colon, without separating whitespace. The corresponding value consists of all the text following the colon up until the next colon or newline, stripped of leading and trailing whitespace.
postingcommentp :: Maybe Year -> TextParser m (Text, [Tag], Maybe Day, Maybe Day) Source #
Parse a posting comment and extract its tags and dates.
Postings may be followed by comments, which begin with semicolons and extend to the end of the line. Posting comments may span multiple lines, but comment lines below the posting must be preceeded by leading whitespace.
200011 account1 $1 ; a posting comment starting on the same line ... ; extending to the next line
account2 ; a posting comment beginning on the next line
Tags are name-value pairs.
>>>
let getTags (_,tags,_,_) = tags
>>>
let parseTags = fmap getTags . rtp (postingcommentp Nothing)
>>>
parseTags "; name1: val1, name2:all this is value2"
Right [("name1","val1"),("name2","all this is value2")]
A tag's name must be immediately followed by a colon, without separating whitespace. The corresponding value consists of all the text following the colon up until the next colon or newline, stripped of leading and trailing whitespace.
Posting dates may be expressed with "date"/"date2" tags or with bracketed date syntax. Posting dates will inherit their year from the transaction date if the year is not specified. We throw parse errors on invalid dates.
>>>
let getDates (_,_,d1,d2) = (d1, d2)
>>>
let parseDates = fmap getDates . rtp (postingcommentp (Just 2000))
>>>
parseDates "; date: 1/2, date2: 1999/12/31"
Right (Just 2000-01-02,Just 1999-12-31)>>>
parseDates "; [1/2=1999/12/31]"
Right (Just 2000-01-02,Just 1999-12-31)
Example: tags, date tags, and bracketed dates >>> rtp (postingcommentp (Just 2000)) "; a:b, date:34, [=56]" Right ("a:b, date:34, [=56]n",[("a","b"),("date","3/4")],Just 2000-03-04,Just 2000-05-06)
Example: extraction of dates from date tags ignores trailing text >>> rtp (postingcommentp (Just 2000)) "; date:34=56" Right ("date:34=56n",[("date","34=56")],Just 2000-03-04,Nothing)
bracketeddatetagsp :: Maybe Year -> TextParser 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.
>>>
either (Left . parseErrorPretty) Right $ rtp (bracketeddatetagsp Nothing) "[2016/1/2=3/4]"
Right [("date",2016-01-02),("date2",2016-03-04)]
>>>
either (Left . parseErrorPretty) Right $ rtp (bracketeddatetagsp Nothing) "[1]"
Left ...not a bracketed date...
>>>
either (Left . parseErrorPretty) Right $ rtp (bracketeddatetagsp Nothing) "[2016/1/32]"
Left ...1:11:...well-formed but invalid date: 2016/1/32...
>>>
either (Left . parseErrorPretty) Right $ rtp (bracketeddatetagsp Nothing) "[1/31]"
Left ...1:6:...partial date 1/31 found, but the current year is unknown...
>>>
either (Left . parseErrorPretty) Right $ rtp (bracketeddatetagsp Nothing) "[0123456789/-.=/-.=]"
Left ...1:13:...expecting month or day...
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).
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.
readJournalFiles :: InputOpts -> [FilePath] -> IO (Either String Journal) Source #
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 affect subsequent sibling or parent files. They do affect included child files though. Also the final parse state saved in the Journal does span all files.
readJournalFile :: InputOpts -> PrefixedFilePath -> IO (Either String Journal) Source #
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) to use is determined from (in priority order):
the mformat_
specified in the input options, if any;
the file path's READER: prefix, if any;
a recognised file name extension.
if none of these identify a known reader, all built-in readers are tried in turn.
The input options can also configure balance assertion checking, automated posting generation, a rules file for converting CSV data, etc.
readJournal :: InputOpts -> Maybe FilePath -> Text -> IO (Either String Journal) Source #
readJournal iopts mfile txt
Read a Journal from some text, or return an error message.
The reader (data format) is chosen based on a recognised file name extension in mfile
(if provided).
If it does not identify a known reader, all built-in readers are tried in turn
(returning the first one's error message if none of them succeed).
Input ioptions (iopts
) specify CSV conversion rules file to help convert CSV data,
enable or disable balance assertion checking and automated posting generation.
type BalanceReportItem = (AccountName, AccountName, Int, MixedAmount) Source #
type BalanceReport = ([BalanceReportItem], MixedAmount) Source #
A simple 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).
MultiBalanceReport ([DateSpan], [MultiBalanceReportRow], MultiBalanceReportTotals) |
Instances
Show MultiBalanceReport Source # | |
Defined in Hledger.Reports.MultiBalanceReports showsPrec :: Int -> MultiBalanceReport -> ShowS # show :: MultiBalanceReport -> String # showList :: [MultiBalanceReport] -> ShowS # |
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. Does not support tree-mode boring parent eliding. If the normalbalance_ option is set, it adjusts the sorting and sign of amounts (see ReportOpts and CompoundBalanceCommand).
mbrNormaliseSign :: NormalSign -> MultiBalanceReport -> MultiBalanceReport Source #
Given a MultiBalanceReport and its normal balance sign, if it is known to be normally negative, convert it to normally positive.
mbrNegate :: MultiBalanceReport -> MultiBalanceReport Source #
Flip the sign of all amounts in a MultiBalanceReport.
multiBalanceReportSpan :: MultiBalanceReport -> DateSpan Source #
Figure out the overall date span of a multicolumn balance report.
balanceReportFromMultiBalanceReport :: ReportOpts -> Query -> Journal -> BalanceReport Source #
Generates a simple non-columnar BalanceReport, but using multiBalanceReport, in order to support --historical. Does not support tree-mode boring parent eliding. If the normalbalance_ option is set, it adjusts the sorting and sign of amounts (see ReportOpts and CompoundBalanceCommand).
tableAsText :: ReportOpts -> (a -> String) -> Table String String a -> String Source #
type BudgetReport = PeriodicReport (Maybe Change, Maybe BudgetGoal) Source #
A budget report tracks expected and actual changes per account and subperiod.
type BudgetAverage = Average Source #
type BudgetTotal = Total Source #
type BudgetGoal = Change Source #
budgetReport :: ReportOpts -> Bool -> Bool -> DateSpan -> Day -> Journal -> BudgetReport Source #
Calculate budget goals from all periodic transactions,
actual balance changes from the regular transactions,
and compare these to get a BudgetReport
.
Unbudgeted accounts may be hidden or renamed (see budgetRollup).
budgetJournal :: Bool -> ReportOpts -> DateSpan -> Journal -> Journal Source #
Use all periodic transactions in the journal to generate budget transactions in the specified report period. Budget transactions are similar to forecast transactions except their purpose is to set goal amounts (of change) per account and period.
budgetRollUp :: [AccountName] -> Bool -> Journal -> Journal Source #
Adjust a journal's account names for budget reporting, in two ways:
- accounts with no budget goal anywhere in their ancestry are moved under the "unbudgeted" top level account.
- subaccounts with no budget goal are merged with their closest parent account with a budget goal, so that only budgeted accounts are shown. This can be disabled by --show-unbudgeted.
combineBudgetAndActual :: MultiBalanceReport -> MultiBalanceReport -> BudgetReport Source #
Combine a per-account-and-subperiod report of budget goals, and one of actual change amounts, into a budget performance report. The two reports should have the same report interval, but need not have exactly the same account rows or date columns. (Cells in the combined budget report can be missing a budget goal, an actual amount, or both.) The combined report will include:
- consecutive subperiods at the same interval as the two reports, spanning the period of both reports
- all accounts mentioned in either report, sorted by account code or account name or amount as appropriate.
budgetReportSpan :: BudgetReport -> DateSpan Source #
Figure out the overall period of a BudgetReport.
budgetReportAsText :: ReportOpts -> BudgetReport -> String Source #
Render a budget report as plain text suitable for console output.
budgetReportAsTable :: ReportOpts -> BudgetReport -> Table String String (Maybe MixedAmount, Maybe MixedAmount) Source #
Build a Table
from a multi-column balance report.
maybeAccountNameDrop :: ReportOpts -> AccountName -> AccountName Source #
Drop leading components of accounts names as specified by --drop, but only in --flat mode.
tests_Hledger :: Test Source #