balance: ignore --drop when displaying in tree mode
This commit is contained in:
parent
4a5d7154cd
commit
e14f39bae0
@ -56,7 +56,7 @@ accounts CliOpts{reportopts_=ropts} j = do
|
|||||||
as' | tree_ ropts = expandAccountNames as
|
as' | tree_ ropts = expandAccountNames as
|
||||||
| otherwise = as
|
| otherwise = as
|
||||||
render a | tree_ ropts = replicate (2 * (accountNameLevel a - 1)) ' ' ++ accountLeafName a
|
render a | tree_ ropts = replicate (2 * (accountNameLevel a - 1)) ' ' ++ accountLeafName a
|
||||||
| otherwise = accountNameDrop (drop_ ropts) a
|
| otherwise = maybeAccountNameDrop ropts a
|
||||||
mapM_ (putStrLn . render) as'
|
mapM_ (putStrLn . render) as'
|
||||||
|
|
||||||
tests_Hledger_Cli_Accounts = TestList []
|
tests_Hledger_Cli_Accounts = TestList []
|
||||||
|
|||||||
@ -382,7 +382,7 @@ formatBalanceReportItem opts accountName depth amount (fmt:fmts) =
|
|||||||
|
|
||||||
formatField :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> HledgerFormatField -> String
|
formatField :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> HledgerFormatField -> String
|
||||||
formatField opts accountName depth total ljust min max field = case field of
|
formatField opts accountName depth total ljust min max field = case field of
|
||||||
AccountField -> formatValue ljust min max $ maybe "" (accountNameDrop (drop_ opts)) accountName
|
AccountField -> formatValue ljust min max $ maybe "" (maybeAccountNameDrop opts) accountName
|
||||||
DepthSpacerField -> case min of
|
DepthSpacerField -> case min of
|
||||||
Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' '
|
Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' '
|
||||||
Nothing -> formatValue ljust Nothing max $ replicate depth ' '
|
Nothing -> formatValue ljust Nothing max $ replicate depth ' '
|
||||||
@ -424,7 +424,7 @@ periodBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, coltotals
|
|||||||
accts = map renderacct items'
|
accts = map renderacct items'
|
||||||
renderacct ((a,a',i),_)
|
renderacct ((a,a',i),_)
|
||||||
| tree_ opts = replicate ((i-1)*2) ' ' ++ a'
|
| tree_ opts = replicate ((i-1)*2) ' ' ++ a'
|
||||||
| otherwise = accountNameDrop (drop_ opts) a
|
| otherwise = maybeAccountNameDrop opts a
|
||||||
acctswidth = maximum $ map length $ accts
|
acctswidth = maximum $ map length $ accts
|
||||||
totalrow | no_total_ opts = row "" []
|
totalrow | no_total_ opts = row "" []
|
||||||
| otherwise = row "" coltotals
|
| otherwise = row "" coltotals
|
||||||
@ -446,7 +446,7 @@ cumulativeBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, colto
|
|||||||
accts = map renderacct items
|
accts = map renderacct items
|
||||||
renderacct ((a,a',i),_)
|
renderacct ((a,a',i),_)
|
||||||
| tree_ opts = replicate ((i-1)*2) ' ' ++ a'
|
| tree_ opts = replicate ((i-1)*2) ' ' ++ a'
|
||||||
| otherwise = accountNameDrop (drop_ opts) a
|
| otherwise = maybeAccountNameDrop opts a
|
||||||
acctswidth = maximum $ map length $ accts
|
acctswidth = maximum $ map length $ accts
|
||||||
addtotalrow | no_total_ opts = id
|
addtotalrow | no_total_ opts = id
|
||||||
| otherwise = (+----+ row "" coltotals)
|
| otherwise = (+----+ row "" coltotals)
|
||||||
@ -468,7 +468,7 @@ historicalBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, colto
|
|||||||
accts = map renderacct items
|
accts = map renderacct items
|
||||||
renderacct ((a,a',i),_)
|
renderacct ((a,a',i),_)
|
||||||
| tree_ opts = replicate ((i-1)*2) ' ' ++ a'
|
| tree_ opts = replicate ((i-1)*2) ' ' ++ a'
|
||||||
| otherwise = accountNameDrop (drop_ opts) a
|
| otherwise = maybeAccountNameDrop opts a
|
||||||
acctswidth = maximum $ map length $ accts
|
acctswidth = maximum $ map length $ accts
|
||||||
addtotalrow | no_total_ opts = id
|
addtotalrow | no_total_ opts = id
|
||||||
| otherwise = (+----+ row "" coltotals)
|
| otherwise = (+----+ row "" coltotals)
|
||||||
|
|||||||
@ -49,6 +49,7 @@ module Hledger.Cli.Options (
|
|||||||
defaultWidth,
|
defaultWidth,
|
||||||
defaultWidthWithFlag,
|
defaultWidthWithFlag,
|
||||||
widthFromOpts,
|
widthFromOpts,
|
||||||
|
maybeAccountNameDrop,
|
||||||
-- | For balance:
|
-- | For balance:
|
||||||
lineFormatFromOpts,
|
lineFormatFromOpts,
|
||||||
|
|
||||||
@ -465,6 +466,11 @@ widthp :: Stream [Char] m t => ParsecT [Char] st m Width
|
|||||||
widthp = (string "auto" >> return Auto)
|
widthp = (string "auto" >> return Auto)
|
||||||
<|> (Width . read) `fmap` many1 digit
|
<|> (Width . read) `fmap` many1 digit
|
||||||
|
|
||||||
|
-- | Drop leading components of accounts names as specified by --drop, but only in --flat mode.
|
||||||
|
maybeAccountNameDrop :: ReportOpts -> AccountName -> AccountName
|
||||||
|
maybeAccountNameDrop opts a | tree_ opts = a
|
||||||
|
| otherwise = accountNameDrop (drop_ opts) a
|
||||||
|
|
||||||
-- Other utils
|
-- Other utils
|
||||||
|
|
||||||
-- | Get the sorted unique precise names and display names of hledger
|
-- | Get the sorted unique precise names and display names of hledger
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user