fix: --forecast shouldn't force --auto on (#953, #959)

This commit is contained in:
Simon Michael 2019-02-01 11:43:24 -08:00
parent d6e075dacd
commit 33d82fb657
2 changed files with 20 additions and 5 deletions

View File

@ -140,7 +140,7 @@ journalApplyValue ropts j = do
-- They end on or before the specified report end date, or 180 days from today if unspecified.
--
journalAddForecast :: CliOpts -> Journal -> IO Journal
journalAddForecast opts@CliOpts{reportopts_=ropts} j = do
journalAddForecast opts@CliOpts{inputopts_=iopts, reportopts_=ropts} j = do
today <- getCurrentDay
-- "They start on or after the day following the latest normal transaction in the journal, or today if there are none."
@ -153,15 +153,16 @@ journalAddForecast opts@CliOpts{reportopts_=ropts} j = do
let forecastspan = DateSpan (Just forecaststart) (Just forecastend)
forecasttxns =
-- If there are forecast transaction, lets apply transaction modifiers to them
modifyTransactions (jtxnmodifiers j) $
[ txnTieKnot t | pt <- jperiodictxns j
, t <- runPeriodicTransaction pt forecastspan
, spanContainsDate forecastspan (tdate t)
]
-- With --auto enabled, transaction modifiers are also applied to forecast txns
forecasttxns' = (if auto_ iopts then modifyTransactions (jtxnmodifiers j) else id) forecasttxns
return $
if forecast_ ropts
then journalBalanceTransactions' opts j{ jtxns = concat [jtxns j, forecasttxns] }
then journalBalanceTransactions' opts j{ jtxns = concat [jtxns j, forecasttxns'] }
else j
where
journalBalanceTransactions' opts j =

View File

@ -164,7 +164,7 @@ because it is also included in transaction modifiers.
>=1
## Transaction modifiers affect forecast transactions
## Transaction modifiers affect forecast transactions (#959)
<
= ^income
(liabilities:tax) *.33 ; income tax
@ -192,3 +192,17 @@ $ hledger print -f- --auto --forecast -b 2016-01 -e 2016-03
assets:bank
>=
# and they don't force --auto on
$ hledger print -f- --forecast -b 2016-01 -e 2016-03
2016/01/03 withdraw
assets:cash $20
assets:bank
2016/02/01 paycheck
; recur: monthly from 2016-01
income:remuneration $-100
income:donations $-15
assets:bank
>=