balance: include report span in title

This commit is contained in:
Simon Michael 2014-07-26 17:29:20 -07:00
parent ca43eab47a
commit 7fb154f820
2 changed files with 29 additions and 23 deletions

View File

@ -248,6 +248,7 @@ import Data.Maybe
import System.Console.CmdArgs.Explicit as C
-- import System.Console.CmdArgs.Text
import Test.HUnit
import Text.Printf (printf)
import Text.Tabular as T
import Text.Tabular.AsciiArt
@ -366,10 +367,15 @@ formatField opts accountName depth total ljust min max field = case field of
TotalField -> formatValue ljust min max $ showAmountWithoutPrice total
_ -> ""
-- | Figure out the overall date span of a multicolumn balance report.
multiBalanceReportSpan :: MultiBalanceReport -> DateSpan
multiBalanceReportSpan (MultiBalanceReport ([], _, _)) = DateSpan Nothing Nothing
multiBalanceReportSpan (MultiBalanceReport (colspans, _, _)) = DateSpan (spanStart $ head colspans) (spanEnd $ last colspans)
-- | Render a multi-column period balance report as plain text suitable for console output.
periodBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> [String]
periodBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals)) =
(["Balance changes:"] ++) $
periodBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, coltotals)) =
([printf "Balance changes in %s:" (showDateSpan $ multiBalanceReportSpan r)] ++) $
trimborder $ lines $
render
id
@ -395,8 +401,8 @@ periodBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals))
-- | Render a multi-column cumulative balance report as plain text suitable for console output.
cumulativeBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> [String]
cumulativeBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals)) =
(["Ending balances (cumulative):"] ++) $
cumulativeBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, coltotals)) =
([printf "Ending balances (cumulative) in %s:" (showDateSpan $ multiBalanceReportSpan r)] ++) $
trimborder $ lines $
render id ((" "++) . maybe "" (showDate . prevday) . spanEnd) showMixedAmountOneLineWithoutPrice $
addtotalrow $
@ -416,8 +422,8 @@ cumulativeBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltota
-- | Render a multi-column historical balance report as plain text suitable for console output.
historicalBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> [String]
historicalBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals)) =
(["Ending balances (historical):"] ++) $
historicalBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, coltotals)) =
([printf "Ending balances (historical) in %s:" (showDateSpan $ multiBalanceReportSpan r)] ++) $
trimborder $ lines $
render id ((" "++) . maybe "" (showDate . prevday) . spanEnd) showMixedAmountOneLineWithoutPrice $
addtotalrow $

View File

@ -14,7 +14,7 @@ hledgerdev -f balance-multicol.journal register
# 2. A period balance (flow) report. --no-total also works but isn't pretty.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --no-total
>>>
Balance changes:
Balance changes in 2013q1:
|| 2013/01 2013/02 2013/03
=================++============================
@ -37,7 +37,7 @@ hledgerdev -f - balance -p 'quarterly in 2013' --empty
2013/3/1
(a) 1
>>>
Balance changes:
Balance changes in 2013:
|| 2013q1 2013q2 2013q3 2013q4
===++=================================
@ -51,7 +51,7 @@ Balance changes:
# the highest-level displayed accounts (here, assets).
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --cumulative
>>>
Ending balances (cumulative):
Ending balances (cumulative) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
=================++=====================================
@ -68,7 +68,7 @@ Ending balances (cumulative):
# includes the displayed subaccount and not the excluded one.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --cumulative not:cash
>>>
Ending balances (cumulative):
Ending balances (cumulative) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
=================++=====================================
@ -82,7 +82,7 @@ Ending balances (cumulative):
# 6. A historical ending balance report.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --historical
>>>
Ending balances (historical):
Ending balances (historical) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
=================++=====================================
@ -98,7 +98,7 @@ Ending balances (historical):
# the highest-level displayed accounts, now assets:cash and assets:checking.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' not:assets$
>>>
Balance changes:
Balance changes in 2013q1:
|| 2013/01 2013/02 2013/03
=================++============================
@ -112,7 +112,7 @@ Balance changes:
# 8. cumulative:
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' not:assets$ --cumulative
>>>
Ending balances (cumulative):
Ending balances (cumulative) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
=================++=====================================
@ -126,7 +126,7 @@ Ending balances (cumulative):
# 9. historical
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --historical
>>>
Ending balances (historical):
Ending balances (historical) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
=================++=====================================
@ -143,7 +143,7 @@ Ending balances (historical):
# 10. A flow report with depth limiting. The depth limit aggregates the three accounts as "assets".
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1
>>>
Balance changes:
Balance changes in 2013q1:
|| 2013/01 2013/02 2013/03
========++============================
@ -156,7 +156,7 @@ Balance changes:
# 11. As above, but postings in the top-level assets account have been excluded.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1 assets:
>>>
Balance changes:
Balance changes in 2013q1:
|| 2013/01 2013/02 2013/03
========++============================
@ -169,7 +169,7 @@ Balance changes:
# 12. A cumulative balance report with depth limiting.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1 --cumulative
>>>
Ending balances (cumulative):
Ending balances (cumulative) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
========++=====================================
@ -182,7 +182,7 @@ Ending balances (cumulative):
# 13. A historical balance report with depth limiting.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1 --historical
>>>
Ending balances (historical):
Ending balances (historical) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
========++=====================================
@ -195,7 +195,7 @@ Ending balances (historical):
# 14. The three multicol balance report types again, this time with --tree
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --tree
>>>
Balance changes:
Balance changes in 2013q1:
|| 2013/01 2013/02 2013/03
============++============================
@ -210,7 +210,7 @@ Balance changes:
# 15.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --cumulative --tree
>>>
Ending balances (cumulative):
Ending balances (cumulative) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
============++=====================================
@ -225,7 +225,7 @@ Ending balances (cumulative):
# 16.
hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --historical --tree
>>>
Ending balances (historical):
Ending balances (historical) in 2013q1:
|| 2013/01/31 2013/02/28 2013/03/31
============++=====================================
@ -247,7 +247,7 @@ hledgerdev -f- balance --monthly --date2
(b) 1
>>>
Balance changes:
Balance changes in 2014/01:
|| 2014/01
===++==========
@ -271,7 +271,7 @@ hledgerdev -f- balance -p 'monthly 2014/1/10-2014/2/20'
(after) 1
>>>
Balance changes:
Balance changes in 2014/01/01-2014/02/28:
|| 2014/01 2014/02
========++===================