fix:ui: V key preserves startup valuation, if any (fix #2084)
Also: hledger-ui cost/value doc improvement and a useful cost/value test file.
This commit is contained in:
parent
936e1b9d0a
commit
7582460e50
@ -58,7 +58,7 @@ import Safe
|
|||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
import Hledger.UI.UITypes
|
import Hledger.UI.UITypes
|
||||||
import Hledger.UI.UIOptions (UIOpts)
|
import Hledger.UI.UIOptions (UIOpts(uoCliOpts))
|
||||||
import Hledger.UI.UIScreens (screenUpdate)
|
import Hledger.UI.UIScreens (screenUpdate)
|
||||||
|
|
||||||
-- | Make an initial UI state with the given options, journal,
|
-- | Make an initial UI state with the given options, journal,
|
||||||
@ -155,13 +155,17 @@ toggleConversionOp = over conversionop toggleCostMode
|
|||||||
toggleCostMode (Just NoConversionOp) = Just ToCost
|
toggleCostMode (Just NoConversionOp) = Just ToCost
|
||||||
toggleCostMode (Just ToCost) = Just NoConversionOp
|
toggleCostMode (Just ToCost) = Just NoConversionOp
|
||||||
|
|
||||||
-- | Toggle between showing primary amounts or default valuation.
|
-- | Toggle between showing primary amounts or values (using valuation specified at startup, or a default).
|
||||||
toggleValue :: UIState -> UIState
|
toggleValue :: UIState -> UIState
|
||||||
toggleValue = over value valuationToggleValue
|
toggleValue ui = over value (valuationToggleValue mstartupvaluation0) ui
|
||||||
where
|
where
|
||||||
-- | Basic toggling of -V, for hledger-ui.
|
mstartupvaluation0 = value_ $ _rsReportOpts $ reportspec_ $ uoCliOpts $ astartupopts ui
|
||||||
valuationToggleValue (Just (AtEnd _)) = Nothing
|
mdefvaluation = Just (AtEnd Nothing)
|
||||||
valuationToggleValue _ = Just $ AtEnd Nothing
|
-- valuationToggleValue (maybe startupvaluation) (maybe currentvaluation) = ...
|
||||||
|
valuationToggleValue Nothing Nothing = mdefvaluation
|
||||||
|
valuationToggleValue Nothing (Just _) = Nothing
|
||||||
|
valuationToggleValue mstartupvaluation Nothing = mstartupvaluation
|
||||||
|
valuationToggleValue _ (Just _) = Nothing
|
||||||
|
|
||||||
-- | Set hierarchic account tree mode.
|
-- | Set hierarchic account tree mode.
|
||||||
setTree :: UIState -> UIState
|
setTree :: UIState -> UIState
|
||||||
|
|||||||
@ -190,23 +190,23 @@ With some editors (emacs, vi), the cursor will be positioned at the current tran
|
|||||||
when invoked from the register and transaction screens, and at the error location (if possible)
|
when invoked from the register and transaction screens, and at the error location (if possible)
|
||||||
when invoked from the error screen.
|
when invoked from the error screen.
|
||||||
|
|
||||||
`B` toggles cost mode, showing amounts in their cost's commodity
|
`B` toggles cost mode, showing amounts converted to their cost's commodity
|
||||||
(like toggling the [`-B/--cost`](https://hledger.org/hledger.html#b-cost) flag).
|
(see [hledger manual > Cost reporting](hledger.md#cost-reporting).
|
||||||
|
|
||||||
`V` toggles value mode, showing amounts' current market value in their
|
`V` toggles value mode, showing amounts converted to their market value
|
||||||
default valuation commodity (like toggling the
|
(see [hledger manual > Valuation](hledger.md#valuation) flag).
|
||||||
[`-V/--market`](https://hledger.org/hledger.html#v-market-value) flag).
|
More specifically,
|
||||||
Note, "current market value" means the value on the report end date if specified, otherwise today.
|
|
||||||
To see the value on another date, you can temporarily set that as the report end date.
|
|
||||||
Eg: to see a transaction as it was valued on july 30,
|
|
||||||
go to the accounts or register screen,
|
|
||||||
press `/`,
|
|
||||||
and add ` date:-7/30` to the query.
|
|
||||||
|
|
||||||
At most one of cost or value mode can be active at once.
|
1. By default, the `V` key toggles showing end value (`--value=end`) on or off.
|
||||||
|
The valuation date will be the report end date if specified, otherwise today.
|
||||||
|
|
||||||
There's not yet any visual reminder when cost or value mode is active;
|
2. If you started hledger-ui with some other valuation (such as `--value=then,EUR`),
|
||||||
for now pressing `b` `b` `v` should reliably reset to normal mode.
|
the `V` key toggles that off or on.
|
||||||
|
|
||||||
|
Cost/value tips:
|
||||||
|
- When showing end value, you can change the report end date without restarting, by pressing `/` and adding a query like ` date:..YYYY-MM-DD`.
|
||||||
|
- Either cost mode, or value mode, can be active, but not both at once. Cost mode takes precedence.
|
||||||
|
- There's not yet any visual indicator that cost or value mode is active, other than the amount values.
|
||||||
|
|
||||||
`q` quits the application.
|
`q` quits the application.
|
||||||
|
|
||||||
|
|||||||
20
hledger-ui/test/value.journal
Normal file
20
hledger-ui/test/value.journal
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
P 2023-01-01 NORMAL VALUE 1
|
||||||
|
P 2023-01-02 NORMAL VALUE 10
|
||||||
|
P 2023-01-03 NORMAL VALUE 100
|
||||||
|
P 2023-01-04 NORMAL VALUE 1000
|
||||||
|
P 2023-09-01 NORMAL VALUE 10000
|
||||||
|
P 9999-01-01 NORMAL VALUE 100000
|
||||||
|
|
||||||
|
2023-01-01
|
||||||
|
(a) NORMAL 1 @ COST 2
|
||||||
|
|
||||||
|
2023-01-02
|
||||||
|
(a) NORMAL 1 @ COST 2
|
||||||
|
|
||||||
|
2023-01-03
|
||||||
|
(a) NORMAL 1 @ COST 2
|
||||||
|
|
||||||
|
2023-01-04
|
||||||
|
(a) NORMAL 1 @ COST 2
|
||||||
|
|
||||||
|
# hledger-ui --register a
|
||||||
Loading…
Reference in New Issue
Block a user