Commit Graph

373 Commits

Author SHA1 Message Date
Stephen Morgan
55f42c3d1e ui: Do not reset cost and value flags on reload. 2021-07-02 10:07:03 +10:00
Stephen Morgan
307bd9366d ui: In TransactionScreen, set the current transaction and index in
tsInit based on the previous RegisterScreen. Use the RegisterScreen
logic for selecting the new transaction when we cannot find the existing
one.

This enables us to get rid of regenerateTransactions. There is now
different behaviour in the transaction screen when the journal is
reloaded and the transaction being viewed is no longer available, but I
have not been able to find an example which exhibits this different
behaviour. I think it is better to have consistent behaviour between the
register screen and transaction screen when determining which to select.

This corrects a bug where you had to reload twice to reset the valuation
and cost flags, due to the elimination of regenerateTransactions.
2021-07-02 10:07:03 +10:00
Stephen Morgan
613efba1bc ui: Do not log to debug.log when regenerating journal in Transaction
screen (#1556). Also really clear cost setting when doing so.

Since plog is no longer used anywhere, and tends to create bugs when it
is, we remove it.
2021-06-30 16:07:32 -10:00
crocket
5725fb8ab7 Improve editor support
Documentation for editFileAtPositionCommand is made more
precise.

This commit makes it possible for hledger-ui to open
a file at the last line on emacs and kakoune.

It also prevents hledger-ui from opening an editor with
imprecise arguments. Passing imprecise arguments to editors
can cause undefined behaviors in editors.

I tested it with emacs(client), nano, vscode, kakoune,
nvim, and vis.
2021-06-16 14:11:36 -10:00
Simon Michael
6df8b6d46e ;ui: editFileAtPositionCommand doc tweaks (#1572) 2021-06-15 17:37:00 -10:00
crocket
aa0a8d079b Add support for kakoune editor 2021-06-15 17:24:35 -10:00
Simon Michael
665fec83cd
Merge pull request #1560 from Xitian9/rationalisevaluation
Clean up valuation functions, and make clear which to use where.
2021-06-07 19:02:44 -10:00
Stephen Morgan
0f1837816d lib,cli,ui,web: Add check balancednoautoconversion command, which checks that
transactions are balanced possibly using explicit prices, but without
inferring any prices. This is included in --strict mode.

Renames check autobalanced to check balancedwithautoconversion.
2021-06-07 18:58:58 -10:00
Stephen Morgan
68e975adf1 lib,cli,ui,web: Remove unused LANGUAGE pragmas. 2021-06-07 17:33:54 -10:00
Stephen Morgan
c87290e5f5 ui: Remove unnecessary CPP when dropping support for GHC 8.4. 2021-06-07 17:33:54 -10:00
Stephen Morgan
55308e1ca8 lib,cli,ui,web: Remove unnecessary CPP when dropping support for GHC 8.2. 2021-06-07 17:33:54 -10:00
Stephen Morgan
56e87f934c ui: Use Text instead of String in RegisterScreen. 2021-06-03 23:23:54 -10:00
Stephen Morgan
bf063e4538 cli,ui,web: Display full git description in --version report if able.
Remove unused prognameanddetailedversion code branches.
2021-06-02 19:46:18 -10:00
Simon Michael
17b241eb64 ui: don't write debug.log when toggling V (#1556) 2021-05-14 11:38:14 -10:00
Stephen Morgan
53611be6e9 lib,ui: Do all cost conversion and price stripping in journalSelectingAmountFromOpts. 2021-05-07 21:51:15 +10:00
Stephen Morgan
5e7b69356f lib: Change internal representation of MixedAmount to use a strict Map
instead of a list of Amounts. No longer export Mixed constructor, to
keep API clean (if you really need it, you can import it directly from
Hledger.Data.Types). We also ensure the JSON representation of
MixedAmount doesn't change: it is stored as a normalised list of
Amounts.

This commit improves performance. Here are some indicative results.

hledger reg -f examples/10000x1000x10.journal
- Maximum residency decreases from 65MB to 60MB (8% decrease)
- Total memory in use decreases from 178MiB to 157MiB (12% decrease)

hledger reg -f examples/10000x10000x10.journal
- Maximum residency decreases from 69MB to 60MB (13% decrease)
- Total memory in use decreases from 198MiB to 153MiB (23% decrease)

hledger bal -f examples/10000x1000x10.journal
- Total heap usage decreases from 6.4GB to 6.0GB (6% decrease)
- Total memory in use decreases from 178MiB to 153MiB (14% decrease)

hledger bal -f examples/10000x10000x10.journal
- Total heap usage decreases from 7.3GB to 6.9GB (5% decrease)
- Total memory in use decreases from 196MiB to 185MiB (5% decrease)

hledger bal -M -f examples/10000x1000x10.journal
- Total heap usage decreases from 16.8GB to 10.6GB (47% decrease)
- Total time decreases from 14.3s to 12.0s (16% decrease)

hledger bal -M -f examples/10000x10000x10.journal
- Total heap usage decreases from 108GB to 48GB (56% decrease)
- Total time decreases from 62s to 41s (33% decrease)

If you never directly use the constructor Mixed or pattern match against
it then you don't need to make any changes. If you do, then do the
following:

- If you really care about the individual Amounts and never normalise
  your MixedAmount (for example, just storing `Mixed amts` and then
  extracting `amts` as a pattern match, then use should switch to using
  [Amount]. This should just involve removing the `Mixed` constructor.
- If you ever call `mixed`, `normaliseMixedAmount`, or do any sort of
  amount arithmetic (+), (-), then you should replace the constructor
  `Mixed` with the function `mixed`. To extract the list of Amounts, use
  the function `amounts`.
- If you ever call `normaliseMixedAmountSquashPricesForDisplay`, you can
  replace that with `mixedAmountStripPrices`. (N.B. this does something
  slightly different from `normaliseMixedAmountSquashPricesForDisplay`,
  but I don't think there's any use case for squashing prices and then
  keeping the first of the squashed prices around. If you disagree let
  me know.)
- Any remaining calls to `normaliseMixedAmount` can be removed, as that
  is now the identity function.
2021-05-01 09:45:29 -10:00
Stephen Morgan
dd5773253b ui: For account screen, if the accounts and amounts are too wide, allocate space proportionally. 2021-04-14 14:18:24 -10:00
Stephen Morgan
203b12bfd9 ui: In account screen, elide amounts which go past the specified width.
Also leave at least 15 spaces width for account names.
2021-04-14 14:18:24 -10:00
Simon Michael
dbe7ef0157 ui: setFilter: note error-ignoring behaviour 2021-04-12 12:06:11 -10:00
Simon Michael
b13df845c0 ui: register: fix queries, broken in 1.21 (#1523) 2021-04-12 12:05:35 -10:00
Stephen Morgan
4609e79f2c lib,cli,ui,web: A number of AccountName and Journal functions which are
supposed to produce unique sorted use Sets internally to be slightly
more efficient. There is also a new function journalCommodities.
2021-03-23 11:26:30 -07:00
Stephen Morgan
d6a4310d8f lib,cli,ui,bin: Eliminate all uses of Mixed outside of Hledger.Data.Amount.
Exceptions are for dealing with the pamount field, which is really just
dealing with an unnormalised list of amounts.

This creates an API for dealing with MixedAmount, so we never have to
access the internals outside of Hledger.Data.Amount.

Also remove a comment, since it looks like #1207 has been resolved.
2021-03-18 09:47:59 +11:00
Simon Michael
ffb985f1a2 ui, web: make --man and --info work, similar to hledger
(cf #1410)
2021-03-03 05:57:31 -08:00
Simon Michael
d865ec5d65 lib: refactor: more consistent amount precision helpers
Hledger.Data.Amount:
renamed:
setAmountPrecision -> amountSetPrecision
setFullPrecision -> amountSetFullPrecision
setMixedAmountPrecision -> mixedAmountSetPrecision
added:
mixedAmountSetFullPrecision
2021-02-05 16:09:49 -08:00
Simon Michael
2a4170dd3b ui: transaction: show all decimal places (like print, cf #931)
On the accounts screen and register screen we round amounts according
to commodity styles, but when you drill down to a transaction you
probably want to see the unrounded amounts.
2021-02-04 08:13:55 -08:00
Stephen Morgan
c9eb7d1bcf lib,cli,ui: Separate costing from valuation; each can now be specified
independently.

You can now combine costing and valuation, for example "--cost
--value=then" will first convert to costs, and then value according to
the "--value=then" strategy. Any valuation strategy can be used with or
without costing.

If multiple valuation and costing strategies are specified on the
command line, then if any of them include costing
(-B/--cost/--value=cost) then amounts will be converted to cost, and for
valuation strategy the rightmost will be used.

--value=cost is deprecated, but still supported and is equivalent to
--cost/-B. --value=cost,COMM is no longer supported, but this behaviour can be
achieved with "--cost --value=then,COMM".
2021-01-28 13:57:48 -08:00
Stephen Morgan
130739e3ef lib,cli,ui: Introduce *ApplyCostValuation functions, which perform both
costing and valuation.

This currently is given a dummy NoCost argument and is equivalent to
"maybe id (*ApplyValuation ...)", but provides a constant interface so
that internal behaviour can be changed freely.
2021-01-28 13:57:48 -08:00
Simon Michael
507648383d ui: register: show all txns in/under an account at depth limit (#1468)
As in 1.19. This was broken since 2020-09-02 c45663d41.
2021-01-24 09:54:18 -08:00
Stephen Morgan
83110e8820 lib,cli: Extend AtThen valuation to all report types.
Also adds a postingDate argument to amountApplyValuation, and re-orders
the ValuationType and (Transaction/Posting) arguments to
(transaction/posting)ApplyValuation, to be consistent with
amountApplyValuation.
2021-01-05 14:42:09 -08:00
Stephen Morgan
7d3cf1747a lib: Make consistent naming scheme for showMixedAmount* functions,
add conversion between old API and new API in the documentation.
2021-01-02 15:08:09 +11:00
Stephen Morgan
e4e533eb9f lib,cli,ui: Replace some uses of String with Text, get rid of some unpacks, clean up showMixed options. 2021-01-02 15:08:09 +11:00
Stephen Morgan
13c111da73 lib,cli,ui: Use WideBuilder for Tabular.AsciiWide.
Move WideBuilder to Text.WideString.
2021-01-02 15:08:09 +11:00
Stephen Morgan
b9c00dce61 lib,cli,ui: Implement all showMixed* functions in terms of DisplayAmountOpts and WideBuilder. 2021-01-02 15:08:09 +11:00
Stephen Morgan
e3ec01c3c6 lib,cli,ui: Use Text for showDate and related. 2021-01-02 15:08:09 +11:00
Stephen Morgan
74b296f865 lib,cli: Make showTransaction return Text rather than String. 2021-01-02 15:08:09 +11:00
Stephen Morgan
7e44b89bb4 lib: Remove unused label on TranspactionReport and AccountTransactionsReport. 2021-01-02 15:08:09 +11:00
Stephen Morgan
5752f1c5cb lib,cli: Use Text Builder for Account Transaction Reports. 2021-01-02 15:08:09 +11:00
Simon Michael
06675bfec4 ;cli, ui: fixes for yesterday's 4330427f 2020-12-27 12:20:50 -08:00
Stephen Morgan
e406cebcce lib: Remove unused AtDefault constructor for ValuationType. 2020-12-19 11:59:44 -08:00
Stephen Morgan
46093b8de7 lib,ui: For hledger-ui, do valuation for all valuation types, not just
AtCost and AtDefault.

Remove unused valuationTypeIs* functions.
2020-12-19 11:59:44 -08:00
Stephen Morgan
cdec0f9382 lib: Remove special handling of now-inaccessible AtDefault valuation constructor.
This simplifies all the *ApplyValuation functions, as they no longer
need mreportdate or multiperiod arguments.
2020-12-19 11:59:44 -08:00
Simon Michael
8d1e3e638b ;ui: refactor, drop old option support 2020-12-12 12:13:52 -08:00
Simon Michael
349ffd7c0b updateReportSpecFromOpts -> updateReportSpec[With] 2020-12-12 12:05:44 -08:00
Simon Michael
15dc638a07 ui: preserve forecast txns (& period) when reloading journal (#1204) 2020-12-12 11:53:24 -08:00
Simon Michael
6158d16443 ;ui: refactor, simplify query 2020-12-12 11:52:15 -08:00
Simon Michael
481c40ca2f ;ui: refactor toggleForecast 2020-12-12 11:51:25 -08:00
Simon Michael
b6cb95b534 ui: make F key keep working, fixing breakage in 1.20 (#1411)
This seems to be fallout from #1340's
2020-09-16 d0d39e615 lib,cli,ui,web: Introduce ReportSpec, which holds ReportOpts, the day of the report, and the parsed Query.
2020-12-11 09:38:15 -08:00
Simon Michael
9730b69a05 ;ui: register: fix one-line amount formatting (#1358) 2020-11-18 17:20:05 -08:00
Simon Michael
cc2654b17b ;ui: notes (#1387) 2020-11-15 11:32:43 -08:00
Simon Michael
4aecb9182e ;ui: notes (#1387) 2020-11-15 11:20:40 -08:00