From 4a35945a8f8e20f1309d5acf1eeda1cb4307af2b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 4 Nov 2022 22:19:52 -1000 Subject: [PATCH] imp: ui: start on balance sheet accounts screen --- hledger-ui/Hledger/UI/Main.hs | 6 ++-- hledger-ui/Hledger/UI/UIScreens.hs | 1 + hledger-ui/hledger-ui.m4.md | 55 +++++++++++++++--------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 04bbcc029..f1460c12e 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -136,8 +136,8 @@ runBrickUi uopts0@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=r -- menu > accounts by default, or menu > accounts > register with --register. -- Remember the parent screens are ordered nearest/lowest first. (prevscrs, startscr) = case uoRegister uopts of - Nothing -> ([menuscr], acctsscr) - Just apat -> ([asSetSelectedAccount acct acctsscr, menuscr], regscr) + Nothing -> ([menuscr], bsacctsscr) + Just apat -> ([asSetSelectedAccount acct bsacctsscr, menuscr], regscr) where regscr = rsSetAccount acct False $ @@ -154,7 +154,7 @@ runBrickUi uopts0@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=r Left _ -> const Nothing where menuscr = msNew - acctsscr = asNew uopts today j Nothing + bsacctsscr = bsNew uopts today j Nothing ui = uiState uopts j prevscrs startscr app = brickApp (uoTheme uopts) diff --git a/hledger-ui/Hledger/UI/UIScreens.hs b/hledger-ui/Hledger/UI/UIScreens.hs index 0b0ed6f93..05f6abbf4 100644 --- a/hledger-ui/Hledger/UI/UIScreens.hs +++ b/hledger-ui/Hledger/UI/UIScreens.hs @@ -84,6 +84,7 @@ msNew = ,MenuScreenItem "Balance sheet accounts (assets, liabilities, equity)" Balancesheet ,MenuScreenItem "Income statement accounts (revenues, expenses)" Incomestatement ]) 1 + & listMoveTo 1 -- select balance sheet accounts screen at startup (currently this screen is constructed only then) ,_mssUnused = () } diff --git a/hledger-ui/hledger-ui.m4.md b/hledger-ui/hledger-ui.m4.md index b559f9d15..97bbbf25b 100644 --- a/hledger-ui/hledger-ui.m4.md +++ b/hledger-ui/hledger-ui.m4.md @@ -191,16 +191,35 @@ Additional screen-specific keys are described below. ## Menu screen -The top-most screen, currently with just one menu item and not shown by default. +The top-most screen. hledger-ui does not show this screen at startup, +but you can press LEFT to navigate to it. +From here you can navigate to three accounts screens: -## Accounts screen +## All accounts screen -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 (including the balances of subaccounts). -Accounts which have been declared with an [account directive](#declaring-accounts) are also listed, even if not yet used +This screen shows all accounts (unless filtered by a query), and their current balances. +It is like the `hledger balance` command. + +## Balance sheet accounts screen + +This is the screen normally shown at startup. +It shows asset, liability and equity accounts, if these can be detected (see [account types](/hledger.html#account-types)). +It always shows historical end balances on some date (not balance changes). +It is like the `hledger balancesheetequity` command. + +## Income statement accounts screen + +This screen shows revenue and expense accounts. +It always shows balance changes in some period (not end balances). +It is like the `hledger incomestatement` command. + +All of these accounts screens work in much the same way: + +They show accounts which have been posted to by transactions, +as well as accounts which have been declared with an [account directive](#declaring-accounts) (except for empty parent accounts). -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 shown as a flat list by default; press `t` to toggle tree mode. In list mode, account balances are exclusive of subaccounts, except where subaccounts are hidden by a depth limit (see below). @@ -211,7 +230,7 @@ Or use `-` to decrease and `+`/`=` to increase the depth limit. `0` shows even less detail, collapsing all accounts to a single total. To remove the depth limit, set it higher than the maximum account depth, or press `ESCAPE`. -`H` toggles between showing historical balances or period balances. +`H` toggles between showing historical balances or period balances (on the "All accounts" screen). Historical balances (the default) are ending balances at the end of the report period, taking into account all transactions before that date (filtered by the filter query if any), including transactions before the start of the report period. In other words, historical @@ -233,7 +252,7 @@ and if you activate all three, the filter is removed.) are shown (hledger-ui shows zero items by default, unlike command-line hledger). -Press `RIGHT` to view an account's transactions register. +Press `RIGHT` to view an account's register screen, Or, `LEFT` to see the menu screen. ## Register screen @@ -294,24 +313,6 @@ preceding them is the transaction's position within the complete unfiltered journal, which is a more stable id (at least until the next reload). -## Balance sheet accounts screen - -This is like the accounts screen except: - -- it shows only asset, liability and equity accounts (see [account types](/hledger.html#account-types)) -- it always shows historical end balances on some date (not balance changes). - -It corresponds to the `hledger balancesheet` command. - -## Income statement accounts screen - -Like the accounts screen except: - -- it shows only revenue and expense accounts -- it always shows balance changes in some period (not end balances). - -It corresponds to the `hledger incomestatement` command. - ## Error screen This screen will appear if there is a problem, such as a parse error,