imp: csv: Ignore --row-totals with tidy csv output.

This commit is contained in:
Stephen Morgan 2021-12-07 11:40:32 +11:00 committed by Simon Michael
parent fb0472e0e9
commit 29ee0c331f
2 changed files with 7 additions and 22 deletions

View File

@ -520,8 +520,13 @@ renderComponent topaligned oneline opts (acctname, depth, total) (FormatField lj
-- The CSV will always include the initial headings row,
-- and will include the final totals row unless --no-total is set.
multiBalanceReportAsCsv :: ReportOpts -> MultiBalanceReport -> CSV
multiBalanceReportAsCsv opts@ReportOpts{..} =
(if transpose_ then transpose else id) . uncurry (++) . multiBalanceReportAsCsv' opts
multiBalanceReportAsCsv opts@ReportOpts{..} report = maybeTranspose allRows
where
allRows = case layout_ of
LayoutTidy -> rows -- tidy csv should not include totals or averages
_ -> rows ++ totals
(rows, totals) = multiBalanceReportAsCsv' opts report
maybeTranspose = if transpose_ then transpose else id
multiBalanceReportAsCsv' :: ReportOpts -> MultiBalanceReport -> (CSV, CSV)
multiBalanceReportAsCsv' opts@ReportOpts{..} (PeriodicReport colspans items tr) =

View File

@ -255,21 +255,6 @@ $ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O csv --layout=tidy
"Assets:US:ETrade","2014","2014-01-01","2014-12-31","USD","4881.44"
"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VEA","14.00"
"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VHT","170.00"
"total","2012","2012-01-01","2012-12-31","GLD","0"
"total","2012","2012-01-01","2012-12-31","ITOT","10.00"
"total","2012","2012-01-01","2012-12-31","USD","337.18"
"total","2012","2012-01-01","2012-12-31","VEA","12.00"
"total","2012","2012-01-01","2012-12-31","VHT","106.00"
"total","2013","2013-01-01","2013-12-31","GLD","70.00"
"total","2013","2013-01-01","2013-12-31","ITOT","18.00"
"total","2013","2013-01-01","2013-12-31","USD","-98.12"
"total","2013","2013-01-01","2013-12-31","VEA","10.00"
"total","2013","2013-01-01","2013-12-31","VHT","18.00"
"total","2014","2014-01-01","2014-12-31","GLD","0"
"total","2014","2014-01-01","2014-12-31","ITOT","-11.00"
"total","2014","2014-01-01","2014-12-31","USD","4881.44"
"total","2014","2014-01-01","2014-12-31","VEA","14.00"
"total","2014","2014-01-01","2014-12-31","VHT","170.00"
>=0
# 14. Single column balance report csv output with --layout=tidy
@ -281,9 +266,4 @@ $ hledger -f bcexample.hledger bal -T assets.*etrade -3 -O csv --layout=tidy
"Assets:US:ETrade","2012-01-01..2014-10-11","2012-01-01","2014-10-11","USD","5120.50"
"Assets:US:ETrade","2012-01-01..2014-10-11","2012-01-01","2014-10-11","VEA","36.00"
"Assets:US:ETrade","2012-01-01..2014-10-11","2012-01-01","2014-10-11","VHT","294.00"
"total","2012-01-01..2014-10-11","2012-01-01","2014-10-11","GLD","70.00"
"total","2012-01-01..2014-10-11","2012-01-01","2014-10-11","ITOT","17.00"
"total","2012-01-01..2014-10-11","2012-01-01","2014-10-11","USD","5120.50"
"total","2012-01-01..2014-10-11","2012-01-01","2014-10-11","VEA","36.00"
"total","2012-01-01..2014-10-11","2012-01-01","2014-10-11","VHT","294.00"
>=0