Commit Graph

439 Commits

Author SHA1 Message Date
Simon Michael
67cd6be424 imp: ui: at --debug=2, do lots of logging to debug.log 2022-08-23 00:50:51 +01:00
Simon Michael
4e105f0cb7 ;dev: ui: note relevant discussion 2022-08-17 16:19:34 +01:00
Simon Michael
4bd9f4a6f7 dev: ui: avoid MonadFail entirely, simplifying ghc version compat (#1889) 2022-08-17 15:57:27 +01:00
Simon Michael
2a594b7fb7 pkg: ui: use/require brick 1.0+ (#1889) 2022-08-17 15:57:27 +01:00
Simon Michael
dde2ea7e42 pkg: ui: support doclayout 0.4, brick 0.72+ 2022-07-10 22:03:45 +01:00
Simon Michael
3eddd913e3 imp: ghc9.2: silence incomplete-record-updates warnings 2022-03-25 20:36:12 -10:00
Stephen Morgan
603b2e9f09 ref: Use ExceptT String IO a instead of IO (Either String a).
This increases composability and avoids some ugly case handling. We
re-export runExceptT in Hledger.Read.

The final return types of the following functions has been changed from
IO (Either String a) to ExceptT String IO a. If this causes a problem,
you can get the old behaviour by calling runExceptT on the output:
readJournal, readJournalFiles, readJournalFile

Or, you can use the easy functions readJournal', readJournalFiles', and
readJournalFile', which assume default options and return in the IO
monad.
2022-03-25 14:23:27 -10:00
Stephen Morgan
45408183fe dev: reg: areg: Strip prices early on in PostingsReport and AccountTransactionsReport, when possible.
This results in big speedups in cases when we have many transaction prices, like in examples/10000x1000x10.journal. This can be disabled with the show_costs_ option in ReportOpts.
2022-03-10 17:21:40 -10:00
Stephen Morgan
57d055b643 fix: cost: Add inferred equity postings during journal finalisation, so
they can be matched by queries.
2022-01-16 18:37:18 -10:00
Stephen Morgan
8eedbbbe87 imp: cost: Generate totally balanced conversion postings for amounts with costs.
Introduce --infer-equity option which will generate conversion postings.
--cost will override --infer-equity.

This means there will no longer be unbalanced transactions, but will be
offsetting conversion postings to balance things out. For example.

2000-01-01
  a   1 AAA @@ 2 BBB
  b  -2 BBB

When converting to cost, this is treated the same as before.
When used with --infer-equity, this is now treated as:

2000-01-01
  a                               1 AAA
  equity:conversion:AAA-BBB:AAA  -1 AAA
  equity:conversion:AAA-BBB:BBB   2 BBB
  b                              -2 BBB

There is a new account type, Conversion/V, which is a subtype of Equity/E.
The first account declared with this type, if any, is used as the base account
for inferred equity postings in conversion transactions, overriding the default
"equity:conversion".

API changes:

Costing has been changed to ConversionOp with three options:
NoConversionOp, ToCost, and InferEquity.
The first correspond to the previous NoCost and Cost options, while the
third corresponds to the --infer-equity flag.  This converts transactions with costs
(one or more transaction prices) to transactions with equity:conversion postings.
It is in ConversionOp because converting to cost with -B/--cost and inferring conversion
equity postings with --infer-equity are mutually exclusive.

Correspondingly, the cost_ record of ReportOpts has been changed to
conversionop_.

This also removes show_costs_ option in ReportOpts, as its functionality
has been replaced by the richer cost_ option.
2021-12-21 10:50:13 -10:00
Simon Michael
1ef8f329c6 lib: simpler more robust version strings, with date/without patchlevel
We no longer rely on git tags and git describe output, since it's
hard to reliably select the correct tag eg for minor releases.
We might use them again in future for dev builds, but it requires
adding git describe --match support to githash. For now,

* Program name, OS and architecture are always shown.
* The package version is always shown.
* If there is git info at build time, the latest commit hash and commit date are shown.

Example outputs:
A homebrew binary, not built in git repo: hledger-ui 1.24, mac-aarch64
A CI release build, built in git repo:    hledger 1.24.1-g455b35293-20211210, mac-x86_64

API changes:

* new type synonyms ProgramName, PackageVersion, VersionString
* versionStringForProgname -> versionString with extra argument
* versionStringFor -> versionStringWith with extra argument
2021-12-10 12:42:40 -10:00
Simon Michael
6b3d040fdf cln: ui: drop unused pragma 2021-12-09 12:23:55 -10:00
Simon Michael
bfb8a13c13 imp: ui: Z -> z for easier zero toggling
Z remains supported as a hidden legacy key.
2021-11-25 11:58:41 -10:00
Simon Michael
eb4ad8cc11 imp: ui: also show declared leaf accounts (when showing zeros)
Similar to (and motivating) balance --declared, the goal is to
show a useful list of accounts when all you have is some starter
files with account declarations.
2021-11-25 11:57:39 -10:00
Simon Michael
e5678ce230 Revert "imp: ui: accounts: also show declared accounts, even if unused"
This reverts commit 29efacf02c.
(It breaks filtering by account, also the parent accounts aren't really desirable to see.)
2021-11-22 12:06:23 -10:00
Simon Michael
29efacf02c imp: ui: accounts: also show declared accounts, even if unused
This will be more user-friendly when getting started.
2021-11-22 11:13:47 -10:00
Simon Michael
7e4b2af361 imp: ui: -w short flag for --watch 2021-11-21 19:34:40 -10:00
Stephen Morgan
59b4968929 imp: ui: Display an error message on invalid regexp, rather than
silently ignoring. (#1394)
2021-11-20 22:23:52 -10:00
Simon Michael
c11d19a893 fix: ui: scroll selection to middle on first entry, also
The viewport doesn't exist until after first render, and scrollSelectionToMiddle didn't need it; viewportScroll queues up events for it.
https://github.com/jtdaugherty/brick/issues/349
2021-11-20 15:33:28 -10:00
Simon Michael
d0c937a41b imp: ui: can click bottom blank area to go back 2021-11-19 11:32:33 -10:00
Simon Michael
956ee06591 imp: ui: transaction: refactor 2021-11-19 11:32:09 -10:00
Simon Michael
f5cfcf827d imp: ui: don't use top margin as a click target yet 2021-11-18 23:01:52 -10:00
Simon Michael
710c054589 ui: listScrollPushingSelection: do scroll if there's no selection 2021-11-18 22:21:37 -10:00
Simon Michael
7bbff6a359 fix: ui: accounts: don't let j or C-n move past bottom 2021-11-18 22:21:37 -10:00
Simon Michael
9f6595f122 ui: refactor, generalise listScrollPushingSelection 2021-11-18 22:21:37 -10:00
Simon Michael
731a416b8c ui: register: scrolling pushes selection, like accounts screen 2021-11-18 22:21:37 -10:00
Simon Michael
3a57814402 ui: debounced clicking; click top/left margin to exit 2021-11-18 22:21:37 -10:00
Simon Michael
6d69ea9c29 ui: mouse scrolls accounts, register screens 2021-11-18 22:21:37 -10:00
Simon Michael
96a80fca70 ui: register: left click enters transaction screen 2021-11-18 22:21:37 -10:00
Simon Michael
35402fb472 ui: accounts: left click enters register 2021-11-18 22:21:37 -10:00
Simon Michael
2076d5a98b ui: enable mouse support at startup 2021-11-18 22:21:37 -10:00
Simon Michael
8f37d8a611 ;ref: ui: clarify vty construction 2021-11-18 22:21:37 -10:00
Stephen Morgan
ff0132df28 dev: Use realLength from doclayout instead of strWidth and textWidth. (#895)
This gives us more accurate string length calculations. In particular,
it handles emoji and other scripts properly.
2021-11-11 18:29:50 -10:00
Simon Michael
1f2c11d1bc ui: fix breakage from "areg: begin respecting --date2" (#1731) 2021-10-10 11:07:15 -10:00
Stephen Morgan
2b8190b238 fix: ui: Do not display a screen full of .. when there are no transactions. (#822) 2021-09-21 15:26:49 -10:00
Stephen Morgan
4cfd3cb590 lib!: Remove GenericSourcePos, and replace it with either SourcePos or
(SourcePos, SourcePos).

This has been marked for possible removal for a while. We are keeping
strictly more information. Possible edge cases arise with Timeclock and
CsvReader, but I think these are covered.

The particular motivation for getting rid of this is that
GenericSourcePos is creating some awkward import considerations for
little gain. Removing this enables some flattening of the module
dependency tree.
2021-09-20 08:38:33 -10:00
Simon Michael
326d6e8dae ref: ReportOptions{infer_value_} renamed to infer_prices_
For more consistency with the flag name (--infer-market-prices).
And BalancingOpts{infer_prices_} is now infer_transaction_prices_.
2021-09-18 12:12:31 -10:00
Stephen Morgan
3456fcb862 test: ui: web: Use report date from _rsDay for hledger-ui and
hledger-web, rather than getCurrentDay.

File watching in hledger-ui continues to use getCurrentDay.
2021-09-09 14:40:39 -10:00
Stephen Morgan
765466c392 dev!: ui: Rename fields of UIOpts for consistency.
In code, either replace the name with the new name, or use the lenses
instead.

watch_ -> uoWatch
cliopts_ -> uoCliOpts
2021-09-09 13:31:43 -10:00
Stephen Morgan
7f7f1a2cdf ref: ui: lens: Use lenses in UIState, saving a lot of boilerplate. 2021-09-09 13:31:43 -10:00
Stephen Morgan
f471258a48 dev: ui: lens: Add classy lens instances for UIOpts and UIState. 2021-09-09 13:31:43 -10:00
Stephen Morgan
09a2449f4f ref: ui: Pull register and theme options into UIOpts. 2021-09-09 13:31:43 -10:00
Stephen Morgan
54c73ff759 ref: ui: Refactor code to eliminate requirement for change_ in UIOpts.
--change is already stored in balanceaccum_ in ReportOpts, so it does
not need to be stored in UIOpts too.
2021-09-09 13:31:43 -10:00
Stephen Morgan
83aa7324eb dev: cli: Move Template Haskell to get git hash from Hledger.Cli.Version
to Hledger.Cli.

Since the git hash changes whenever any file in the repository changes,
this means Hledger.Cli.Version needs to be recompiled all the time.
Since it is at the bottom of the module hierarchy, this means that the
whole hledger package needs to be recompiled. We instead move the
TemplateHaskell splice to one of the top modules, so much less needs to
be recompiled.

Note: Ghc seems to be able to get out of most of the recompiling a lot
of the time (due to caching?), but this makes things more reliable.
2021-08-30 15:57:33 -10:00
Stephen Morgan
a0f9d7560f pkg!: Remove Hledger.Utils.Color module.
This module was only used in one place in Hledger.Data.Amount. The code
has been moved directly into Hledger.Utils.
2021-08-30 15:57:33 -10:00
Stephen Morgan
761e00caa4 cln: hlint: Clean up lambda related warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
beecb3c9ac cln: hlint: Clean up list related hlint warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
e13239386f cln: hlint: Clean up == and elem related hlint warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
eb6047e81b cln: hlint: Remove redundant where and lambda warnings. 2021-08-26 21:00:35 -10:00
Stephen Morgan
46b0745412 cln: hlint: Remove Either and Bifunctor related warnings. 2021-08-26 21:00:35 -10:00