added 'qualifiers' to odd customized usages of bs/is/cf (ie, historical for is) to prevent misleading reports
This commit is contained in:
parent
b06739f714
commit
7616056fbe
@ -14,8 +14,9 @@ module Hledger.Cli.BalanceView (
|
|||||||
,balanceviewReport
|
,balanceviewReport
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad (unless)
|
import Control.Monad (unless, forM_)
|
||||||
import Data.List (intercalate, foldl')
|
import Data.List (intercalate, foldl')
|
||||||
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.Monoid (Sum(..), (<>))
|
import Data.Monoid (Sum(..), (<>))
|
||||||
import System.Console.CmdArgs.Explicit as C
|
import System.Console.CmdArgs.Explicit as C
|
||||||
import Text.Tabular as T
|
import Text.Tabular as T
|
||||||
@ -144,15 +145,22 @@ balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts, rawopts_=raw} j = d
|
|||||||
++ (if average_ ropts' then [totavg] else [])
|
++ (if average_ ropts' then [totavg] else [])
|
||||||
)
|
)
|
||||||
putStrLn bvtitle
|
putStrLn bvtitle
|
||||||
|
forM_ overwriteBalanceType $ \t ->
|
||||||
|
putStrLn $ case t of
|
||||||
|
PeriodChange -> "(Balance Changes)"
|
||||||
|
CumulativeChange -> "(Cumulative Ending Balances)"
|
||||||
|
HistoricalBalance -> "(Historical Ending Balances)"
|
||||||
putStrLn $ renderBalanceReportTable totTabl
|
putStrLn $ renderBalanceReportTable totTabl
|
||||||
where
|
where
|
||||||
balancetype =
|
overwriteBalanceType =
|
||||||
case reverse $ filter (`elem` ["change","cumulative","historical"]) $ map fst raw of
|
case reverse $ filter (`elem` ["change","cumulative","historical"]) $ map fst raw of
|
||||||
"historical":_ -> HistoricalBalance
|
"historical":_ -> Just HistoricalBalance
|
||||||
"cumulative":_ -> CumulativeChange
|
"cumulative":_ -> Just CumulativeChange
|
||||||
"change":_ -> PeriodChange
|
"change":_ -> Just PeriodChange
|
||||||
_ -> bvtype
|
_ -> Nothing
|
||||||
ropts' = emptyMulti . treeIfNotChange $ ropts { balancetype_ = balancetype }
|
balancetype = fromMaybe bvtype overwriteBalanceType
|
||||||
|
ropts' = emptyMulti . treeIfNotChange $
|
||||||
|
ropts { balancetype_ = balancetype }
|
||||||
treeIfNotChange = case (balancetype, interval_ ropts) of
|
treeIfNotChange = case (balancetype, interval_ ropts) of
|
||||||
-- For --historical/--cumulative, we must use multiBalanceReport.
|
-- For --historical/--cumulative, we must use multiBalanceReport.
|
||||||
-- (This forces --no-elide.)
|
-- (This forces --no-elide.)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user