mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
lib: make --auto work on --forecast transactions
This commit is contained in:
parent
f2aaaf3310
commit
f6e5b3d438
@ -164,13 +164,16 @@ journalAddForecast opts@CliOpts{reportopts_=ropts} j = do
|
||||
let forecastend = dbg2 "forecastend" $ fromMaybe (addDays 180 today) mspecifiedend
|
||||
|
||||
let forecastspan = DateSpan (Just forecaststart) (Just forecastend)
|
||||
forecasttxns = [ txnTieKnot t | pt <- jperiodictxns j
|
||||
, t <- runPeriodicTransaction pt forecastspan
|
||||
, spanContainsDate forecastspan (tdate t)
|
||||
]
|
||||
forecasttxns =
|
||||
-- If there are forecast transaction, lets apply transaction modifiers to them
|
||||
map (foldr (flip (.) . transactionModifierToFunction) id (jtxnmodifiers j)) $
|
||||
[ txnTieKnot t | pt <- jperiodictxns j
|
||||
, t <- runPeriodicTransaction pt forecastspan
|
||||
, spanContainsDate forecastspan (tdate t)
|
||||
]
|
||||
return $
|
||||
if forecast_ ropts
|
||||
then journalBalanceTransactions' opts j{ jtxns = forecasttxns ++ jtxns j } -- XXX wouldn't appending be better ?
|
||||
then journalBalanceTransactions' opts j{ jtxns = concat [forecasttxns, jtxns j] }
|
||||
else j
|
||||
where
|
||||
journalBalanceTransactions' opts j =
|
||||
|
@ -164,3 +164,31 @@ because it is also included in transaction modifiers.
|
||||
|
||||
>=1
|
||||
|
||||
## Transaction modifiers affect forecast transactions
|
||||
<
|
||||
= ^income
|
||||
(liabilities:tax) *.33 ; income tax
|
||||
|
||||
~ monthly from 2016-01 paycheck
|
||||
income:remuneration $-100
|
||||
income:donations $-15
|
||||
assets:bank
|
||||
|
||||
2016/1/3 withdraw
|
||||
assets:cash $20
|
||||
assets:bank
|
||||
|
||||
$ hledger print -f- --auto --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
|
||||
(liabilities:tax) $-33 ; income tax
|
||||
income:donations $-15
|
||||
(liabilities:tax) $-5 ; income tax
|
||||
assets:bank
|
||||
|
||||
>=
|
||||
|
Loading…
Reference in New Issue
Block a user