From 574115e00157ed98dee32dd657a54b558d517e06 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 12 Jun 2024 04:17:21 +0100 Subject: [PATCH] imp: balcmds: csv, html output: change "total" row header to "Total:" --- hledger/Hledger/Cli/Commands/Balance.hs | 6 ++-- hledger/Hledger/Cli/Commands/Balance.md | 10 +++--- hledger/test/balance/layout.test | 48 ++++++++++++------------- hledger/test/balance/transpose.test | 2 +- hledger/test/balancesheet.test | 12 +++---- hledger/test/journal/precision.test | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index dc18af1ab..902db7c44 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -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. diff --git a/hledger/Hledger/Cli/Commands/Balance.md b/hledger/Hledger/Cli/Commands/Balance.md index 1a7b55e62..5ea0f27cd 100644 --- a/hledger/Hledger/Cli/Commands/Balance.md +++ b/hledger/Hledger/Cli/Commands/Balance.md @@ -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, diff --git a/hledger/test/balance/layout.test b/hledger/test/balance/layout.test index 37a5c547a..ee183eec7 100644 --- a/hledger/test/balance/layout.test +++ b/hledger/test/balance/layout.test @@ -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 diff --git a/hledger/test/balance/transpose.test b/hledger/test/balance/transpose.test index 458a2aaf2..5f4f647a0 100644 --- a/hledger/test/balance/transpose.test +++ b/hledger/test/balance/transpose.test @@ -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" diff --git a/hledger/test/balancesheet.test b/hledger/test/balancesheet.test index 69a464d42..858339212 100644 --- a/hledger/test/balancesheet.test +++ b/hledger/test/balancesheet.test @@ -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 diff --git a/hledger/test/journal/precision.test b/hledger/test/journal/precision.test index f6bb1375a..f19e8b968 100644 --- a/hledger/test/journal/precision.test +++ b/hledger/test/journal/precision.test @@ -187,4 +187,4 @@ $ hledger -f - bal -O csv "a","1 JPY" "b","1 JPY" "c","1000 JPY" -"total","1002 JPY" +"Total:","1002 JPY"