cleanups
This commit is contained in:
parent
d4eb3caf70
commit
a56c547bc2
@ -312,6 +312,7 @@ balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|||||||
interval = interval_ ropts
|
interval = interval_ ropts
|
||||||
case interval of
|
case interval of
|
||||||
NoInterval -> do
|
NoInterval -> do
|
||||||
|
-- single column balance report
|
||||||
let report
|
let report
|
||||||
| balancetype_ ropts `elem` [HistoricalBalance, CumulativeChange]
|
| balancetype_ ropts `elem` [HistoricalBalance, CumulativeChange]
|
||||||
= let ropts' | flat_ ropts = ropts
|
= let ropts' | flat_ ropts = ropts
|
||||||
@ -326,6 +327,7 @@ balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|||||||
writeOutput opts $ render ropts report
|
writeOutput opts $ render ropts report
|
||||||
|
|
||||||
_ | boolopt "budget" rawopts -> do
|
_ | boolopt "budget" rawopts -> do
|
||||||
|
-- multi column budget report
|
||||||
let budget = budgetJournal opts j
|
let budget = budgetJournal opts j
|
||||||
j' = budgetRollUp opts budget j
|
j' = budgetRollUp opts budget j
|
||||||
report = multiBalanceReport ropts (queryFromOpts d ropts) j'
|
report = multiBalanceReport ropts (queryFromOpts d ropts) j'
|
||||||
@ -337,6 +339,7 @@ balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|||||||
writeOutput opts $ render report
|
writeOutput opts $ render report
|
||||||
|
|
||||||
| otherwise -> do
|
| otherwise -> do
|
||||||
|
-- multi column balance report
|
||||||
let report = multiBalanceReport ropts (queryFromOpts d ropts) j
|
let report = multiBalanceReport ropts (queryFromOpts d ropts) j
|
||||||
render = case format of
|
render = case format of
|
||||||
"csv" -> (++ "\n") . printCSV . multiBalanceReportAsCsv ropts
|
"csv" -> (++ "\n") . printCSV . multiBalanceReportAsCsv ropts
|
||||||
@ -636,9 +639,10 @@ multiBalanceReportAsText opts r =
|
|||||||
CumulativeChange -> "Ending balances (cumulative)"
|
CumulativeChange -> "Ending balances (cumulative)"
|
||||||
HistoricalBalance -> "Ending balances (historical)"
|
HistoricalBalance -> "Ending balances (historical)"
|
||||||
|
|
||||||
-- | Render two multi-column balance reports as plain text suitable for console output.
|
-- | Given two multi-column balance reports, the first representing a budget
|
||||||
-- They are assumed to have same number of columns, one of them representing
|
-- (target change amounts) and the second representing actual change amounts,
|
||||||
-- a budget
|
-- render a budget report as plain text suitable for console output.
|
||||||
|
-- The reports should have the same number of columns.
|
||||||
multiBalanceReportWithBudgetAsText :: ReportOpts -> MultiBalanceReport -> MultiBalanceReport -> String
|
multiBalanceReportWithBudgetAsText :: ReportOpts -> MultiBalanceReport -> MultiBalanceReport -> String
|
||||||
multiBalanceReportWithBudgetAsText opts budget r =
|
multiBalanceReportWithBudgetAsText opts budget r =
|
||||||
printf "%s in %s:\n\n" typeStr (showDateSpan $ multiBalanceReportSpan r)
|
printf "%s in %s:\n\n" typeStr (showDateSpan $ multiBalanceReportSpan r)
|
||||||
@ -667,12 +671,12 @@ multiBalanceReportWithBudgetAsText opts budget r =
|
|||||||
toCost = normaliseMixedAmount . costOfMixedAmount
|
toCost = normaliseMixedAmount . costOfMixedAmount
|
||||||
showamt | color_ opts = cshowMixedAmountOneLineWithoutPrice
|
showamt | color_ opts = cshowMixedAmountOneLineWithoutPrice
|
||||||
| otherwise = showMixedAmountOneLineWithoutPrice
|
| otherwise = showMixedAmountOneLineWithoutPrice
|
||||||
-- combine reportTable budgetTable will combine them into a single table where cells
|
|
||||||
-- are tuples of (actual, Maybe budget) numbers. Main assumptions is that
|
-- Combine a table of actual amounts and a table of budgeted amounts into
|
||||||
-- row/column titles of budgetTable are subset of row/column titles or reportTable,
|
-- a single table of (actualamount, Maybe budgetamount) tuples.
|
||||||
-- and there are now row/column titles in budgetTable that are not mentioned in reporTable.
|
-- The budget table's row/column titles should be a subset of the actual table's.
|
||||||
-- Both of these are satisfied by construction of budget report and process of rolling up
|
-- (This is satisfied by the construction of the budget report and the
|
||||||
-- account names.
|
-- process of rolling up account names.)
|
||||||
combine (Table l t d) (Table l' t' d') = Table l t combinedRows
|
combine (Table l t d) (Table l' t' d') = Table l t combinedRows
|
||||||
where
|
where
|
||||||
-- For all accounts that are present in the budget, zip real amounts with budget amounts
|
-- For all accounts that are present in the budget, zip real amounts with budget amounts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user