;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. | ||||
| -- | ||||
| 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 | ||||
| 
 | ||||
|       -- "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: | ||||
|           forecasttxns | ||||
| 
 | ||||
|     journalBalanceTransactions' iopts j =  | ||||
|       either error' id $ journalBalanceTransactions assrt j  -- PARTIAL: | ||||
|         where assrt = not . ignore_assertions_ $ iopts | ||||
|         j' = either error' id $ journalBalanceTransactions (not . ignore_assertions_ $ iopts)  -- PARTIAL: | ||||
|           j{jtxns=concat [jtxns j, forecasttxns']} | ||||
| 
 | ||||
|   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 | ||||
|         -- transactions are also styled. XXX Possible optimisation: style just the forecasttxns. | ||||
|       case journalApplyCommodityStyles j' of | ||||
|         Left e    -> error' e  -- PARTIAL: | ||||
|         Right j'' -> return j'' | ||||
|         j'' = either error' id $ journalApplyCommodityStyles j'  -- PARTIAL: | ||||
| 
 | ||||
|       return j'' | ||||
| 
 | ||||
| -- | Write some output to stdout or to a file selected by --output-file. | ||||
| -- If the file exists it will be overwritten. | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user