imp: csv: Include the start and end dates of intervals, as well as
string representation of the period, in tidy csv output, and never include row totals or averages.
This commit is contained in:
parent
35c1c9b6a2
commit
71646f993c
@ -266,7 +266,7 @@ import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Builder as TB
|
||||
import Data.Time (fromGregorian)
|
||||
import Data.Time (addDays, fromGregorian)
|
||||
import System.Console.CmdArgs.Explicit as C
|
||||
import Lucid as L
|
||||
import Safe (headMay, maximumMay)
|
||||
@ -530,7 +530,7 @@ multiBalanceReportAsCsv' opts@ReportOpts{..} (PeriodicReport colspans items tr)
|
||||
)
|
||||
where
|
||||
headers = "account" : case layout_ of
|
||||
LayoutTidy -> ["date", "commodity", "value"]
|
||||
LayoutTidy -> ["period", "start_date", "end_date", "commodity", "value"]
|
||||
LayoutBare -> "commodity" : dateHeaders
|
||||
_ -> dateHeaders
|
||||
dateHeaders = map showDateSpan colspans ++ ["total" | row_total_] ++ ["average" | average_]
|
||||
@ -708,19 +708,20 @@ multiBalanceRowAsWbs bopts ReportOpts{..} colspans (PeriodicReportRow _ as rowto
|
||||
. fmap (showMixedAmountLinesB bopts{displayOrder=Just cs, displayMinWidth=Nothing})
|
||||
$ all
|
||||
LayoutTidy -> concat
|
||||
. zipWith (\d -> map (wbFromText d :)) dates
|
||||
. zipWith (map . addDateColumns) colspans
|
||||
. fmap ( zipWith (\c a -> [wbFromText c, a]) cs
|
||||
. showMixedAmountLinesB bopts{displayOrder=Just cs, displayMinWidth=Nothing})
|
||||
$ all
|
||||
$ as -- Do not include totals column or average for tidy output, as this
|
||||
-- complicates the data representation and can be easily calculated
|
||||
where
|
||||
totalscolumn = row_total_ && balanceaccum_ `notElem` [Cumulative, Historical]
|
||||
cs = S.toList . foldl' S.union mempty $ fmap maCommodities all
|
||||
all = as
|
||||
++ [rowtot | totalscolumn && not (null as)]
|
||||
++ [rowavg | average_ && not (null as)]
|
||||
dates = map showDateSpan colspans
|
||||
++ ["Total" | totalscolumn && not (null as)]
|
||||
++ ["Average" | average_ && not (null as)]
|
||||
addDateColumns span@(DateSpan s e) = (wbFromText (showDateSpan span) :)
|
||||
. (wbFromText (maybe "" showDate s) :)
|
||||
. (wbFromText (maybe "" (showDate . addDays (-1)) e) :)
|
||||
|
||||
paddedTranspose :: a -> [[a]] -> [[a]]
|
||||
paddedTranspose _ [] = [[]]
|
||||
|
||||
@ -239,45 +239,35 @@ Balance Sheet 2014-10-11
|
||||
# 13. Multicolumn balance report csv output with --layout=tidy
|
||||
$ hledger -f bcexample.hledger bal -T -Y assets.*etrade -3 -O csv --layout=tidy
|
||||
>
|
||||
"account","date","commodity","value"
|
||||
"Assets:US:ETrade","2012","GLD","0"
|
||||
"Assets:US:ETrade","2012","ITOT","10.00"
|
||||
"Assets:US:ETrade","2012","USD","337.18"
|
||||
"Assets:US:ETrade","2012","VEA","12.00"
|
||||
"Assets:US:ETrade","2012","VHT","106.00"
|
||||
"Assets:US:ETrade","2013","GLD","70.00"
|
||||
"Assets:US:ETrade","2013","ITOT","18.00"
|
||||
"Assets:US:ETrade","2013","USD","-98.12"
|
||||
"Assets:US:ETrade","2013","VEA","10.00"
|
||||
"Assets:US:ETrade","2013","VHT","18.00"
|
||||
"Assets:US:ETrade","2014","GLD","0"
|
||||
"Assets:US:ETrade","2014","ITOT","-11.00"
|
||||
"Assets:US:ETrade","2014","USD","4881.44"
|
||||
"Assets:US:ETrade","2014","VEA","14.00"
|
||||
"Assets:US:ETrade","2014","VHT","170.00"
|
||||
"Assets:US:ETrade","Total","GLD","70.00"
|
||||
"Assets:US:ETrade","Total","ITOT","17.00"
|
||||
"Assets:US:ETrade","Total","USD","5120.50"
|
||||
"Assets:US:ETrade","Total","VEA","36.00"
|
||||
"Assets:US:ETrade","Total","VHT","294.00"
|
||||
"total","2012","GLD","0"
|
||||
"total","2012","ITOT","10.00"
|
||||
"total","2012","USD","337.18"
|
||||
"total","2012","VEA","12.00"
|
||||
"total","2012","VHT","106.00"
|
||||
"total","2013","GLD","70.00"
|
||||
"total","2013","ITOT","18.00"
|
||||
"total","2013","USD","-98.12"
|
||||
"total","2013","VEA","10.00"
|
||||
"total","2013","VHT","18.00"
|
||||
"total","2014","GLD","0"
|
||||
"total","2014","ITOT","-11.00"
|
||||
"total","2014","USD","4881.44"
|
||||
"total","2014","VEA","14.00"
|
||||
"total","2014","VHT","170.00"
|
||||
"total","Total","GLD","70.00"
|
||||
"total","Total","ITOT","17.00"
|
||||
"total","Total","USD","5120.50"
|
||||
"total","Total","VEA","36.00"
|
||||
"total","Total","VHT","294.00"
|
||||
"account","period","start_date","end_date","commodity","value"
|
||||
"Assets:US:ETrade","2012","2012-01-01","2012-12-31","GLD","0"
|
||||
"Assets:US:ETrade","2012","2012-01-01","2012-12-31","ITOT","10.00"
|
||||
"Assets:US:ETrade","2012","2012-01-01","2012-12-31","USD","337.18"
|
||||
"Assets:US:ETrade","2012","2012-01-01","2012-12-31","VEA","12.00"
|
||||
"Assets:US:ETrade","2012","2012-01-01","2012-12-31","VHT","106.00"
|
||||
"Assets:US:ETrade","2013","2013-01-01","2013-12-31","GLD","70.00"
|
||||
"Assets:US:ETrade","2013","2013-01-01","2013-12-31","ITOT","18.00"
|
||||
"Assets:US:ETrade","2013","2013-01-01","2013-12-31","USD","-98.12"
|
||||
"Assets:US:ETrade","2013","2013-01-01","2013-12-31","VEA","10.00"
|
||||
"Assets:US:ETrade","2013","2013-01-01","2013-12-31","VHT","18.00"
|
||||
"Assets:US:ETrade","2014","2014-01-01","2014-12-31","GLD","0"
|
||||
"Assets:US:ETrade","2014","2014-01-01","2014-12-31","ITOT","-11.00"
|
||||
"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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user