Skip to content

Commit 165e70d

Browse files
committed
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.
1 parent 224e0bf commit 165e70d

File tree

7 files changed

+36
-14
lines changed

7 files changed

+36
-14
lines changed

hledger/Hledger/Cli/CompoundBalanceCommand.hs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE OverloadedStrings #-}
22
{-# LANGUAGE RecordWildCards #-}
3+
{-# LANGUAGE LambdaCase #-}
34
{-|
45
56
Common helpers for making multi-section balance report commands
@@ -124,7 +125,8 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r
124125
ropts' = ropts{balanceaccum_=balanceaccumulation}
125126

126127
title =
127-
T.pack cbctitle
128+
maybe "" (<>" ") mintervalstr
129+
<> T.pack cbctitle
128130
<> " "
129131
<> titledatestr
130132
<> maybe "" (" "<>) mtitleclarification
@@ -143,6 +145,8 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r
143145
enddates = map (addDays (-1)) . mapMaybe spanEnd $ cbrDates cbr -- these spans will always have a definite end date
144146
requestedspan = fst $ reportSpan j rspec
145147

148+
mintervalstr = showInterval interval_
149+
146150
-- when user overrides, add an indication to the report title
147151
-- Do we need to deal with overridden BalanceCalculation?
148152
mtitleclarification = case (balancecalc_, balanceaccumulation, mbalanceAccumulationOverride) of
@@ -186,6 +190,24 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r
186190
"json" -> toJsonText
187191
x -> error' $ unsupportedOutputFormatError x
188192

193+
-- | Show a simplified description of an Interval.
194+
showInterval :: Interval -> Maybe T.Text
195+
showInterval = \case
196+
NoInterval -> Nothing
197+
Days 1 -> Just "Daily"
198+
Weeks 1 -> Just "Weekly"
199+
Weeks 2 -> Just "Biweekly"
200+
Months 1 -> Just "Monthly"
201+
Months 2 -> Just "Bimonthly"
202+
Months 3 -> Just "Quarterly"
203+
Months 6 -> Just "Half-yearly"
204+
Months 12 -> Just "Yearly"
205+
Quarters 1 -> Just "Quarterly"
206+
Quarters 2 -> Just "Half-yearly"
207+
Years 1 -> Just "Yearly"
208+
Years 2 -> Just "Biannual"
209+
_ -> Just "Periodic"
210+
189211
-- | Summarise one or more (inclusive) end dates, in a way that's
190212
-- visually different from showDateSpan, suggesting discrete end dates
191213
-- rather than a continuous span.

hledger/test/balance/layout.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Balance changes in 2012-01-01..2014-12-31:
142142

143143
# ** 13. Multicolumn income statement with --row-total, --average, and --summary-only
144144
$ hledger -f bcexample.hledger is -Y income expenses:food -3 --layout=bare --row-total --average --summary-only
145-
Income Statement 2012-01-01..2014-12-31
145+
Yearly Income Statement 2012-01-01..2014-12-31
146146

147147
|| Commodity Total Average
148148
==========================++=================================

hledger/test/balancesheet.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Balance Sheet 2016-01-01
6969
# Total || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
7070
#
7171
$ hledger -f sample.journal balancesheet -p 'monthly in 2008'
72-
Balance Sheet 2008-01-31..2008-12-31
72+
Monthly Balance Sheet 2008-01-31..2008-12-31
7373

7474
|| 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
7575
======================++================================================================================================================================================
@@ -113,7 +113,7 @@ Balance Sheet 2008-01-31..2008-12-31
113113
# Total || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
114114
#
115115
$ hledger -f sample.journal balancesheet -p 'monthly in 2008' --tree
116-
Balance Sheet 2008-01-31..2008-12-31
116+
Monthly Balance Sheet 2008-01-31..2008-12-31
117117

118118
|| 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
119119
===================++================================================================================================================================================
@@ -139,7 +139,7 @@ Balance Sheet 2008-01-31..2008-12-31
139139
# Total column is requested but not shown because balancesheet is in historical mode
140140
# by default (shows ending balances).
141141
$ hledger -f sample.journal balancesheet -p 'monthly in 2008' -NAT
142-
Balance Sheet 2008-01-31..2008-12-31
142+
Monthly Balance Sheet 2008-01-31..2008-12-31
143143

144144
|| 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
145145
======================++=========================================================================================================================================================
@@ -202,7 +202,7 @@ Balance Sheet 2017-01-01
202202
2017/1/1
203203
(assets) $1
204204
$ hledger -f- balancesheet -YA
205-
Balance Sheet 2017-12-31
205+
Yearly Balance Sheet 2017-12-31
206206

207207
|| 2017-12-31 Average
208208
=============++=====================
@@ -226,7 +226,7 @@ Balance Sheet 2017-12-31
226226
b
227227

228228
$ hledger -f - balancesheet -M --pretty
229-
Balance Sheet 2016-01-31
229+
Monthly Balance Sheet 2016-01-31
230230

231231
┌─────────────╥────────────┐
232232
│ ║ 2016-01-31 │

hledger/test/cashflow.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Cashflow Statement 2016-10
9595

9696
# ** 6. Multicolumn test
9797
$ hledger -f sample.journal cashflow -p 'monthly in 2008'
98-
Cashflow Statement 2008
98+
Monthly Cashflow Statement 2008
9999

100100
|| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
101101
======================++============================================================
@@ -110,7 +110,7 @@ Cashflow Statement 2008
110110

111111
# ** 7. Multicolumn test (historical)
112112
$ hledger -f sample.journal cashflow -p 'monthly in 2008' -A --historical
113-
Cashflow Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
113+
Monthly Cashflow Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
114114

115115
|| 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
116116
======================++=========================================================================================================================================================

hledger/test/incomestatement.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Income Statement 2016-10
203203
# Total || $-1 0 0 0 0 $1 0 0 0 0 0 0 0 0
204204
#
205205
$ hledger -f sample.journal incomestatement -p 'monthly in 2008' -AT
206-
Income Statement 2008
206+
Monthly Income Statement 2008
207207

208208
|| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Total Average
209209
===================++==============================================================================
@@ -246,7 +246,7 @@ Income Statement 2008
246246
# Total || $-1 $-1 $-1 $-1 $-1 0 0 0 0 0 0 0
247247
#
248248
$ hledger -f sample.journal incomestatement -p 'monthly in 2008' --historical
249-
Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
249+
Monthly Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
250250

251251
|| 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
252252
===================++================================================================================================================================================
@@ -268,7 +268,7 @@ Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
268268

269269
# ** 8. Percentage test
270270
$ hledger -f sample.journal incomestatement -p 'quarterly 2008' -T --average -% --no-total
271-
Income Statement 2008
271+
Quarterly Income Statement 2008
272272

273273
|| 2008Q1 2008Q2 2008Q3 2008Q4 Total Average
274274
===================++====================================================

hledger/test/journal/gain.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Historical gain in 2000-01, valued at 2000-02-01:
8181

8282
# ** 7. also works in balancesheet
8383
$ hledger -f- bs -M --gain --no-total
84-
Balance Sheet 1999-12-31..2000-02-29 (Historical Gain), valued at period ends
84+
Monthly Balance Sheet 1999-12-31..2000-02-29 (Historical Gain), valued at period ends
8585

8686
|| 1999-12-31 2000-01-31 2000-02-29
8787
=============++====================================

hledger/test/journal/valuechange.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Ending balances (historical) in 2000-01-01..2000-04-30, valued at period ends:
5959
# ** 4. Balance sheet also reports on value change, and --valuechange overrides
6060
# the historical period
6161
$ hledger -f- balancesheet -MN --valuechange -b 2000
62-
Balance Sheet 2000-01-01..2000-04-30 (Period-End Value Changes)
62+
Monthly Balance Sheet 2000-01-01..2000-04-30 (Period-End Value Changes)
6363

6464
|| Jan Feb Mar Apr
6565
=============++======================

0 commit comments

Comments
 (0)