imp: ui: transaction: refactor
This commit is contained in:
		
							parent
							
								
									f5cfcf827d
								
							
						
					
					
						commit
						956ee06591
					
				| @ -72,25 +72,26 @@ tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec | |||||||
|     Help       -> [helpDialog copts, maincontent] |     Help       -> [helpDialog copts, maincontent] | ||||||
|     -- Minibuffer e -> [minibuffer e, maincontent] |     -- Minibuffer e -> [minibuffer e, maincontent] | ||||||
|     _          -> [maincontent] |     _          -> [maincontent] | ||||||
|  |   where | ||||||
|  |     maincontent = Widget Greedy Greedy $ render $ defaultLayout toplabel bottomlabel txn | ||||||
|       where |       where | ||||||
|         -- as with print, show amounts with all of their decimal places |         -- as with print, show amounts with all of their decimal places | ||||||
|         t = transactionMapPostingAmounts mixedAmountSetFullPrecision t' |         t = transactionMapPostingAmounts mixedAmountSetFullPrecision t' | ||||||
|     maincontent = Widget Greedy Greedy $ do | 
 | ||||||
|       let |         txn = str | ||||||
|  |           $ T.unpack . showTransactionOneLineAmounts | ||||||
|  |           $ maybe id (transactionApplyValuation prices styles periodlast (_rsDay rspec)) (value_ ropts) | ||||||
|  |           $ case cost_ ropts of | ||||||
|  |                 Cost   -> transactionToCost styles t | ||||||
|  |                 NoCost -> t | ||||||
|  |           -- (if real_ ropts then filterTransactionPostings (Real True) else id) -- filter postings by --real | ||||||
|  |           where | ||||||
|             prices = journalPriceOracle (infer_prices_ ropts) j |             prices = journalPriceOracle (infer_prices_ ropts) j | ||||||
|             styles = journalCommodityStyles j |             styles = journalCommodityStyles j | ||||||
|             periodlast = |             periodlast = | ||||||
|               fromMaybe (error' "TransactionScreen: expected a non-empty journal") $  -- PARTIAL: shouldn't happen |               fromMaybe (error' "TransactionScreen: expected a non-empty journal") $  -- PARTIAL: shouldn't happen | ||||||
|               reportPeriodOrJournalLastDay rspec j |               reportPeriodOrJournalLastDay rspec j | ||||||
| 
 | 
 | ||||||
|       render . defaultLayout toplabel bottomlabel . str |  | ||||||
|         . T.unpack . showTransactionOneLineAmounts |  | ||||||
|         . maybe id (transactionApplyValuation prices styles periodlast (_rsDay rspec)) (value_ ropts) |  | ||||||
|         $ case cost_ ropts of |  | ||||||
|                Cost   -> transactionToCost styles t |  | ||||||
|                NoCost -> t |  | ||||||
|         -- (if real_ ropts then filterTransactionPostings (Real True) else id) -- filter postings by --real |  | ||||||
|       where |  | ||||||
|         toplabel = |         toplabel = | ||||||
|           str "Transaction " |           str "Transaction " | ||||||
|           -- <+> withAttr ("border" <> "bold") (str $ "#" ++ show (tindex t)) |           -- <+> withAttr ("border" <> "bold") (str $ "#" ++ show (tindex t)) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user