diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index 6942644ec..d1396678b 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -20,7 +20,6 @@ module Hledger.Reports.BudgetReport ( budgetReportAsText, budgetReportAsCsv, -- * Helpers - reportPeriodName, combineBudgetAndActual, -- * Tests tests_BudgetReport @@ -318,27 +317,6 @@ budgetReportAsTable ++ [grandavg | average_ ropts && not (null coltots)] )) --- | Make a name for the given period in a multiperiod report, given --- the type of balance being reported and the full set of report --- periods. This will be used as a column heading (or row heading, in --- a register summary report). We try to pick a useful name as follows: --- --- - ending-balance reports: the period's end date --- --- - balance change reports where the periods are months and all in the same year: --- the short month name in the current locale --- --- - all other balance change reports: a description of the datespan, --- abbreviated to compact form if possible (see showDateSpan). --- -reportPeriodName :: BalanceType -> [DateSpan] -> DateSpan -> T.Text -reportPeriodName balancetype spans = - case balancetype of - PeriodChange -> if multiyear then showDateSpan else showDateSpanMonthAbbrev - where - multiyear = (>1) $ length $ nubSort $ map spanStartYear spans - _ -> maybe "" (showDate . prevday) . spanEnd - -- XXX generalise this with multiBalanceReportAsCsv ? -- | Render a budget report as CSV. Like multiBalanceReportAsCsv, -- but includes alternating actual and budget amount columns. diff --git a/hledger-lib/Hledger/Reports/ReportOptions.hs b/hledger-lib/Hledger/Reports/ReportOptions.hs index 6e6dc7963..f2ee8b338 100644 --- a/hledger-lib/Hledger/Reports/ReportOptions.hs +++ b/hledger-lib/Hledger/Reports/ReportOptions.hs @@ -42,6 +42,7 @@ module Hledger.Reports.ReportOptions ( reportPeriodOrJournalStart, reportPeriodLastDay, reportPeriodOrJournalLastDay, + reportPeriodName ) where @@ -592,3 +593,23 @@ reportPeriodOrJournalLastDay rspec j = reportPeriodLastDay rspec <|> journalOrPr Just (AtEnd _) -> max (journalEndDate False j) lastPriceDirective _ -> journalEndDate False j lastPriceDirective = fmap (addDays 1) . maximumMay . map pddate $ jpricedirectives j + +-- | Make a name for the given period in a multiperiod report, given +-- the type of balance being reported and the full set of report +-- periods. This will be used as a column heading (or row heading, in +-- a register summary report). We try to pick a useful name as follows: +-- +-- - ending-balance reports: the period's end date +-- +-- - balance change reports where the periods are months and all in the same year: +-- the short month name in the current locale +-- +-- - all other balance change reports: a description of the datespan, +-- abbreviated to compact form if possible (see showDateSpan). +reportPeriodName :: BalanceType -> [DateSpan] -> DateSpan -> T.Text +reportPeriodName balancetype spans = + case balancetype of + PeriodChange -> if multiyear then showDateSpan else showDateSpanMonthAbbrev + where + multiyear = (>1) $ length $ nubSort $ map spanStartYear spans + _ -> maybe "" (showDate . prevday) . spanEnd diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 82df236c7..02dfb886a 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -243,7 +243,7 @@ compoundBalanceReportAsCsv ropts (CompoundPeriodicReport title colspans subrepor addtotals $ padRow title : ( "Account" - : map showDateSpanMonthAbbrev colspans + : map (reportPeriodName (balancetype_ ropts) colspans) colspans ++ (if row_total_ ropts then ["Total"] else []) ++ (if average_ ropts then ["Average"] else []) ) @@ -288,7 +288,7 @@ compoundBalanceReportAsHtml ropts cbr = [tr_ $ th_ [colspanattr, leftattr] $ h2_ $ toHtml title] ++ [thRow $ "" : - map showDateSpanMonthAbbrev colspans + map (reportPeriodName (balancetype_ ropts) colspans) colspans ++ (if row_total_ ropts then ["Total"] else []) ++ (if average_ ropts then ["Average"] else []) ]