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:
Simon Michael 2024-10-08 22:22:57 -10:00
parent 75ad734edf
commit 6ce5e85e99
4 changed files with 19 additions and 15 deletions

View File

@ -71,7 +71,7 @@ balanceReport rspec j = (rows, total)
report = multiBalanceReport rspec j
rows = [( prrFullName row
, prrDisplayName row
, prrDepth row - 1 -- BalanceReport uses 0-based account depths
, prrIndent row - 1 -- BalanceReport uses 0-based account depths
, prrTotal row
) | row <- prRows report]
total = prrTotal $ prTotals report

View File

@ -601,7 +601,7 @@ tests_MultiBalanceReport = testGroup "MultiBalanceReport" [
(eitems, etotal) = r
(PeriodicReport _ aitems atotal) = multiBalanceReport rspec' journal
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)
showMixedAmountDebug (prrTotal atotal) @?= showMixedAmountDebug etotal -- we only check the sum of the totals
in

View File

@ -31,7 +31,7 @@ module Hledger.Reports.ReportTypes
, prrShowDebug
, prrFullName
, prrDisplayName
, prrDepth
, prrIndent
, prrAdd
) 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
{ displayFull :: AccountName
, displayName :: AccountName
, displayDepth :: Int
{ displayFull :: AccountName
, displayName :: AccountName
, displayIndent :: NumberOfIndents
} deriving (Show, Eq, Ord)
instance ToJSON DisplayName where
@ -232,15 +237,14 @@ flatDisplayName a = DisplayName a a 1
treeDisplayName :: AccountName -> DisplayName
treeDisplayName a = DisplayName a (accountLeafName a) (accountNameLevel a)
-- | Get the full, canonical, name of a PeriodicReportRow tagged by a
-- DisplayName.
-- | Get the full canonical account name from a PeriodicReportRow containing a DisplayName.
prrFullName :: PeriodicReportRow DisplayName a -> AccountName
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 = displayName . prrName
-- | Get the display depth of a PeriodicReportRow tagged by a DisplayName.
prrDepth :: PeriodicReportRow DisplayName a -> Int
prrDepth = displayDepth . prrName
-- | Get the indent level from a PeriodicReportRow containing a DisplayName.
prrIndent :: PeriodicReportRow DisplayName a -> Int
prrIndent = displayIndent . prrName

View File

@ -932,7 +932,7 @@ multiBalanceReportAsTable opts@ReportOpts{summary_only_, average_, row_total_, b
in (replicate (length rs) (renderacct row), rs)
(accts, rows) = unzip $ fmap fullRowAsTexts items
renderacct row =
T.replicate ((prrDepth row - 1) * 2) " " <> prrDisplayName row
T.replicate ((prrIndent row - 1) * 2) " " <> prrDisplayName row
addtotalrow
| no_total_ opts = id
| otherwise =
@ -1343,7 +1343,7 @@ renderPeriodicAcct ::
ReportOpts -> Text -> PeriodicReportRow DisplayName a -> Text
renderPeriodicAcct opts space row =
renderBalanceAcct opts space
(prrFullName row, prrDisplayName row, prrDepth row - 1)
(prrFullName row, prrDisplayName row, prrIndent row - 1)
-- tests