dev: clarify: rename displayDepth/prrDepth to displayIndent/prrIndent
These are about indentation for rendering, not account depth; these are not always directly related, eg when boring parents are elided.
This commit is contained in:
parent
75ad734edf
commit
6ce5e85e99
@ -71,7 +71,7 @@ balanceReport rspec j = (rows, total)
|
|||||||
report = multiBalanceReport rspec j
|
report = multiBalanceReport rspec j
|
||||||
rows = [( prrFullName row
|
rows = [( prrFullName row
|
||||||
, prrDisplayName row
|
, prrDisplayName row
|
||||||
, prrDepth row - 1 -- BalanceReport uses 0-based account depths
|
, prrIndent row - 1 -- BalanceReport uses 0-based account depths
|
||||||
, prrTotal row
|
, prrTotal row
|
||||||
) | row <- prRows report]
|
) | row <- prRows report]
|
||||||
total = prrTotal $ prTotals report
|
total = prrTotal $ prTotals report
|
||||||
|
|||||||
@ -601,7 +601,7 @@ tests_MultiBalanceReport = testGroup "MultiBalanceReport" [
|
|||||||
(eitems, etotal) = r
|
(eitems, etotal) = r
|
||||||
(PeriodicReport _ aitems atotal) = multiBalanceReport rspec' journal
|
(PeriodicReport _ aitems atotal) = multiBalanceReport rspec' journal
|
||||||
showw (PeriodicReportRow a lAmt amt amt')
|
showw (PeriodicReportRow a lAmt amt amt')
|
||||||
= (displayFull a, displayName a, displayDepth a, map showMixedAmountDebug lAmt, showMixedAmountDebug amt, showMixedAmountDebug amt')
|
= (displayFull a, displayName a, displayIndent a, map showMixedAmountDebug lAmt, showMixedAmountDebug amt, showMixedAmountDebug amt')
|
||||||
(map showw aitems) @?= (map showw eitems)
|
(map showw aitems) @?= (map showw eitems)
|
||||||
showMixedAmountDebug (prrTotal atotal) @?= showMixedAmountDebug etotal -- we only check the sum of the totals
|
showMixedAmountDebug (prrTotal atotal) @?= showMixedAmountDebug etotal -- we only check the sum of the totals
|
||||||
in
|
in
|
||||||
|
|||||||
@ -31,7 +31,7 @@ module Hledger.Reports.ReportTypes
|
|||||||
, prrShowDebug
|
, prrShowDebug
|
||||||
, prrFullName
|
, prrFullName
|
||||||
, prrDisplayName
|
, prrDisplayName
|
||||||
, prrDepth
|
, prrIndent
|
||||||
, prrAdd
|
, prrAdd
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -211,11 +211,16 @@ data CBCSubreportSpec a = CBCSubreportSpec
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- | A full name, display name, and depth for an account.
|
-- | The number of indentation steps with which to display a report item.
|
||||||
|
-- 0 means no indentation. 1 means one indent step, which is normally rendered
|
||||||
|
-- as two spaces in text output, or two no-break spaces in csv/html output.
|
||||||
|
type NumberOfIndents = Int
|
||||||
|
|
||||||
|
-- | A full name, display name, and indent level for an account.
|
||||||
data DisplayName = DisplayName
|
data DisplayName = DisplayName
|
||||||
{ displayFull :: AccountName
|
{ displayFull :: AccountName
|
||||||
, displayName :: AccountName
|
, displayName :: AccountName
|
||||||
, displayDepth :: Int
|
, displayIndent :: NumberOfIndents
|
||||||
} deriving (Show, Eq, Ord)
|
} deriving (Show, Eq, Ord)
|
||||||
|
|
||||||
instance ToJSON DisplayName where
|
instance ToJSON DisplayName where
|
||||||
@ -232,15 +237,14 @@ flatDisplayName a = DisplayName a a 1
|
|||||||
treeDisplayName :: AccountName -> DisplayName
|
treeDisplayName :: AccountName -> DisplayName
|
||||||
treeDisplayName a = DisplayName a (accountLeafName a) (accountNameLevel a)
|
treeDisplayName a = DisplayName a (accountLeafName a) (accountNameLevel a)
|
||||||
|
|
||||||
-- | Get the full, canonical, name of a PeriodicReportRow tagged by a
|
-- | Get the full canonical account name from a PeriodicReportRow containing a DisplayName.
|
||||||
-- DisplayName.
|
|
||||||
prrFullName :: PeriodicReportRow DisplayName a -> AccountName
|
prrFullName :: PeriodicReportRow DisplayName a -> AccountName
|
||||||
prrFullName = displayFull . prrName
|
prrFullName = displayFull . prrName
|
||||||
|
|
||||||
-- | Get the display name of a PeriodicReportRow tagged by a DisplayName.
|
-- | Get the account display name from a PeriodicReportRow containing a DisplayName.
|
||||||
prrDisplayName :: PeriodicReportRow DisplayName a -> AccountName
|
prrDisplayName :: PeriodicReportRow DisplayName a -> AccountName
|
||||||
prrDisplayName = displayName . prrName
|
prrDisplayName = displayName . prrName
|
||||||
|
|
||||||
-- | Get the display depth of a PeriodicReportRow tagged by a DisplayName.
|
-- | Get the indent level from a PeriodicReportRow containing a DisplayName.
|
||||||
prrDepth :: PeriodicReportRow DisplayName a -> Int
|
prrIndent :: PeriodicReportRow DisplayName a -> Int
|
||||||
prrDepth = displayDepth . prrName
|
prrIndent = displayIndent . prrName
|
||||||
|
|||||||
@ -932,7 +932,7 @@ multiBalanceReportAsTable opts@ReportOpts{summary_only_, average_, row_total_, b
|
|||||||
in (replicate (length rs) (renderacct row), rs)
|
in (replicate (length rs) (renderacct row), rs)
|
||||||
(accts, rows) = unzip $ fmap fullRowAsTexts items
|
(accts, rows) = unzip $ fmap fullRowAsTexts items
|
||||||
renderacct row =
|
renderacct row =
|
||||||
T.replicate ((prrDepth row - 1) * 2) " " <> prrDisplayName row
|
T.replicate ((prrIndent row - 1) * 2) " " <> prrDisplayName row
|
||||||
addtotalrow
|
addtotalrow
|
||||||
| no_total_ opts = id
|
| no_total_ opts = id
|
||||||
| otherwise =
|
| otherwise =
|
||||||
@ -1343,7 +1343,7 @@ renderPeriodicAcct ::
|
|||||||
ReportOpts -> Text -> PeriodicReportRow DisplayName a -> Text
|
ReportOpts -> Text -> PeriodicReportRow DisplayName a -> Text
|
||||||
renderPeriodicAcct opts space row =
|
renderPeriodicAcct opts space row =
|
||||||
renderBalanceAcct opts space
|
renderBalanceAcct opts space
|
||||||
(prrFullName row, prrDisplayName row, prrDepth row - 1)
|
(prrFullName row, prrDisplayName row, prrIndent row - 1)
|
||||||
|
|
||||||
|
|
||||||
-- tests
|
-- tests
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user