;lib: refactor journalAddForecast
This commit is contained in:
parent
fe5a97be81
commit
831ec0dcf0
@ -120,14 +120,16 @@ journalAddForecast CliOpts{inputopts_=iopts, reportopts_=ropts} j = do
|
|||||||
today <- getCurrentDay
|
today <- getCurrentDay
|
||||||
|
|
||||||
-- "They can start no earlier than: the day following the latest normal transaction in the journal (or today if there are none)."
|
-- "They can start no earlier than: the day following the latest normal transaction in the journal (or today if there are none)."
|
||||||
let mjournalend = dbg2 "journalEndDate" $ journalEndDate False j -- ignore secondary dates
|
let
|
||||||
|
mjournalend = dbg2 "journalEndDate" $ journalEndDate False j -- ignore secondary dates
|
||||||
forecastbeginDefault = dbg2 "forecastbeginDefault" $ fromMaybe today mjournalend
|
forecastbeginDefault = dbg2 "forecastbeginDefault" $ fromMaybe today mjournalend
|
||||||
|
|
||||||
-- "They end on or before the specified report end date, or 180 days from today if unspecified."
|
-- "They end on or before the specified report end date, or 180 days from today if unspecified."
|
||||||
mspecifiedend <- snd . dbg2 "specifieddates" <$> specifiedStartEndDates ropts
|
mspecifiedend <- snd . dbg2 "specifieddates" <$> specifiedStartEndDates ropts
|
||||||
let forecastendDefault = dbg2 "forecastendDefault" $ fromMaybe (addDays 180 today) mspecifiedend
|
let
|
||||||
|
forecastendDefault = dbg2 "forecastendDefault" $ fromMaybe (addDays 180 today) mspecifiedend
|
||||||
|
|
||||||
let forecastspan = dbg2 "forecastspan" $
|
forecastspan = dbg2 "forecastspan" $
|
||||||
spanDefaultsFrom
|
spanDefaultsFrom
|
||||||
(fromMaybe nulldatespan $ dbg2 "forecastspan flag" $ forecast_ ropts)
|
(fromMaybe nulldatespan $ dbg2 "forecastspan flag" $ forecast_ ropts)
|
||||||
(DateSpan (Just forecastbeginDefault) (Just forecastendDefault))
|
(DateSpan (Just forecastbeginDefault) (Just forecastendDefault))
|
||||||
@ -142,15 +144,15 @@ journalAddForecast CliOpts{inputopts_=iopts, reportopts_=ropts} j = do
|
|||||||
(if auto_ iopts then either error' id . modifyTransactions today (jtxnmodifiers j) else id) -- PARTIAL:
|
(if auto_ iopts then either error' id . modifyTransactions today (jtxnmodifiers j) else id) -- PARTIAL:
|
||||||
forecasttxns
|
forecasttxns
|
||||||
|
|
||||||
return $
|
journalBalanceTransactions' iopts j =
|
||||||
case forecast_ ropts of
|
either error' id $ journalBalanceTransactions assrt j -- PARTIAL:
|
||||||
|
where assrt = not . ignore_assertions_ $ iopts
|
||||||
|
|
||||||
|
let j' = case forecast_ ropts of
|
||||||
Just _ -> journalBalanceTransactions' iopts j{ jtxns = concat [jtxns j, forecasttxns'] }
|
Just _ -> journalBalanceTransactions' iopts j{ jtxns = concat [jtxns j, forecasttxns'] }
|
||||||
Nothing -> j
|
Nothing -> j
|
||||||
where
|
|
||||||
journalBalanceTransactions' iopts j =
|
return j'
|
||||||
let assrt = not . ignore_assertions_ $ iopts
|
|
||||||
in
|
|
||||||
either error' id $ journalBalanceTransactions assrt j -- PARTIAL:
|
|
||||||
|
|
||||||
-- | Write some output to stdout or to a file selected by --output-file.
|
-- | Write some output to stdout or to a file selected by --output-file.
|
||||||
-- If the file exists it will be overwritten.
|
-- If the file exists it will be overwritten.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user