Hledger.Reports
Description
Generate several common kinds of report from a journal, as "*Report" - simple intermediate data structures intended to be easily rendered as text, html, json, csv etc. by hledger commands, hamlet templates, javascript, or whatever. This is under Hledger.Cli since it depends on the command-line options, should move to hledger-lib later.
- data ReportOpts = ReportOpts {
- begin_ :: Maybe Day
- end_ :: Maybe Day
- period_ :: Maybe (Interval, DateSpan)
- cleared_ :: Bool
- uncleared_ :: Bool
- cost_ :: Bool
- depth_ :: Maybe Int
- display_ :: Maybe DisplayExp
- effective_ :: Bool
- empty_ :: Bool
- no_elide_ :: Bool
- real_ :: Bool
- flat_ :: Bool
- drop_ :: Int
- no_total_ :: Bool
- daily_ :: Bool
- weekly_ :: Bool
- monthly_ :: Bool
- quarterly_ :: Bool
- yearly_ :: Bool
- format_ :: Maybe FormatStr
- patterns_ :: [String]
- type DisplayExp = String
- type FormatStr = String
- defreportopts :: ReportOpts
- dateSpanFromOpts :: Day -> ReportOpts -> DateSpan
- intervalFromOpts :: ReportOpts -> Interval
- clearedValueFromOpts :: ReportOpts -> Maybe Bool
- whichDateFromOpts :: ReportOpts -> WhichDate
- journalSelectingDateFromOpts :: ReportOpts -> Journal -> Journal
- journalSelectingAmountFromOpts :: ReportOpts -> Journal -> Journal
- optsToFilterSpec :: ReportOpts -> Day -> FilterSpec
- type EntriesReport = [EntriesReportItem]
- type EntriesReportItem = Transaction
- entriesReport :: ReportOpts -> FilterSpec -> Journal -> EntriesReport
- type PostingsReport = (String, [PostingsReportItem])
- type PostingsReportItem = (Maybe (Day, String), Posting, MixedAmount)
- postingsReport :: ReportOpts -> FilterSpec -> Journal -> PostingsReport
- mkpostingsReportItem :: Bool -> Posting -> MixedAmount -> PostingsReportItem
- type TransactionsReport = (String, [TransactionsReportItem])
- type TransactionsReportItem = (Transaction, Transaction, Bool, String, MixedAmount, MixedAmount)
- triDate :: (Transaction, t, t1, t2, t3, t4) -> Day
- triBalance :: (t, t1, t2, t3, t4, MixedAmount) -> [Char]
- journalTransactionsReport :: ReportOpts -> Journal -> Matcher -> TransactionsReport
- accountTransactionsReport :: ReportOpts -> Journal -> Matcher -> Matcher -> TransactionsReport
- type AccountsReport = ([AccountsReportItem], MixedAmount)
- type AccountsReportItem = (AccountName, AccountName, Int, MixedAmount)
- accountsReport :: ReportOpts -> FilterSpec -> Journal -> AccountsReport
- accountsReport2 :: ReportOpts -> Matcher -> Journal -> AccountsReport
- isInteresting :: ReportOpts -> Ledger -> AccountName -> Bool
- tests_Hledger_Reports :: Test
Documentation
data ReportOpts Source
Constructors
ReportOpts | |
Fields
|
Instances
type DisplayExp = StringSource
dateSpanFromOpts :: Day -> ReportOpts -> DateSpanSource
Figure out the date span we should report on, based on any beginendperiod options provided. A period option will cause begin and end options to be ignored.
intervalFromOpts :: ReportOpts -> IntervalSource
Figure out the reporting interval, if any, specified by the options. --period overrides --daily overrides --weekly overrides --monthly etc.
clearedValueFromOpts :: ReportOpts -> Maybe BoolSource
Get a maybe boolean representing the last cleared/uncleared option if any.
whichDateFromOpts :: ReportOpts -> WhichDateSource
Report which date we will report on based on --effective.
journalSelectingDateFromOpts :: ReportOpts -> Journal -> JournalSource
Convert this journal's transactions' primary date to either the actual or effective date, as per options.
journalSelectingAmountFromOpts :: ReportOpts -> Journal -> JournalSource
Convert this journal's postings' amounts to the cost basis amounts if specified by options.
optsToFilterSpec :: ReportOpts -> Day -> FilterSpecSource
Convert application options to the library's generic filter specification.
Entries report
type EntriesReport = [EntriesReportItem]Source
A journal entries report is a list of whole transactions as originally entered in the journal (mostly). Used by eg hledger's print command and hledger-web's journal entries view.
entriesReport :: ReportOpts -> FilterSpec -> Journal -> EntriesReportSource
Select transactions for an entries report.
Postings report
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.
type PostingsReportItem = (Maybe (Day, String), Posting, MixedAmount)Source
postingsReport :: ReportOpts -> FilterSpec -> Journal -> PostingsReportSource
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 -> Posting -> MixedAmount -> PostingsReportItemSource
Generate one postings report line item, from a flag indicating whether to include transaction info, a posting, and the current running balance.
Transactions report
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).
type TransactionsReportItem = (Transaction, Transaction, Bool, String, MixedAmount, MixedAmount)Source
triDate :: (Transaction, t, t1, t2, t3, t4) -> DaySource
triBalance :: (t, t1, t2, t3, t4, MixedAmount) -> [Char]Source
journalTransactionsReport :: ReportOpts -> Journal -> Matcher -> TransactionsReportSource
Select transactions from the whole journal for a transactions report, with no "current" account. The end result is similar to postingsReport except it uses matchers and transaction-based report items and the items are most recent first. Used by eg hledger-web's journal view.
accountTransactionsReport :: ReportOpts -> Journal -> Matcher -> Matcher -> TransactionsReportSource
Select transactions within one or more "current" accounts, and make a transactions report relative to those account(s). This means:
- it shows transactions from the point of view of the current account(s). The transaction amount is the amount posted to the current account(s). The other accounts' names are provided.
- With no transaction filtering in effect other than a start date, it shows the accurate historical running balance for the current account(s). Otherwise it shows a running total starting at 0.
Currently, reporting intervals are not supported, and report items are most recent first. Used by eg hledger-web's account register view.
Accounts report
type AccountsReport = ([AccountsReportItem], MixedAmount)Source
An accounts report is a list of account names (full and short variants) with their balances, appropriate indentation for rendering as a hierarchy, and grand total.
type AccountsReportItem = (AccountName, AccountName, Int, MixedAmount)Source
accountsReport :: ReportOpts -> FilterSpec -> Journal -> AccountsReportSource
Select accounts, and get their balances at the end of the selected period, and misc. display information, for an accounts report. Used by eg hledger's balance command.
accountsReport2 :: ReportOpts -> Matcher -> Journal -> AccountsReportSource
Select accounts, and get their balances at the end of the selected period, and misc. display information, for an accounts report. Like accountsReport but uses the new matchers. Used by eg hledger-web's accounts sidebar.
isInteresting :: ReportOpts -> Ledger -> AccountName -> BoolSource
Is the named account considered interesting for this ledger's accounts report, following the eliding style of ledger's balance command ?