budget: refactor date handling, add debug output
This commit is contained in:
parent
c306193667
commit
939d6833ea
@ -329,10 +329,11 @@ balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|||||||
|
|
||||||
_ | boolopt "budget" rawopts -> do
|
_ | boolopt "budget" rawopts -> do
|
||||||
-- multi column budget report
|
-- multi column budget report
|
||||||
let budget = budgetJournal opts j
|
reportspan <- dbg1 "reportspan" <$> reportSpan j ropts
|
||||||
|
let budget = budgetJournal opts reportspan j
|
||||||
j' = budgetRollUp opts budget j
|
j' = budgetRollUp opts budget j
|
||||||
report = multiBalanceReport ropts (queryFromOpts d ropts) j'
|
report = dbg1 "report" $ multiBalanceReport ropts (queryFromOpts d ropts) j'
|
||||||
budgetReport = multiBalanceReport ropts (queryFromOpts d ropts) budget
|
budgetReport = dbg1 "budgetreport" $ multiBalanceReport ropts (queryFromOpts d ropts) budget
|
||||||
render = case format of
|
render = case format of
|
||||||
"csv" -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report." -- TODO
|
"csv" -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report." -- TODO
|
||||||
"html" -> const $ error' "Sorry, HTML output is not yet implemented for this kind of report." -- TODO
|
"html" -> const $ error' "Sorry, HTML output is not yet implemented for this kind of report." -- TODO
|
||||||
@ -369,19 +370,21 @@ budgetRollUp CliOpts{rawopts_=rawopts} budget j = j { jtxns = remapTxn <$> jtxns
|
|||||||
mapPostings f t = txnTieKnot $ t { tpostings = f $ tpostings t }
|
mapPostings f t = txnTieKnot $ t { tpostings = f $ tpostings t }
|
||||||
|
|
||||||
-- | Select all periodic transactions from the given journal which
|
-- | Select all periodic transactions from the given journal which
|
||||||
-- match the opts-specified report interval, and use them to generate
|
-- match the requested report interval, and use them to generate
|
||||||
-- budget transactions (like forecast transactions) in the specified
|
-- budget transactions (like forecast transactions) in the specified
|
||||||
-- report period.
|
-- report period (calculated in IO and passed in).
|
||||||
budgetJournal :: CliOpts -> Journal -> Journal
|
budgetJournal :: CliOpts -> DateSpan -> Journal -> Journal
|
||||||
budgetJournal opts j = journalBalanceTransactions' opts j { jtxns = budgetts }
|
budgetJournal opts reportspan j = journalBalanceTransactions' opts j { jtxns = budgetts }
|
||||||
where
|
where
|
||||||
interval = intervalFromRawOpts $ rawopts_ opts
|
budgetinterval = dbg2 "budgetinterval" $ intervalFromRawOpts $ rawopts_ opts
|
||||||
dates = spanIntersect (jdatespan j) (periodAsDateSpan $ period_ $ reportopts_ opts)
|
budgetspan = dbg2 "budgetspan" $ reportspan
|
||||||
budgetts = [makeBudgetTxn t
|
budgetts =
|
||||||
| pt <- jperiodictxns j
|
dbg1 "budgetts" $
|
||||||
, periodTransactionInterval pt == Just interval
|
[makeBudgetTxn t
|
||||||
, t <- runPeriodicTransaction pt dates
|
| pt <- jperiodictxns j
|
||||||
]
|
, periodTransactionInterval pt == Just budgetinterval
|
||||||
|
, t <- runPeriodicTransaction pt budgetspan
|
||||||
|
]
|
||||||
makeBudgetTxn t = txnTieKnot $ t { tdescription = T.pack "Budget transaction" }
|
makeBudgetTxn t = txnTieKnot $ t { tdescription = T.pack "Budget transaction" }
|
||||||
journalBalanceTransactions' opts j =
|
journalBalanceTransactions' opts j =
|
||||||
let assrt = not . ignore_assertions_ $ inputopts_ opts
|
let assrt = not . ignore_assertions_ $ inputopts_ opts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user