mirror of
https://github.com/simonmichael/hledger.git
synced 2025-01-05 18:13:12 +03:00
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.
|
||||
balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV
|
||||
balanceReportAsCsv opts (items, total) =
|
||||
headers : concatMap (\(a, _, _, b) -> rows a b) items ++ if no_total_ opts then [] else rows totalRowHeadingCsv total
|
||||
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)
|
||||
balanceReportAsCsv opts =
|
||||
map (map Ods.cellContent) . balanceReportAsSpreadsheet opts
|
||||
|
||||
-- | Render a single-column balance report as plain text.
|
||||
balanceReportAsText :: ReportOpts -> BalanceReport -> TB.Builder
|
||||
|
Loading…
Reference in New Issue
Block a user