imp: bs,cf,is: show interval in report title

This makes the report interval clearer, eg when it's set unexpectedly
by a config file.
This commit is contained in:
Simon Michael 2024-07-17 08:26:43 +01:00
parent 224e0bfb38
commit 165e70df7a
7 changed files with 36 additions and 14 deletions

View File

@ -1,5 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE LambdaCase #-}
{-|
Common helpers for making multi-section balance report commands
@ -124,7 +125,8 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r
ropts' = ropts{balanceaccum_=balanceaccumulation}
title =
T.pack cbctitle
maybe "" (<>" ") mintervalstr
<> T.pack cbctitle
<> " "
<> titledatestr
<> maybe "" (" "<>) mtitleclarification
@ -143,6 +145,8 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r
enddates = map (addDays (-1)) . mapMaybe spanEnd $ cbrDates cbr -- these spans will always have a definite end date
requestedspan = fst $ reportSpan j rspec
mintervalstr = showInterval interval_
-- when user overrides, add an indication to the report title
-- Do we need to deal with overridden BalanceCalculation?
mtitleclarification = case (balancecalc_, balanceaccumulation, mbalanceAccumulationOverride) of
@ -186,6 +190,24 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r
"json" -> toJsonText
x -> error' $ unsupportedOutputFormatError x
-- | Show a simplified description of an Interval.
showInterval :: Interval -> Maybe T.Text
showInterval = \case
NoInterval -> Nothing
Days 1 -> Just "Daily"
Weeks 1 -> Just "Weekly"
Weeks 2 -> Just "Biweekly"
Months 1 -> Just "Monthly"
Months 2 -> Just "Bimonthly"
Months 3 -> Just "Quarterly"
Months 6 -> Just "Half-yearly"
Months 12 -> Just "Yearly"
Quarters 1 -> Just "Quarterly"
Quarters 2 -> Just "Half-yearly"
Years 1 -> Just "Yearly"
Years 2 -> Just "Biannual"
_ -> Just "Periodic"
-- | Summarise one or more (inclusive) end dates, in a way that's
-- visually different from showDateSpan, suggesting discrete end dates
-- rather than a continuous span.

View File

@ -142,7 +142,7 @@ Balance changes in 2012-01-01..2014-12-31:
# ** 13. Multicolumn income statement with --row-total, --average, and --summary-only
$ hledger -f bcexample.hledger is -Y income expenses:food -3 --layout=bare --row-total --average --summary-only
Income Statement 2012-01-01..2014-12-31
Yearly Income Statement 2012-01-01..2014-12-31
|| Commodity Total Average
==========================++=================================

View File

@ -69,7 +69,7 @@ Balance Sheet 2016-01-01
# Total || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
#
$ hledger -f sample.journal balancesheet -p 'monthly in 2008'
Balance Sheet 2008-01-31..2008-12-31
Monthly Balance Sheet 2008-01-31..2008-12-31
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31
======================++================================================================================================================================================
@ -113,7 +113,7 @@ Balance Sheet 2008-01-31..2008-12-31
# Total || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
#
$ hledger -f sample.journal balancesheet -p 'monthly in 2008' --tree
Balance Sheet 2008-01-31..2008-12-31
Monthly Balance Sheet 2008-01-31..2008-12-31
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31
===================++================================================================================================================================================
@ -139,7 +139,7 @@ Balance Sheet 2008-01-31..2008-12-31
# Total column is requested but not shown because balancesheet is in historical mode
# by default (shows ending balances).
$ hledger -f sample.journal balancesheet -p 'monthly in 2008' -NAT
Balance Sheet 2008-01-31..2008-12-31
Monthly Balance Sheet 2008-01-31..2008-12-31
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31 Average
======================++=========================================================================================================================================================
@ -202,7 +202,7 @@ Balance Sheet 2017-01-01
2017/1/1
(assets) $1
$ hledger -f- balancesheet -YA
Balance Sheet 2017-12-31
Yearly Balance Sheet 2017-12-31
|| 2017-12-31 Average
=============++=====================
@ -226,7 +226,7 @@ Balance Sheet 2017-12-31
b
$ hledger -f - balancesheet -M --pretty
Balance Sheet 2016-01-31
Monthly Balance Sheet 2016-01-31
┌─────────────╥────────────┐
│ ║ 2016-01-31 │

View File

@ -95,7 +95,7 @@ Cashflow Statement 2016-10
# ** 6. Multicolumn test
$ hledger -f sample.journal cashflow -p 'monthly in 2008'
Cashflow Statement 2008
Monthly Cashflow Statement 2008
|| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
======================++============================================================
@ -110,7 +110,7 @@ Cashflow Statement 2008
# ** 7. Multicolumn test (historical)
$ hledger -f sample.journal cashflow -p 'monthly in 2008' -A --historical
Cashflow Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
Monthly Cashflow Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31 Average
======================++=========================================================================================================================================================

View File

@ -203,7 +203,7 @@ Income Statement 2016-10
# Total || $-1 0 0 0 0 $1 0 0 0 0 0 0 0 0
#
$ hledger -f sample.journal incomestatement -p 'monthly in 2008' -AT
Income Statement 2008
Monthly Income Statement 2008
|| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Total Average
===================++==============================================================================
@ -246,7 +246,7 @@ Income Statement 2008
# Total || $-1 $-1 $-1 $-1 $-1 0 0 0 0 0 0 0
#
$ hledger -f sample.journal incomestatement -p 'monthly in 2008' --historical
Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
Monthly Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31
===================++================================================================================================================================================
@ -268,7 +268,7 @@ Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
# ** 8. Percentage test
$ hledger -f sample.journal incomestatement -p 'quarterly 2008' -T --average -% --no-total
Income Statement 2008
Quarterly Income Statement 2008
|| 2008Q1 2008Q2 2008Q3 2008Q4 Total Average
===================++====================================================

View File

@ -81,7 +81,7 @@ Historical gain in 2000-01, valued at 2000-02-01:
# ** 7. also works in balancesheet
$ hledger -f- bs -M --gain --no-total
Balance Sheet 1999-12-31..2000-02-29 (Historical Gain), valued at period ends
Monthly Balance Sheet 1999-12-31..2000-02-29 (Historical Gain), valued at period ends
|| 1999-12-31 2000-01-31 2000-02-29
=============++====================================

View File

@ -59,7 +59,7 @@ Ending balances (historical) in 2000-01-01..2000-04-30, valued at period ends:
# ** 4. Balance sheet also reports on value change, and --valuechange overrides
# the historical period
$ hledger -f- balancesheet -MN --valuechange -b 2000
Balance Sheet 2000-01-01..2000-04-30 (Period-End Value Changes)
Monthly Balance Sheet 2000-01-01..2000-04-30 (Period-End Value Changes)
|| Jan Feb Mar Apr
=============++======================