ui: register: be inclusive for a depth-clipped account, matching displayed balance
And drop F key from register screen again.
This commit is contained in:
		
							parent
							
								
									b540b4336e
								
							
						
					
					
						commit
						ffb40870ce
					
				| @ -297,7 +297,10 @@ asHandle ui0@UIState{ | ||||
|         EvKey k           [] | k `elem` [KLeft, KChar 'h']     -> continue $ popScreen ui | ||||
|         EvKey k           [] | k `elem` [KRight, KChar 'l', KEnter] -> scrollTopRegister >> continue (screenEnter d scr ui) | ||||
|           where | ||||
|             scr = rsSetAccount selacct registerScreen | ||||
|             scr = rsSetAccount selacct isdepthclipped registerScreen | ||||
|             isdepthclipped = case getDepth ui of | ||||
|                                 Just d  -> accountNameLevel selacct >= d | ||||
|                                 Nothing -> False | ||||
| 
 | ||||
|         -- fall through to the list's event handler (handles up/down) | ||||
|         ev -> do | ||||
|  | ||||
| @ -101,7 +101,7 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} j = do | ||||
|       -- with --register, start on the register screen, and also put | ||||
|       -- the accounts screen on the prev screens stack so you can exit | ||||
|       -- to that as usual. | ||||
|       Just apat -> (rsSetAccount acct registerScreen, [ascr']) | ||||
|       Just apat -> (rsSetAccount acct False registerScreen, [ascr']) | ||||
|         where | ||||
|           acct = headDef | ||||
|                  (error' $ "--register "++apat++" did not match any account") | ||||
|  | ||||
| @ -44,23 +44,28 @@ registerScreen = RegisterScreen{ | ||||
|   ,sHandle = rsHandle | ||||
|   ,rsList    = list RegisterList V.empty 1 | ||||
|   ,rsAccount = "" | ||||
|   ,rsForceInclusive = False | ||||
|   } | ||||
| 
 | ||||
| rsSetAccount a scr@RegisterScreen{} = scr{rsAccount=replaceHiddenAccountsNameWith "*" a} | ||||
| rsSetAccount _ scr = scr | ||||
| rsSetAccount :: AccountName -> Bool -> Screen -> Screen | ||||
| rsSetAccount a forceinclusive scr@RegisterScreen{} = | ||||
|   scr{rsAccount=replaceHiddenAccountsNameWith "*" a, rsForceInclusive=forceinclusive} | ||||
| rsSetAccount _ _ scr = scr | ||||
| 
 | ||||
| rsInit :: Day -> Bool -> UIState -> UIState | ||||
| rsInit d reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}, ajournal=j, aScreen=s@RegisterScreen{..}} = | ||||
|   ui{aScreen=s{rsList=newitems'}} | ||||
|   where | ||||
|     -- gather arguments and queries | ||||
|     -- XXX temp | ||||
|     inclusive = not (flat_ ropts) || rsForceInclusive | ||||
|     thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) rsAccount | ||||
|     ropts' = ropts{ | ||||
|                depth_=Nothing | ||||
|               ,balancetype_=HistoricalBalance | ||||
|               } | ||||
|     -- XXX temp | ||||
|     thisacctq = Acct $ (if flat_ ropts then accountNameToAccountOnlyRegex else accountNameToAccountRegex) rsAccount | ||||
|     q = filterQuery (not . queryIsDepth) $ queryFromOpts d ropts' | ||||
|     q = queryFromOpts d ropts' | ||||
| --    reportq = filterQuery (not . queryIsDepth) q | ||||
| 
 | ||||
|     (_label,items) = accountTransactionsReport ropts' j q thisacctq | ||||
|     items' = (if empty_ ropts' then id else filter (not . isZeroMixedAmount . fifth6)) $  -- without --empty, exclude no-change txns | ||||
| @ -108,9 +113,10 @@ rsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | ||||
|     -- Minibuffer e -> [minibuffer e, maincontent] | ||||
|     _          -> [maincontent] | ||||
|   where | ||||
|     inclusive = not (flat_ ropts) || rsForceInclusive | ||||
|     toplabel = | ||||
|           withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount) | ||||
|       <+> withAttr (borderAttr <> "query") (str $ if flat_ ropts then " (exclusive)" else "") | ||||
|       <+> withAttr (borderAttr <> "query") (str $ if inclusive then "" else " (exclusive)") | ||||
|       <+> togglefilters | ||||
|       <+> str " transactions" | ||||
|       <+> borderQueryStr (query_ ropts) | ||||
|  | ||||
| @ -123,6 +123,9 @@ setDepth mdepth ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_ | ||||
|                        | d >= maxDepth ui -> Nothing | ||||
|                        | otherwise        -> mdepth | ||||
| 
 | ||||
| getDepth :: UIState -> Maybe Int | ||||
| getDepth UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}} = depth_ ropts | ||||
| 
 | ||||
| -- | Open the minibuffer, setting its content to the current query with the cursor at the end. | ||||
| showMinibuffer :: UIState -> UIState | ||||
| showMinibuffer ui = setMode (Minibuffer e) ui | ||||
|  | ||||
| @ -105,8 +105,11 @@ data Screen = | ||||
|       ,sDraw   :: UIState -> [Widget Name] | ||||
|       ,sHandle :: UIState -> Event -> EventM Name (Next UIState) | ||||
|       -- | ||||
|       ,rsList    :: List Name RegisterScreenItem           -- ^ list widget showing transactions affecting this account | ||||
|       ,rsList    :: List Name RegisterScreenItem      -- ^ list widget showing transactions affecting this account | ||||
|       ,rsAccount :: AccountName                       -- ^ the account this register is for | ||||
|       ,rsForceInclusive :: Bool                       -- ^ should this register always include subaccount transactions, | ||||
|                                                       --   even when in flat mode ? (ie because entered from a | ||||
|                                                       --   depth-clipped accounts screen item) | ||||
|     } | ||||
|   | TransactionScreen { | ||||
|        sInit   :: Day -> Bool -> UIState -> UIState | ||||
|  | ||||
| @ -124,7 +124,7 @@ Additional screen-specific keys are described below. | ||||
| 
 | ||||
| This is normally the first screen displayed. | ||||
| It lists accounts and their balances, like hledger's balance command. | ||||
| By default, it shows all accounts and their latest ending balances. | ||||
| By default, it shows all accounts and their latest ending balances (including the balances of subaccounts). | ||||
| if you specify a query on the command line, it shows just the matched accounts and the balances from matched transactions. | ||||
| 
 | ||||
| Account names are normally indented to show the hierarchy (tree mode). | ||||
| @ -133,8 +133,9 @@ To see less detail, set a depth limit by pressing a number key, `1` to `9`. | ||||
| `-` and `+` (or `=`) decrease and increase the depth limit. | ||||
| To remove the depth limit, set it higher than the maximum account depth, or press `ESCAPE`. | ||||
| 
 | ||||
| `F` toggles flat mode on and off. In flat mode, accounts are listed without indentation | ||||
| (and account registers will exclude subaccounts, see below). | ||||
| `F` toggles flat mode on and off. In flat mode, accounts are listed without indentation, | ||||
| and show their subaccount-excluding balances, except for accounts which have been clipped  | ||||
| by a depth limit, which show their inclusive balances (as with hledger's balance command).  | ||||
| 
 | ||||
| `C` toggles cleared mode, in which | ||||
| [uncleared transactions and postings](/journal.html#transactions) are | ||||
| @ -179,11 +180,14 @@ Each line represents one transaction and shows: | ||||
|     $ hledger-ui --register checking --cleared | ||||
|     ``` | ||||
| 
 | ||||
| Normally the register screen shows transactions in the current account and any of its subaccounts | ||||
| (inclusive mode). If it was entered from accounts screen in flat mode,  | ||||
| it shows transactions affecting this account specifically, without  | ||||
| considering subaccounts (exclusive mode). | ||||
| As on the accounts screen you can toggle this with the `F` key. | ||||
| The register screen normally shows transactions in the current account  | ||||
| and any of its subaccounts (inclusive mode).  | ||||
| If it was entered from the accounts screen in flat mode, where the  | ||||
| selected account was not depth-clipped and therefore was showing its  | ||||
| subaccount-excluding balance, the register too will omit the transactions  | ||||
| of subaccounts (exclusive mode). This means the register always shows | ||||
| the transactions responsible for the balance being displayed on the  | ||||
| accounts screen. | ||||
| 
 | ||||
| `C` toggles cleared mode, in which | ||||
| [uncleared transactions and postings](/journal.html#transactions) are | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user