Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions hledger/Hledger/Cli/Commands/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ module Hledger.Cli.Commands.Balance (
,tidyColumnLabels
,nbsp
,RowClass(..)
,accountClass
-- ** Tests
,tests_Balance
) where
Expand Down Expand Up @@ -452,6 +453,9 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ ropts of

-- Rendering

accountClass :: Ods.Class
accountClass = Ods.Class "account"

data RowClass = Value | Total
deriving (Eq, Ord, Enum, Bounded, Show)

Expand Down Expand Up @@ -735,7 +739,7 @@ balanceReportAsSpreadsheetParts fmt opts (items, total) =
setAccountAnchor
(guard (rc==Value) >> balance_base_url_ opts)
(querystring_ opts) name $
(\c -> c{Ods.cellClass = Ods.Class "account"}) $
(\c -> c{Ods.cellClass = accountClass}) $
cell $ case rc of
Total -> dispName -- show the total row heading as is; --drop etc. don't apply (#2688)
Value -> renderBalanceAcct opts nbsp (name, dispName, dep) in
Expand Down Expand Up @@ -799,9 +803,8 @@ multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..}
allCommodities (PeriodicReport colspans items tr) =
(allHeaders, concatMap fullRowAsTexts items, addTotalBorders totalrows)
where
accountCell label =
(Ods.defaultCell label) {Ods.cellClass = Ods.Class "account"}
hCell cls label = (headerCell label) {Ods.cellClass = Ods.Class cls}
accountCell label = (Ods.defaultCell label) {Ods.cellClass = accountClass}
hCell cls label = (headerCell label) {Ods.cellClass = cls}
allHeaders =
case layout_ of
LayoutBareWide ->
Expand All @@ -812,19 +815,19 @@ multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..}
_ -> [headers]
headers =
addHeaderBorders $
hCell "account" "account" :
hCell accountClass "account" :
case layout_ of
LayoutTidy -> map headerCell tidyColumnLabels
LayoutBareWide -> dateHeaders >> map headerCell allCommodities
LayoutBare -> headerCell "commodity" : dateHeaders
_ -> dateHeaders
-- The headings over columns of figures are marked as such, so that a
-- stylesheet can align them with the figures below (cf amountClass).
amountHeader c = c{Ods.cellClass = Ods.Class "amount"}
amountHeader c = c{Ods.cellClass = amountClass Value}
dateHeaders =
(if not summary_only_ then map (amountHeader . headerDateSpanCell period_titles_ balance_base_url_ querystring_) colspans else [] )++
[hCell "amount rowtotal" "total" | multiBalanceHasTotalsColumn opts] ++
[hCell "amount rowaverage" "average" | average_]
[hCell (rowTotalClass Value) "total" | multiBalanceHasTotalsColumn opts] ++
[hCell (rowAverageClass Value) "average" | average_]
fullRowAsTexts row =
addRowSpanHeader anchorCell $
rowAsText Value (dateSpanCell period_titles_ balance_base_url_ querystring_ acctName) row
Expand Down
4 changes: 2 additions & 2 deletions hledger/Hledger/Cli/CompoundBalanceCommand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ compoundBalanceReportAsSpreadsheet fmt accountLabel maybeBlank ropts cbr =
accountCell =
(Spr.defaultCell subreporttitle) {
Spr.cellStyle = Spr.Body Spr.Total,
Spr.cellClass = Spr.Class "account"
Spr.cellClass = accountClass
}
titleRows
| T.null subreporttitle = []
Expand All @@ -444,7 +444,7 @@ compoundBalanceReportAsSpreadsheet fmt accountLabel maybeBlank ropts cbr =
-- make a table of rendered lines of the report totals row
& map (map (fmap wbToText))
& Spr.addRowSpanHeader
((Spr.defaultCell "Net:") {Spr.cellClass = Spr.Class "account"})
((Spr.defaultCell "Net:") {Spr.cellClass = accountClass})
-- insert a headings column, with Net: on the first line only
& addTotalBorders -- marking the first row for special styling

Expand Down