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` [KLeft, KChar 'h']     -> continue $ popScreen ui | ||||||
|         EvKey k           [] | k `elem` [KRight, KChar 'l', KEnter] -> scrollTopRegister >> continue (screenEnter d scr ui) |         EvKey k           [] | k `elem` [KRight, KChar 'l', KEnter] -> scrollTopRegister >> continue (screenEnter d scr ui) | ||||||
|           where |           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) |         -- fall through to the list's event handler (handles up/down) | ||||||
|         ev -> do |         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 |       -- with --register, start on the register screen, and also put | ||||||
|       -- the accounts screen on the prev screens stack so you can exit |       -- the accounts screen on the prev screens stack so you can exit | ||||||
|       -- to that as usual. |       -- to that as usual. | ||||||
|       Just apat -> (rsSetAccount acct registerScreen, [ascr']) |       Just apat -> (rsSetAccount acct False registerScreen, [ascr']) | ||||||
|         where |         where | ||||||
|           acct = headDef |           acct = headDef | ||||||
|                  (error' $ "--register "++apat++" did not match any account") |                  (error' $ "--register "++apat++" did not match any account") | ||||||
|  | |||||||
| @ -44,23 +44,28 @@ registerScreen = RegisterScreen{ | |||||||
|   ,sHandle = rsHandle |   ,sHandle = rsHandle | ||||||
|   ,rsList    = list RegisterList V.empty 1 |   ,rsList    = list RegisterList V.empty 1 | ||||||
|   ,rsAccount = "" |   ,rsAccount = "" | ||||||
|  |   ,rsForceInclusive = False | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| rsSetAccount a scr@RegisterScreen{} = scr{rsAccount=replaceHiddenAccountsNameWith "*" a} | rsSetAccount :: AccountName -> Bool -> Screen -> Screen | ||||||
| rsSetAccount _ scr = scr | rsSetAccount a forceinclusive scr@RegisterScreen{} = | ||||||
|  |   scr{rsAccount=replaceHiddenAccountsNameWith "*" a, rsForceInclusive=forceinclusive} | ||||||
|  | rsSetAccount _ _ scr = scr | ||||||
| 
 | 
 | ||||||
| rsInit :: Day -> Bool -> UIState -> UIState | rsInit :: Day -> Bool -> UIState -> UIState | ||||||
| rsInit d reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}, ajournal=j, aScreen=s@RegisterScreen{..}} = | rsInit d reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}, ajournal=j, aScreen=s@RegisterScreen{..}} = | ||||||
|   ui{aScreen=s{rsList=newitems'}} |   ui{aScreen=s{rsList=newitems'}} | ||||||
|   where |   where | ||||||
|     -- gather arguments and queries |     -- gather arguments and queries | ||||||
|  |     -- XXX temp | ||||||
|  |     inclusive = not (flat_ ropts) || rsForceInclusive | ||||||
|  |     thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) rsAccount | ||||||
|     ropts' = ropts{ |     ropts' = ropts{ | ||||||
|                depth_=Nothing |                depth_=Nothing | ||||||
|               ,balancetype_=HistoricalBalance |               ,balancetype_=HistoricalBalance | ||||||
|               } |               } | ||||||
|     -- XXX temp |     q = queryFromOpts d ropts' | ||||||
|     thisacctq = Acct $ (if flat_ ropts then accountNameToAccountOnlyRegex else accountNameToAccountRegex) rsAccount | --    reportq = filterQuery (not . queryIsDepth) q | ||||||
|     q = filterQuery (not . queryIsDepth) $ queryFromOpts d ropts' |  | ||||||
| 
 | 
 | ||||||
|     (_label,items) = accountTransactionsReport ropts' j q thisacctq |     (_label,items) = accountTransactionsReport ropts' j q thisacctq | ||||||
|     items' = (if empty_ ropts' then id else filter (not . isZeroMixedAmount . fifth6)) $  -- without --empty, exclude no-change txns |     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] |     -- Minibuffer e -> [minibuffer e, maincontent] | ||||||
|     _          -> [maincontent] |     _          -> [maincontent] | ||||||
|   where |   where | ||||||
|  |     inclusive = not (flat_ ropts) || rsForceInclusive | ||||||
|     toplabel = |     toplabel = | ||||||
|           withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount) |           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 |       <+> togglefilters | ||||||
|       <+> str " transactions" |       <+> str " transactions" | ||||||
|       <+> borderQueryStr (query_ ropts) |       <+> borderQueryStr (query_ ropts) | ||||||
|  | |||||||
| @ -123,6 +123,9 @@ setDepth mdepth ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_ | |||||||
|                        | d >= maxDepth ui -> Nothing |                        | d >= maxDepth ui -> Nothing | ||||||
|                        | otherwise        -> mdepth |                        | 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. | -- | Open the minibuffer, setting its content to the current query with the cursor at the end. | ||||||
| showMinibuffer :: UIState -> UIState | showMinibuffer :: UIState -> UIState | ||||||
| showMinibuffer ui = setMode (Minibuffer e) ui | showMinibuffer ui = setMode (Minibuffer e) ui | ||||||
|  | |||||||
| @ -105,8 +105,11 @@ data Screen = | |||||||
|       ,sDraw   :: UIState -> [Widget Name] |       ,sDraw   :: UIState -> [Widget Name] | ||||||
|       ,sHandle :: UIState -> Event -> EventM Name (Next UIState) |       ,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 |       ,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 { |   | TransactionScreen { | ||||||
|        sInit   :: Day -> Bool -> UIState -> UIState |        sInit   :: Day -> Bool -> UIState -> UIState | ||||||
|  | |||||||
| @ -124,7 +124,7 @@ Additional screen-specific keys are described below. | |||||||
| 
 | 
 | ||||||
| This is normally the first screen displayed. | This is normally the first screen displayed. | ||||||
| It lists accounts and their balances, like hledger's balance command. | 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. | 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). | 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. | `-` and `+` (or `=`) decrease and increase the depth limit. | ||||||
| To remove the depth limit, set it higher than the maximum account depth, or press `ESCAPE`. | 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 | `F` toggles flat mode on and off. In flat mode, accounts are listed without indentation, | ||||||
| (and account registers will exclude subaccounts, see below). | 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 | `C` toggles cleared mode, in which | ||||||
| [uncleared transactions and postings](/journal.html#transactions) are | [uncleared transactions and postings](/journal.html#transactions) are | ||||||
| @ -179,11 +180,14 @@ Each line represents one transaction and shows: | |||||||
|     $ hledger-ui --register checking --cleared |     $ hledger-ui --register checking --cleared | ||||||
|     ``` |     ``` | ||||||
| 
 | 
 | ||||||
| Normally the register screen shows transactions in the current account and any of its subaccounts | The register screen normally shows transactions in the current account  | ||||||
| (inclusive mode). If it was entered from accounts screen in flat mode,  | and any of its subaccounts (inclusive mode).  | ||||||
| it shows transactions affecting this account specifically, without  | If it was entered from the accounts screen in flat mode, where the  | ||||||
| considering subaccounts (exclusive mode). | selected account was not depth-clipped and therefore was showing its  | ||||||
| As on the accounts screen you can toggle this with the `F` key. | 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 | `C` toggles cleared mode, in which | ||||||
| [uncleared transactions and postings](/journal.html#transactions) are | [uncleared transactions and postings](/journal.html#transactions) are | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user