report haddocks

This commit is contained in:
Simon Michael 2011-07-18 00:21:13 +00:00
parent df7dc1464e
commit 848a081d29

View File

@ -1,6 +1,9 @@
{-| {-|
Generate various kinds of report from a journal/ledger. Generate several common kinds of report from a journal, as "Reports" -
simple intermediate data structures intended to be easily rendered as
text, html, json, csv etc. by hledger commands, hamlet templates,
javascript, or whatever.
-} -}
@ -20,7 +23,7 @@ module Hledger.Report (
,postingRegisterReport ,postingRegisterReport
,accountRegisterReport ,accountRegisterReport
,journalRegisterReport ,journalRegisterReport
,mkpostingRegisterItem ,mkpostingRegisterItem -- for silly showPostingWithBalanceForVty in Hledger.Cli.Register
,balanceReport ,balanceReport
,balanceReport2 ,balanceReport2
) )
@ -42,7 +45,6 @@ import Hledger.Cli.Utils
import Hledger.Data import Hledger.Data
import Hledger.Utils import Hledger.Utils
-- | A "journal report" is just a list of transactions. -- | A "journal report" is just a list of transactions.
type JournalReport = [JournalReportItem] type JournalReport = [JournalReportItem]
@ -92,6 +94,7 @@ type BalanceReportItem = (AccountName -- full account name
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- | Select transactions, as in the print command.
journalReport :: [Opt] -> FilterSpec -> Journal -> JournalReport journalReport :: [Opt] -> FilterSpec -> Journal -> JournalReport
journalReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j' journalReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j'
where where
@ -99,8 +102,8 @@ journalReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTra
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- | Get a ledger-style posting register report, with the specified options, -- | Select postings from the journal and get their running balance, as in
-- for the whole journal. See also "accountRegisterReport". -- the register command.
postingRegisterReport :: [Opt] -> FilterSpec -> Journal -> PostingRegisterReport postingRegisterReport :: [Opt] -> FilterSpec -> Journal -> PostingRegisterReport
postingRegisterReport opts fspec j = (totallabel, postingRegisterItems ps nullposting startbal (+)) postingRegisterReport opts fspec j = (totallabel, postingRegisterItems ps nullposting startbal (+))
where where
@ -235,7 +238,7 @@ summarisePostingsInDateSpan (DateSpan b e) depth showempty ps
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- | Get a ledger-style register report showing all matched transactions and postings. -- | Select postings from the whole journal and get their running balance.
-- Similar to "postingRegisterReport" except it uses matchers and -- Similar to "postingRegisterReport" except it uses matchers and
-- per-transaction report items like "accountRegisterReport". -- per-transaction report items like "accountRegisterReport".
journalRegisterReport :: [Opt] -> Journal -> Matcher -> AccountRegisterReport journalRegisterReport :: [Opt] -> Journal -> Matcher -> AccountRegisterReport
@ -247,10 +250,10 @@ journalRegisterReport _ Journal{jtxns=ts} m = (totallabel, items)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- | Get a conventional account register report, with the specified -- | Select transactions within one (or more) specified accounts, and get
-- options, for the currently focussed account (or possibly the focussed -- their running balance within that (those) account(s). Used for a
-- account plus sub-accounts.) This differs from "postingRegisterReport" -- conventional quicker/gnucash/bank-style account register. Specifically,
-- in several ways: -- this differs from "postingRegisterReport" as follows:
-- --
-- 1. it shows transactions, from the point of view of the focussed -- 1. it shows transactions, from the point of view of the focussed
-- account. The other account's name and posted amount is displayed, -- account. The other account's name and posted amount is displayed,
@ -258,11 +261,12 @@ journalRegisterReport _ Journal{jtxns=ts} m = (totallabel, items)
-- --
-- 2. With no transaction filtering in effect other than a start date, it -- 2. With no transaction filtering in effect other than a start date, it
-- shows the accurate historical running balance for this -- shows the accurate historical running balance for this
-- account. Otherwise it shows a running total starting at 0 like the posting register report. -- account. Otherwise it shows a running total starting at 0 like the
-- posting register report.
-- --
-- 3. Currently this report does not handle reporting intervals. -- 3. It currently does not handle reporting intervals.
-- --
-- 4. Report items will be most recent first. -- 4. Report items are most recent first.
-- --
accountRegisterReport :: [Opt] -> Journal -> Matcher -> Matcher -> AccountRegisterReport accountRegisterReport :: [Opt] -> Journal -> Matcher -> Matcher -> AccountRegisterReport
accountRegisterReport opts j m thisacctmatcher = (label, items) accountRegisterReport opts j m thisacctmatcher = (label, items)
@ -334,12 +338,13 @@ filterTransactionPostings m t@Transaction{tpostings=ps} = t{tpostings=filter (m
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- | Get a balance report with the specified options for this journal. -- | Select accounts, and get their balances at the end of the selected
-- period, as in the balance command.
balanceReport :: [Opt] -> FilterSpec -> Journal -> BalanceReport balanceReport :: [Opt] -> FilterSpec -> Journal -> BalanceReport
balanceReport opts filterspec j = balanceReport' opts j (journalToLedger filterspec) balanceReport opts filterspec j = balanceReport' opts j (journalToLedger filterspec)
-- | Get a balance report with the specified options for this -- | Select accounts, and get their balances at the end of the selected
-- journal. Like balanceReport but uses the new matchers. -- period. Like "balanceReport" but uses the new matchers.
balanceReport2 :: [Opt] -> Matcher -> Journal -> BalanceReport balanceReport2 :: [Opt] -> Matcher -> Journal -> BalanceReport
balanceReport2 opts matcher j = balanceReport' opts j (journalToLedger2 matcher) balanceReport2 opts matcher j = balanceReport' opts j (journalToLedger2 matcher)