From 5a322c1908da94a34588007fdf8e0219b83c1264 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Sun, 6 Jun 2021 22:32:11 +1000 Subject: [PATCH] cli: Make sure full account name is used (possibly including dropping) for csv output. (#1566) --- hledger/Hledger/Cli/Commands/Balance.hs | 2 +- hledger/test/balance/drop.test | 10 ++++++++++ hledger/test/balancesheet.test | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 215adc004..b29c7699b 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -476,7 +476,7 @@ multiBalanceReportAsCsv opts@ReportOpts{average_, row_total_} ++ ["total" | row_total_] ++ ["average" | average_] ) : - [displayName a : + [accountNameDrop (drop_ opts) (displayFull a) : map (wbToText . showMixedAmountB (balanceOpts False opts)) (amts ++ [rowtot | row_total_] diff --git a/hledger/test/balance/drop.test b/hledger/test/balance/drop.test index 283dbc092..de1e355c8 100644 --- a/hledger/test/balance/drop.test +++ b/hledger/test/balance/drop.test @@ -41,3 +41,13 @@ $ hledger -f - balance --tree --no-total --drop 1 1 q 1 ... >= + +# 4. Drop works with csv output in tree mode +$ hledger -f - balance --tree --no-total --output-format=csv --drop 1 +"account","balance" +"k","1" +"i:p","1" +"j","2" +"j:q","1" +"...","1" +>= diff --git a/hledger/test/balancesheet.test b/hledger/test/balancesheet.test index ef1bf0c93..2e6e2618f 100644 --- a/hledger/test/balancesheet.test +++ b/hledger/test/balancesheet.test @@ -305,3 +305,25 @@ Balance Sheet 2020-03-25 || =============++============ Net: || $1 + +# 12. Check csv output (for tree mode) (#1566) +$ hledger -f - balancesheet --tree --output-format=csv +"Balance Sheet 2020-03-25","" +"Account","2020-03-25" +"Assets","" +"assets:a","$1" +"total","$1" +"Liabilities","" +"total" +"Net:","$1" + +# 13. Check csv output (for tree mode) with dropping +$ hledger -f - balancesheet --tree --output-format=csv --drop 1 +"Balance Sheet 2020-03-25","" +"Account","2020-03-25" +"Assets","" +"a","$1" +"total","$1" +"Liabilities","" +"total" +"Net:","$1"