;lib: refactor
This commit is contained in:
parent
2761324404
commit
291a35d8b4
@ -116,7 +116,10 @@ anonymiseByOpts opts =
|
|||||||
-- a somewhat complicated way; see the hledger manual -> Periodic transactions.
|
-- a somewhat complicated way; see the hledger manual -> Periodic transactions.
|
||||||
--
|
--
|
||||||
journalAddForecast :: CliOpts -> Journal -> IO Journal
|
journalAddForecast :: CliOpts -> Journal -> IO Journal
|
||||||
journalAddForecast CliOpts{inputopts_=iopts, reportopts_=ropts} j = do
|
journalAddForecast CliOpts{inputopts_=iopts, reportopts_=ropts} j =
|
||||||
|
case forecast_ ropts of
|
||||||
|
Nothing -> return j
|
||||||
|
Just _ -> 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)."
|
||||||
@ -144,19 +147,14 @@ 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
|
||||||
|
|
||||||
journalBalanceTransactions' iopts j =
|
j' = either error' id $ journalBalanceTransactions (not . ignore_assertions_ $ iopts) -- PARTIAL:
|
||||||
either error' id $ journalBalanceTransactions assrt j -- PARTIAL:
|
j{jtxns=concat [jtxns j, forecasttxns']}
|
||||||
where assrt = not . ignore_assertions_ $ iopts
|
|
||||||
|
|
||||||
case forecast_ ropts of
|
|
||||||
Nothing -> return j
|
|
||||||
Just _ -> do
|
|
||||||
let j' = journalBalanceTransactions' iopts j{ jtxns = concat [jtxns j, forecasttxns'] }
|
|
||||||
-- Display styles were applied early.. apply them again to ensure the forecasted
|
-- Display styles were applied early.. apply them again to ensure the forecasted
|
||||||
-- transactions are also styled. XXX Possible optimisation: style just the forecasttxns.
|
-- transactions are also styled. XXX Possible optimisation: style just the forecasttxns.
|
||||||
case journalApplyCommodityStyles j' of
|
j'' = either error' id $ journalApplyCommodityStyles j' -- PARTIAL:
|
||||||
Left e -> error' e -- PARTIAL:
|
|
||||||
Right j'' -> return j''
|
return j''
|
||||||
|
|
||||||
-- | 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