imp: balcmds: csv, html output: change "total" row header to "Total:"

This commit is contained in:
Simon Michael 2024-06-12 04:17:21 +01:00
parent 9788a06223
commit 574115e001
6 changed files with 40 additions and 40 deletions

View File

@ -423,7 +423,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ of
-- | 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 "total" total
headers : concatMap (\(a, _, _, b) -> rows a b) items ++ if no_total_ opts then [] else rows "Total:" total
where
headers = "account" : case layout_ opts of
LayoutBare -> ["commodity", "balance"]
@ -580,8 +580,8 @@ multiBalanceReportAsCsvHelper ishtml opts@ReportOpts{..} (PeriodicReport colspan
where showName = accountNameDrop drop_ . prrFullName
totalrows
| no_total_ = mempty
| ishtml = zipWith (:) ("total":repeat "") $ rowAsText opts colspans tr
| otherwise = map ("total" :) $ rowAsText opts colspans tr
| ishtml = zipWith (:) ("Total:":repeat "") $ rowAsText opts colspans tr
| otherwise = map ("Total:" :) $ rowAsText opts colspans tr
rowAsText = if ishtml then multiBalanceRowAsHtmlText else multiBalanceRowAsCsvText
-- | Render a multi-column balance report as HTML.

View File

@ -833,11 +833,11 @@ $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=
"Assets:US:ETrade","USD","5120.50"
"Assets:US:ETrade","VEA","36.00"
"Assets:US:ETrade","VHT","294.00"
"total","GLD","70.00"
"total","ITOT","17.00"
"total","USD","5120.50"
"total","VEA","36.00"
"total","VHT","294.00"
"Total:","GLD","70.00"
"Total:","ITOT","17.00"
"Total:","USD","5120.50"
"Total:","VEA","36.00"
"Total:","VHT","294.00"
```
Bare layout will sometimes display an extra row for the no-symbol commodity,

View File

@ -6,13 +6,13 @@
$ hledger -f bcexample.hledger bal assets.*etrade -3 -O csv
"account","balance"
"Assets:US:ETrade","70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT"
"total","70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT"
"Total:","70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT"
# ** 2.
$ hledger -f bcexample.hledger bal assets.*etrade -3 -O tsv
account balance
Assets:US:ETrade 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
total 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
Total: 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
# ** 3. Balance report csv output with one line per commodity (--layout=bare).
$ hledger -f bcexample.hledger bal assets.*etrade -3 -O csv --layout=bare
@ -22,11 +22,11 @@ $ hledger -f bcexample.hledger bal assets.*etrade -3 -O csv --layout=bare
"Assets:US:ETrade","USD","5120.50"
"Assets:US:ETrade","VEA","36.00"
"Assets:US:ETrade","VHT","294.00"
"total","GLD","70.00"
"total","ITOT","17.00"
"total","USD","5120.50"
"total","VEA","36.00"
"total","VHT","294.00"
"Total:","GLD","70.00"
"Total:","ITOT","17.00"
"Total:","USD","5120.50"
"Total:","VEA","36.00"
"Total:","VHT","294.00"
# ** 4.
$ hledger -f bcexample.hledger bal assets.*etrade -3 -O tsv --layout=bare
@ -36,11 +36,11 @@ Assets:US:ETrade ITOT 17.00
Assets:US:ETrade USD 5120.50
Assets:US:ETrade VEA 36.00
Assets:US:ETrade VHT 294.00
total GLD 70.00
total ITOT 17.00
total USD 5120.50
total VEA 36.00
total VHT 294.00
Total: GLD 70.00
Total: ITOT 17.00
Total: USD 5120.50
Total: VEA 36.00
Total: VHT 294.00
# ** 5. Balance report output with no commodity column.
$ hledger -f bcexample.hledger bal assets.*etrade -3
@ -74,13 +74,13 @@ $ hledger -f bcexample.hledger bal assets.*etrade -3 --layout=bare
$ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O csv
"account","2012","2013","2014","total"
"Assets:US:ETrade","10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT","70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT","-11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT","70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT"
"total","10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT","70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT","-11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT","70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT"
"Total:","10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT","70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT","-11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT","70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT"
# ** 8.
$ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O tsv
account 2012 2013 2014 total
Assets:US:ETrade 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
total 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
Total: 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
# ** 9. Multicolumn balance report csv output with --layout=bare.
$ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O csv --layout=bare
@ -90,11 +90,11 @@ $ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O csv --layout=bare
"Assets:US:ETrade","USD","337.18","-98.12","4881.44","5120.50"
"Assets:US:ETrade","VEA","12.00","10.00","14.00","36.00"
"Assets:US:ETrade","VHT","106.00","18.00","170.00","294.00"
"total","GLD","0","70.00","0","70.00"
"total","ITOT","10.00","18.00","-11.00","17.00"
"total","USD","337.18","-98.12","4881.44","5120.50"
"total","VEA","12.00","10.00","14.00","36.00"
"total","VHT","106.00","18.00","170.00","294.00"
"Total:","GLD","0","70.00","0","70.00"
"Total:","ITOT","10.00","18.00","-11.00","17.00"
"Total:","USD","337.18","-98.12","4881.44","5120.50"
"Total:","VEA","12.00","10.00","14.00","36.00"
"Total:","VHT","106.00","18.00","170.00","294.00"
# ** 10.
$ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O tsv --layout=bare
@ -104,11 +104,11 @@ Assets:US:ETrade ITOT 10.00 18.00 -11.00 17.00
Assets:US:ETrade USD 337.18 -98.12 4881.44 5120.50
Assets:US:ETrade VEA 12.00 10.00 14.00 36.00
Assets:US:ETrade VHT 106.00 18.00 170.00 294.00
total GLD 0 70.00 0 70.00
total ITOT 10.00 18.00 -11.00 17.00
total USD 337.18 -98.12 4881.44 5120.50
total VEA 12.00 10.00 14.00 36.00
total VHT 106.00 18.00 170.00 294.00
Total: GLD 0 70.00 0 70.00
Total: ITOT 10.00 18.00 -11.00 17.00
Total: USD 337.18 -98.12 4881.44 5120.50
Total: VEA 12.00 10.00 14.00 36.00
Total: VHT 106.00 18.00 170.00 294.00
# ** 11. Multicolumn balance report with --layout=bare.
$ hledger -f bcexample.hledger bal -Y assets.*etrade -3 --average --layout=bare --no-total

View File

@ -10,7 +10,7 @@ Balance changes in 2012-12-01..2013-03-31:
Average || 0 0 3 | 3
$ hledger -f balance-multicol.journal balance -M -A -O csv --transpose
"account","assets","assets:cash","assets:checking","total"
"account","assets","assets:cash","assets:checking","Total:"
"2012-12","0","0","10","10"
"2013-01","0","0","0","0"
"2013-02","1","1","0","2"

View File

@ -313,9 +313,9 @@ $ hledger -f - balancesheet --tree --output-format=csv
"Account","2020-03-25"
"Assets",""
"assets:a","$1"
"total","$1"
"Total:","$1"
"Liabilities",""
"total","0"
"Total:","0"
"Net:","$1"
# ** 13. CSV output supports --drop.
@ -324,9 +324,9 @@ $ hledger -f - balancesheet --tree --output-format=csv --drop 1
"Account","2020-03-25"
"Assets",""
"a","$1"
"total","$1"
"Total:","$1"
"Liabilities",""
"total","0"
"Total:","0"
"Net:","$1"
<
@ -340,9 +340,9 @@ $ hledger -f - balancesheet --output-format=csv
"Account","2020-03-01"
"Assets",""
"assets:a","$-10000.00"
"total","$-10000.00"
"Total:","$-10000.00"
"Liabilities",""
"total","0"
"Total:","0"
"Net:","$-10000.00"
# ** 15. In compound reports like balancesheet, parent accounts might not have

View File

@ -187,4 +187,4 @@ $ hledger -f - bal -O csv
"a","1 JPY"
"b","1 JPY"
"c","1000 JPY"
"total","1002 JPY"
"Total:","1002 JPY"