cli: Cli.Balance.balanceReportAsCvs: now based on balanceReportAsSpreadsheet
This warrants consistency of ODS, HTML and CSV export.
This commit is contained in:
parent
37be769540
commit
48723c930c
@ -430,26 +430,8 @@ totalRowHeadingBudgetCsv = "Total:"
|
|||||||
|
|
||||||
-- | Render a single-column balance report as CSV.
|
-- | Render a single-column balance report as CSV.
|
||||||
balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV
|
balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV
|
||||||
balanceReportAsCsv opts (items, total) =
|
balanceReportAsCsv opts =
|
||||||
headers : concatMap (\(a, _, _, b) -> rows a b) items ++ if no_total_ opts then [] else rows totalRowHeadingCsv total
|
map (map Ods.cellContent) . balanceReportAsSpreadsheet opts
|
||||||
where
|
|
||||||
headers = "account" : case layout_ opts of
|
|
||||||
LayoutBare -> ["commodity", "balance"]
|
|
||||||
_ -> ["balance"]
|
|
||||||
rows :: AccountName -> MixedAmount -> [[T.Text]]
|
|
||||||
rows name ma = case layout_ opts of
|
|
||||||
LayoutBare ->
|
|
||||||
map (\a -> [showName name, acommodity a, renderAmount $ mixedAmount a])
|
|
||||||
. amounts $ mixedAmountStripCosts ma
|
|
||||||
_ -> [[showName name, renderAmount ma]]
|
|
||||||
|
|
||||||
showName = accountNameDrop (drop_ opts)
|
|
||||||
renderAmount amt = wbToText $ showMixedAmountB bopts amt
|
|
||||||
where
|
|
||||||
bopts = machineFmt{displayCommodity=showcomm, displayCommodityOrder = commorder}
|
|
||||||
(showcomm, commorder)
|
|
||||||
| layout_ opts == LayoutBare = (False, Just $ S.toList $ maCommodities amt)
|
|
||||||
| otherwise = (True, Nothing)
|
|
||||||
|
|
||||||
-- | Render a single-column balance report as plain text.
|
-- | Render a single-column balance report as plain text.
|
||||||
balanceReportAsText :: ReportOpts -> BalanceReport -> TB.Builder
|
balanceReportAsText :: ReportOpts -> BalanceReport -> TB.Builder
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user