Commit Graph

1713 Commits

Author SHA1 Message Date
Simon Michael
42efbbe4aa imp:import: also show the file path being imported to 2023-06-16 09:14:38 -10:00
Simon Michael
f225bf2f7f cln:print: clarify code a bit, rename originalTransaction 2023-06-14 18:11:28 -10:00
Simon Michael
98d53b42e4 ;dev:cli: avoid breakage with old haddock versions in Demo.hs 2023-06-02 10:22:49 -10:00
Simon Michael
2a3941682b ;doc: update command help 2023-06-01 16:34:57 -10:00
Simon Michael
1b0be2b65f imp:demo: add an easy -s/--speed option, play at 2x by default 2023-06-01 16:32:40 -10:00
Simon Michael
c9f39db363 imp:demo: rename/reorder install demo 2023-06-01 16:32:36 -10:00
Simon Michael
f485b30ae0 ;cln:close: fix end date doc 2023-06-01 16:32:25 -10:00
Simon Michael
f7b59c8950 dev: demo: drop two confusing demos for now 2023-05-31 18:57:30 -10:00
Simon Michael
9cdc0f21b6 imp:cli: add-ons can also have .js, .lua, or .php extensions 2023-05-30 20:23:12 -10:00
Simon Michael
96cdc0cb96 fix: likelyExecutablesInPath, hledgerExecutablesInPath on windows (#2040)
Pointed out by mauke in #haskell chat: this was incorrectly splitting
PATH on windows (splitting on the : in C:\...), which meant that
people using multiple drive letters on Windows might see hledger
failing to recognise installed add-on commands.
2023-05-27 12:28:38 -10:00
Simon Michael
a12880de05 fix: typo in Hledger.Cli.CliOptions.likelyExecutablesInPath
This had a bug noticed by mauke in #haskell: it was splitting PATH
on [ and ] as well as : and ;. Hard to trigger, but now fixed.
2023-05-27 09:21:49 -10:00
Simon Michael
6854b0b5e6 ;doc: update command help 2023-05-26 06:38:27 -10:00
Simon Michael
029b59093b feat: csv: rules files can be read directly; data file can be specified
CSV rules files can now be read directly, eg you have the option of
writing `hledger -f foo.csv.rules CMD`. By default this will read data
from foo.csv in the same directory.  But you can also specify a
different data file with a new `source FILE` rule. This has some
convenience features:

- If the data file does not exist, it is treated as empty, not an
  error.

- If FILE is a relative path, it is relative to the rules file's
  directory. If it is just a file name with no path, it is relative
  to ~/Downloads/.

- If FILE is a glob pattern, the most recently modified matched file
  is used.

This helps remove some of the busywork of managing CSV downloads.
Most of your financial institutions's default CSV filenames are
different and can be recognised by a glob pattern.  So you can put a
rule like `source Checking1*.csv` in foo-checking.csv.rules,
periodically download CSV from Foo's website accepting your browser's
defaults, and then run `hledger import checking.csv.rules` to import
any new transactions. The next time, if you have done no cleanup, your
browser will probably save it as something like Checking1-2.csv, and
hledger will still see that because of the * wild card. You can choose
whether to delete CSVs after import, or keep them for a while as
temporary backups, or archive them somewhere.
2023-05-19 09:09:21 -10:00
Simon Michael
71ef6ef478 fix: cli: commands list now shows help for hledger-lots if installed 2023-05-18 07:19:36 -10:00
Simon Michael
4c3046dea8 fix: cli: the commands list no longer lists non-installed addons (fix #2034)
And internally has been rewritten for clarity.
2023-05-18 07:19:36 -10:00
Simon Michael
ae4f58beb7 lib: Hledger.Cli.Commands: findCommand -> findBuiltinCommand 2023-05-18 07:13:58 -10:00
Simon Michael
2d03148d7f dev: lib: drop unused pragma 2023-05-09 10:03:15 -10:00
Simon Michael
147d49c66c dev: cln: drop Hledger.Data.RawOptions.inRawOpts 2023-05-09 10:02:24 -10:00
Simon Michael
a771c8fc19 imp: revert 2b5194238 imp: generate auto postings on forecast transactions by default (#2027)
I found at least one user for whom this would be a breaking change
(they generate forecast txns, and have auto posting rules, but don't
want the latter applied to the former). I guess it's better to keep
things as they were for now: if you need auto postings on your
forecast txns you must use two flags, --forecast --auto.
2023-04-30 08:08:26 -10:00
Simon Michael
7f713f6a44 imp: Generated/modified txns/postings are now tagged only with --verbose-tags 2023-04-29 18:25:11 -10:00
Simon Michael
ca42b0aaca imp: cli: clean up some flags' help and sync docs 2023-04-29 18:11:53 -10:00
Simon Michael
2b5194238b imp: generate auto postings on forecast transactions by default 2023-04-29 16:00:14 -10:00
Simon Michael
fe6df964b4 ;doc: bal: try to improve description of budget report differences 2023-04-25 12:39:28 -10:00
Simon Michael
1be06c87c4 feat: bal: A new --count report type counts postings instead of amounts. 2023-04-20 14:36:41 -10:00
Simon Michael
40d10bc8c5 imp: cli: commands list: help for hledger-bar script 2023-04-20 12:58:30 -10:00
Simon Michael
c2288f8143 ;doc: update command help 2023-04-07 09:52:31 -10:00
Simon Michael
9c4b5a26fa imp: ui, web: use a pager to show command line help, like cli 2023-04-06 15:36:08 -10:00
Simon Michael
3e3c3c8355 imp: help: doc: warn about old info on mac (fix #1770) 2023-04-06 15:36:00 -10:00
Simon Michael
f0157625cb ;doc: close: fix typo 2023-04-06 12:18:00 -10:00
Simon Michael
1de8600067 imp: cli: try to ensure less (and its more mode) show ANSI (fix #2015)
If you use some other $PAGER, you will have to configure it to show
ANSI yourself (or disable ANSI, eg by setting NO_COLOR=1).
2023-04-06 11:13:00 -10:00
Simon Michael
94e5aa3dfa ;doc: update command help 2023-04-06 11:12:35 -10:00
Simon Michael
ba0bb5eb4a imp: close: restore legacy flags --closing/--opening/--close-to/--open-from (#2020)
They're cruft, but hidden and low cost and remove one more user hassle.
2023-04-06 11:12:35 -10:00
Simon Michael
c151d57069 imp: close: restore equity command alias; improve help/doc (#2020) 2023-04-06 11:12:35 -10:00
Simon Michael
1d83e14392 imp: close: more cleanup; add --close; always default to ALE (#2020) 2023-04-06 11:12:35 -10:00
Simon Michael
7695e409bf imp: close: tweak doc more (#2020) 2023-04-06 11:12:35 -10:00
Simon Michael
3660118575 imp: close: reorder/clean options more (#2020) 2023-04-06 11:12:35 -10:00
Simon Michael
19ea31dd61 fix: close: restore --open-acct option (#2020) 2023-04-06 11:12:35 -10:00
Simon Michael
3acd0a33df imp: close: reorder flags, rewrite help/doc (#2020) 2023-04-06 11:12:35 -10:00
Simon Michael
e8cf09f477 imp: acc: reorder/clean up flags 2023-03-30 10:58:46 -10:00
Simon Michael
c03d6b1123 imp: print: --match makes better choices
Previously, similarity completely outweighed recency, so a
slightly-more-similar transaction would always be selected no matter
how old it was. Now similarity and recency are more balanced,
and it should produce the desired transaction more often.
There is also new debug output (at debug level 1) for
troubleshooting.
2023-03-27 15:21:42 -10:00
Chris Lemaire
cddbae6467 queries: Prefix boolean queries with expr:
Boolean queries are now prefixed with an 'expr:' prefix, making them
completely separable from old queries and making the addition of them a
little more migration proof.

The tests are updated accordingly, changes made to the tests previously
are removed and extra cautious documentation is also removed.
2023-03-27 10:29:26 -10:00
Chris Lemaire
35db1cae4f queries: Add generalised boolean queries
This commit changes some of the functions in the Query module and
changes the overall way to parse queries. Instead of using the words''
split function, this commit starts to fully parse the query, as it's
seen as a type of expression.

AND, OR, NOT, and space operators can be used. The space operator
simulates the behaviour from before, leaving a minimal amount of tests
that need to be adjusted to comply to the new behaviour.
2023-03-27 10:29:26 -10:00
Simon Michael
69a8834803 dev: demo: notes 2023-03-18 20:49:12 -10:00
Simon Michael
062559cbd5 imp: demo: nicer output, show clearer start/stop indicators, don't show "exit" 2023-03-18 20:06:24 -10:00
Simon Michael
33876905f1 dev: lib: Hledger.Cli.Script: cleanup 2023-03-18 20:02:22 -10:00
Simon Michael
be8e64e498 imp: lib: export more terminal size, ANSI style/color helpers
Hledger.Utils.IO (and therefore Hledger and Hledger.Cli.Script) added:

    getTerminalHeightWidth
    getTerminalHeight
    getTerminalWidth
    Color(..)
    ColorIntensity(..)
    bold'
    faint'
    black'
    red'
    green'
    yellow'
    blue'
    magenta'
    cyan'
    white'
    brightBlack'
    brightRed'
    brightGreen'
    brightYellow'
    brightBlue'
    brightMagenta'
    brightCyan'
    brightWhite'
    rgb'
2023-03-18 19:59:00 -10:00
Simon Michael
8ec59eafac imp: demo: Getting help 2023-03-18 01:33:34 -10:00
Simon Michael
0520ef03f6 ;imp: demo: titles cleanup 2023-03-18 01:32:40 -10:00
Simon Michael
7632321b3c ;imp: cli: commands list cleanups 2023-03-18 01:14:31 -10:00
Simon Michael
6588020e64 ;doc: update CLI help text files 2023-03-17 00:53:57 -10:00
Simon Michael
8b2efe3c33 ;imp: demo: help updates 2023-03-17 00:53:30 -10:00
Simon Michael
bbb58c3804 imp: demo: Watching the built-in demos (demo) 2023-03-17 00:09:24 -10:00
Simon Michael
b9273a4585 imp: cli: move OTHER last in commands list 2023-03-16 23:20:14 -10:00
Simon Michael
98865d6025 imp: demo: split print / balance demos 2023-03-16 23:20:14 -10:00
Simon Michael
6777182c70 imp: demo: output cleanups 2023-03-16 23:20:14 -10:00
Simon Michael
2d496609bc imp: demo: hide the file names 2023-03-16 23:20:14 -10:00
Simon Michael
7e422cb12a ;doc: update CLI help text files 2023-03-16 21:58:39 -10:00
Simon Michael
38fd51b97c feat: embed some asciinema demos, and a demo command to play them 2023-03-16 21:58:38 -10:00
Simon Michael
70ef3e816c fix: stats: fix a regression in date display since 1.28 (#2012) 2023-03-16 14:52:37 -10:00
Simon Michael
62bb93af9c imp: lib: Hledger.Cli.Script: more re-exports
added:
Control.Applicative
Control.Concurrent
Data.Char
Data.Functor
System.IO
System.IO.Error
2023-03-16 14:36:29 -10:00
Simon Michael
d012384d57 ;dev: cli: also build with GHC 9.6.1 2023-03-14 10:49:58 -10:00
Yehoshua Pesach Wallach
7ddcf3b9e1 fix: doc: remove duplicate in hledger close docs 2023-03-13 09:23:18 -10:00
Simon Michael
af38121442 imp: areg: when restricted by extra query args, show a hint in title
I was confused when using 'areg ACCT QUERY'. Now, the title will show
" (matching query)" as a hint when a QUERY is specified,
except when it is a date restriction (which is common and not confusing)
or a depth restriction (which is ignored).
2023-02-21 08:29:59 -10:00
Simon Michael
25b8d51ff2 activity: fix output after #1982; add tests 2023-02-21 07:17:21 -10:00
Simon Michael
70539a70bd ;cli: consolidate commands overvinew; sync commands list 2023-02-21 00:35:14 -10:00
Simon Michael
4d66f48a47 ;doc: update CLI help text files 2023-02-21 00:16:46 -10:00
Simon Michael
2e6cf0e806 ;imp: cli: commands list: better hledger-fifo entries 2023-02-20 22:15:58 -10:00
Simon Michael
c74f72ff40 ;imp: cli: commands list: add an entry for hledger-fifo 2023-02-20 21:58:13 -10:00
Simon Michael
0db44f11bb ;doc: update CLI usage texts 2023-02-20 16:24:54 -10:00
Simon Michael
2eaab54426 imp: close: more useful defaults, retain/migrate/open modes 2023-02-20 16:24:54 -10:00
Simon Michael
173f61bee0 dev: Commands: cleanup, fix harmless bug in command finding 2023-02-20 16:24:54 -10:00
Simon Michael
0567935e4b cli: simplify command doc inclusion, give them normal heading structure 2023-02-20 16:24:54 -10:00
Simon Michael
81f596b1fb cli: fix some Commands file permissions 2023-02-20 16:24:54 -10:00
Michael Grünewald
4b43e63a89 fix: cli: don't crash multicol with few strings
When there are only few, short strs and width is large, then the div
operation in itemspercol would return zero, triggering and error in
chunksOf.

This fix makes numcols have always at least as many entries as strs,
filling one line.
2023-02-19 11:52:46 -10:00
Simon Michael
fa70f160ae imp: partial/inferred dates are flexible, full dates are not (#1982)
DateSpans are now now aware of exact/flexible dates.
2023-02-17 07:24:19 -10:00
Simon Michael
7a9b0fd94c feat: check: the tags check checks tag names 2023-02-16 11:56:22 -10:00
Simon Michael
8aca6ff84b ;doc: import: tweak 2023-02-16 04:37:45 -10:00
Simon Michael
e34a20f3db ;doc: import: note a pitfall with multifile import 2023-02-15 20:09:20 -10:00
Jonathan Dowland
15eadd58ce feat: aregister: implement HTML output formatter (#1996)
The HTML formatter outputs a HTML snippet containing a table with a
header row and one data row per report item. The header row names
match those for the CSV output formatter. Multiple commodities in
a report item are listed together in the same cell separated by
commas, again matching the CSV formatter.

A future extension could be to explore using multiple rows for
multiple commodities, with HTML row spanning.

Fixes #1996.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2023-02-09 10:53:09 -10:00
Simon Michael
9106c9013f ;doc: bal: budget: fix lists 2023-02-04 14:54:54 -10:00
Simon Michael
3fea3b0db7 ;doc: bal: budget: compare with forecasting; add some tips 2023-02-04 14:47:01 -10:00
Simon Michael
b8e538a57f ;doc: bal: --budget: clarify use of print --forecast 2023-02-04 10:37:14 -10:00
Simon Michael
513b6b5164 ;doc: check: adjacentconversionpostings was dropped 2023-02-04 08:03:54 -10:00
Simon Michael
da5b4667df ;doc: rename directive sections, fix many links 2023-02-04 08:01:47 -10:00
Simon Michael
89b699e78e ;doc: cli: fix all links to Journal > Tags / Commands > tags 2023-02-04 07:05:58 -10:00
Simon Michael
4eeafdc4d3 dev: delete strange old remnant of the checkdates command, causing HLS trouble 2023-02-04 06:42:05 -10:00
Simon Michael
3f3401f8ad imp: cli: Hledger.Cli.Script convenience import for scripts
Hledger.Cli.Script is a convenient prelude for use in scripts,
reducing import boilerplate. It currently re-exports:

Control.Monad
Data.Either
Data.List
Data.Maybe
Data.Ord
Data.Time
Text.Printf hiding (formatString)
Data.Text (Text, pack, unpack)
Safe hiding (at)
System.Directory
System.Environment
System.Exit
System.FilePath
System.Process
Hledger
Hledger.Cli
Hledger.Cli.Main (argsToCliOpts)

but not (much of) Data.Text or Data.Text.IO, as those
need to be imported qualified.
2023-01-29 16:29:18 -10:00
Simon Michael
53efb49c77 fix: cli: use black or white for banner & version, maximising legibility 2023-01-27 17:01:06 -10:00
Simon Michael
eed8a06906 fix: cli: don't highlight help when TERM=dumb 2023-01-27 06:06:17 -10:00
Simon Michael
7a636dd428 imp: cli: non-bold version string 2023-01-26 23:17:58 -10:00
Simon Michael
45808c8e13 imp: cli: add terminalLightness; tweak IsLight threshold; embolden banner 2023-01-26 22:11:20 -10:00
Simon Michael
9c7144e939 imp: cli: pick help accent color to contrast with terminal bg when possible 2023-01-26 22:11:20 -10:00
Simon Michael
72cd441a9f imp: cli: add a little highlighting to help output 2023-01-25 19:16:09 -10:00
Simon Michael
de330bdfce imp: journal: check for adjacent conversion postings only in strict mode
This avoids breaking existing journals if, say, they happen to have
a single "equity:trading" posting somewhere.
2023-01-25 19:00:29 -10:00
Simon Michael
d77d76e17f imp: cli: use $PAGER when help output is taller than terminal
This works with hledger, hledger -h and hledger CMD -h.
2023-01-25 17:20:27 -10:00
Simon Michael
093fdda7db ;imp: cli: commands list tweaks 2023-01-25 15:20:15 -10:00
Simon Michael
1b3b26895e ;doc: update CLI usage texts 2023-01-25 11:59:05 -10:00
Simon Michael
311f0c99eb ;doc: areg: more advice on account-matching 2023-01-25 11:19:03 -10:00
Simon Michael
fbbae55101 imp: cli: merge register-match with register command
register-match is now the --match mode of the register command.
It was used by ledger-autosync at one point, hopefully the new flag
works similarly.
2023-01-25 10:44:12 -10:00
Simon Michael
1899b43073 imp: cli: drop the print-unique command
It disorders same-day transactions, doesn't support print's options,
and isn't useful enough to be always shown in the builtin commands
list. I don't know of any users, or a use for it, and it could easily
be recreated as an addon script, so I'm inclined to not bother
supporting it as a hidden command.
2023-01-25 10:44:12 -10:00
Simon Michael
cce63e6816 imp: cli: reorganise commands list; add a banner; multicolumn addons 2023-01-25 10:44:12 -10:00
Simon Michael
dbb1441402 ;doc: update CLI usage texts 2023-01-10 23:34:14 -10:00
Simon Michael
a7bb6dc5b5 fix: stats: remove wrong mention of output format in help 2023-01-10 23:30:15 -10:00
Simon Michael
e891eecb8b dev: add TypeOperators pragma to satisfy ghc 9.4 2023-01-10 19:33:31 -10:00
Simon Michael
1ea2c41bf7 imp: lib: registerWidthsFromOpts: fix ugly parse error message 2023-01-10 17:07:54 -10:00
Simon Michael
5c289ac92e lib: drop unused widthFromOpts 2023-01-10 17:07:19 -10:00
Simon Michael
af9f8c0416 ;doc: add: payees/descriptions completion 2023-01-04 19:58:05 -10:00
Simon Michael
b5ed655b49 imp: add: Description completions now include payees declared or used
Ie as well as full descriptions, it now also offers payee names which
have been declared with a payee directive, or recorded in transactions
with the | syntax.
2023-01-04 19:46:06 -10:00
Simon Michael
bfe12c33de ;doc: cli: balance: fix link to Budgeting page 2022-12-30 10:05:50 -10:00
Simon Michael
5a8e63d24d ;fix: bal: add missing --layout=tidy to help 2022-12-14 12:21:35 -10:00
Simon Michael
e819e02372 ;doc: bal: more balance doc cleanups 2022-12-14 09:03:55 -10:00
Simon Michael
cf607adfcf ;doc: update CLI usage texts 2022-12-14 07:53:03 -10:00
Simon Michael
2ba91b1195 ;doc: bal: clean up/reorder balance command doc 2022-12-14 07:52:53 -10:00
Simon Michael
2902769616 ;doc: cli, bal: cleanups 2022-12-14 06:36:28 -10:00
Simon Michael
985c15f039 ;doc: cli: clean up/rename directives sections 2022-12-11 01:59:26 -10:00
Simon Michael
fc5d1414f9 ;doc: cli: fix comment links, drop old doc 2022-12-11 01:24:10 -10:00
Simon Michael
ace185f7d2 ;doc: update old manual links 2022-12-10 18:56:47 -10:00
Simon Michael
474ad22b94 ;doc: officially rename "transaction prices" to "costs" in docs
(though not in code)
2022-12-10 18:50:45 -10:00
Simon Michael
3698f8cf90 fix: balcmds: the table layout in HTML output with --layout=bare 2022-12-10 10:22:26 -10:00
Simon Michael
2eadd2497b ;doc: codes: improve example
suggested by Rob Nielsen
2022-12-09 07:57:10 -10:00
Simon Michael
a5b4d80e24 ;doc: update CLI usage texts 2022-12-01 12:24:12 -08:00
Simon Michael
dedb331845 imp: --version strings no longer show + for dirty repos as it's buggy 2022-12-01 12:20:23 -08:00
Simon Michael
a929f8ec8a dev: Cli: cleanup 2022-12-01 12:20:19 -08:00
Simon Michael
d5682aa644 imp: print: --match now respects -o and -O 2022-11-24 19:50:47 -05:00
Simon Michael
b67cb97fff ;doc: print: mention "fuzzy" for discoverability 2022-11-09 09:06:38 -10:00
Simon Michael
7997007dcf imp: print: a failed --match now returns a non-zero exit code 2022-11-09 08:56:48 -10:00
Simon Michael
892eb06396 ;dev: ui: replace "curses interface" with TUI 2022-11-07 16:48:54 -10:00
Simon Michael
06bc09a36f dev: comments 2022-11-06 07:59:45 -10:00
Simon Michael
c25c5cef44 fix: make no-argument --debug flag work with ui & web also 2022-11-03 08:13:58 -10:00
Simon Michael
603fae70c0 dev: lib: clean up/simplify debug helpers 2022-10-31 11:26:11 -10:00
Simon Michael
d5fa141176 ;doc: update CLI usage texts 2022-10-08 13:18:29 -10:00
Simon Michael
ca5847fc08 imp: accounts: clarify flag help; prioritise flags in order of help 2022-10-08 13:18:29 -10:00
Simon Michael
4ecc57461a imp: accounts: -u, -d 2022-10-08 08:22:10 -10:00
Simon Michael
b16a02b2e6 imp: accounts: --unused 2022-10-08 08:16:07 -10:00
Simon Michael
360ef833ae ;doc: update CLI usage texts 2022-10-05 08:42:09 -10:00
Simon Michael
3e42851958 feat: accounts: add --undeclared and --find flags 2022-10-05 08:41:37 -10:00
Simon Michael
ae8d297396 ;doc: update CLI usage texts 2022-10-01 16:09:16 -10:00
Simon Michael
7d1b1cadce fix: add: doc: update tutorial link 2022-09-27 13:40:40 -10:00
Simon Michael
d4a1718690 fix: balcmds: fix empty html columns fix (#1933) 2022-09-14 17:25:18 -10:00
Simon Michael
b9d2aa7b54 fix: balcmds: handle an empty totals column in html output (#1933) 2022-09-14 16:56:28 -10:00
Simon Michael
93ce75d756 imp: dev builds with uncommitted changes now show + in --version 2022-09-08 12:23:59 -10:00
Simon Michael
5deda67658 imp: add: update/improve invalid date message 2022-09-01 15:30:36 -07:00
Simon Michael
c80c72d7cd dev: lib, cli, bin: enable/fix name shadowing warnings
And a few other cleanups.
2022-08-23 12:16:15 +01:00
Simon Michael
96db4fe9cc dev: ui: enable/fix name shadowing warnings 2022-08-23 02:57:59 +01:00
Simon Michael
8f65f8a096 ;doc: update CLI usage texts 2022-08-23 02:02:19 +01:00
Simon Michael
efa1879a11 ;doc: cli: help: more updates 2022-08-22 08:26:32 +01:00
Simon Michael
61d2c047e1 ;doc: update CLI usage texts 2022-08-22 08:21:24 +01:00
Simon Michael
9d2c9bd85f ;doc: cli: help: more updates 2022-08-22 08:21:01 +01:00
Simon Michael
2d9b6b91b5 ;doc: update CLI usage texts 2022-08-22 07:58:41 +01:00
Simon Michael
8eb1e0883a ;doc: cli: help, common tasks: update 2022-08-22 07:45:23 +01:00
Stephen Morgan
c966a0f413 fix!: cbr: Remove old account type query code. (#1921)
This replaces the old journal*AccountQuery with the new Type query. This
enables uniform treatment of account type, and fixes a subtle bug
(#1921).

Note that cbcsubreportquery no longer takes Journal as an argument.
2022-08-21 08:27:51 +01:00
Simon Michael
5fd5cd5b85 imp: acc: --declarations -> --positions; add --directives
And tweak the layout of flags in --help.
2022-08-18 05:08:10 +01:00
Simon Michael
8ec31b079c imp: accounts: --declarations shows that info, not --debug (#1909) 2022-08-16 09:13:30 +01:00
Simon Michael
035f2ac4bb imp: accounts: at --debug 2, show account declaration positions (#1909) 2022-08-16 09:13:30 +01:00
Simon Michael
3b34987bdd dev: accounts: clarifications 2022-08-04 19:01:11 +01:00
Charlotte Van Petegem
75fc6767a9 fix: roi: make sure empty cashflows are skipped when determining first cashflow
Empty cashflows are added when the begin date of the report is before the first
transaction.
2022-08-03 18:16:42 +01:00
Simon Michael
910b37abf8 fix: check: recentassertions: drop the cleared requirement (#1899)
It was causing trouble and complicating things too much.
I wanted it as another signal of being "caught up", but YAGNI.
2022-08-03 09:53:55 +01:00
Simon Michael
c025d228a1 doc: check: add more details about recentassertions 2022-08-01 06:53:04 +01:00
Simon Michael
1ed8c20978 feat: check recentassertions disallows assertion lag > 7 days
hledger check recentassertions (or flycheck-hledger if you enable this
check) will complain if any balance-asserted account does not have a
balance assertion within 7 days before its latest posting.  This aims
to prevent the situation where you are regularly updating your
journal, but forgetting to check your balances against the real world,
eventually requiring you to dig back through months of data to find
the error.
2022-08-01 06:53:04 +01:00
Stephen Morgan
c54fb4d514 imp: cost: Allow matching equity conversion equity postings to
transaction prices.

When given --infer-costs, hledger will now separately infer transaction
prices for different prices. Given a pair of adjacent conversion
postings, hledger will check if there is a single posting with a
transaction price which matches both the amounts. If so, it associates
those conversion postings to that priced post.

If it can't find any transaction price postings which match, it will
find the first non-transaction price post which matches one of the two
amounts, and will add a transaction price to that, and associate them.
2022-07-15 12:32:38 +01:00
Stephen Morgan
07d1b01287 imp: cost: Allow inferring cost from conversion equity postings with --infer-costs.
When given --infer-equity, hledger will change transaction prices to balancing equity postings. This introduces the inverse operation, --infer-costs, which will match balancing equity postings and transform them into a transaction price, allowing --cost to work properly with them. This is only a partial inverse as it needs to use some heuristics to match the postings which will not work in complicated cases.

Specifically, when hledger finds exactly two conversion postings in a transaction (by default, subaccounts of equity:conversion or equity:trad(e|ing)), it will find the first posting in the transaction whose amount is negative one of the conversion posting amounts, and inserts the corresponding transaction price.
2022-07-15 12:32:38 +01:00
Simon Michael
9a34145569 ;doc: update CLI usage texts 2022-07-12 16:01:33 +01:00
Simon Michael
82bfd2bebb ;doc: bse: clarify, link to account types 2022-06-07 02:24:53 +01:00
Simon Michael
ecb8023892 ;doc: bs, cf, is: clarify, link to account types 2022-06-07 02:17:26 +01:00
Simon Michael
496b59060f ;doc: bs, cf: add wikipedia link 2022-06-07 02:09:23 +01:00
Stephen Morgan
9155d679fe fix!: Revert "fix!: utf-8: Use with-utf8 to ensure all files are read and written with utf8 encoding. (#1619)"
This reverts commit e233f001c5.

This would break at least some people's workflow. A lighter touch is
probably sufficient.
2022-06-01 09:35:18 +10:00
Simon Michael
2d581d7d4d ;doc: update CLI usage texts 2022-05-23 05:42:27 -10:00
Simon Michael
43c0ca06c5 doc: cf: update cash account inference description for 1.25 2022-05-23 05:28:27 -10:00
Simon Michael
307f723b0a lib: simpler, more consistent names for check functions
API changes:
journalCheckAccountsDeclared
journalCheckCommoditiesDeclared
journalCheckPayeesDeclared
->
journalCheckAccounts
journalCheckCommodities
journalCheckPayees
2022-05-21 18:29:13 -10:00
Stephen Morgan
e233f001c5 fix!: utf-8: Use with-utf8 to ensure all files are read and written with utf8 encoding. (#1619)
May also fix #1154, #1033, #708, #536, #73: testing is needed.

This aims to solve all problems where misconfigured locales lead to
parsers failing on utf8-encoded data. This should hopefully avoid
encoding issues, but since it fundamentally alters how encoding is dealt
with it may lead to unexpected outcomes. Widespread testing on a number
of different platforms would be useful.
2022-05-22 13:12:19 +10:00
Simon Michael
db26456e1c imp: consolidate ordereddates check under Hledger.Read.Checks too
And remove the last vestiges of older more complex behaviour.
ordereddates now always checks all transactions in each file,
unaffected by a query. (But still affected by --date2).
2022-05-09 00:05:39 -10:00
Simon Michael
810a868c88 ref: consolidate most checks under Hledger.Read.Checks
and error message helpers in Hledger.Read.Error.
2022-05-09 00:04:33 -10:00
Simon Michael
a00dc04e0d imp: check: uniqueleafnames: use the standard error format (#1436)
Hledger.Read.Common:
export makePostingErrorExcerpt
2022-04-25 02:56:59 -10:00
Simon Michael
66d0beea5e imp: check: ordereddates: use the standard error format (#1436)
Hledger.Read.Common:
export makeTransactionErrorExcerpt
2022-04-25 02:56:59 -10:00
Simon Michael
0d232ed673 imp: check: exit with error' for consistent output 2022-04-25 02:56:59 -10:00
Simon Michael
5ee1e1d62f ;doc: fixups suggested by afm 2022-04-15 15:07:17 -10:00
Simon Michael
9f8381426c ;doc: update CLI usage texts 2022-04-14 12:39:09 -10:00
Simon Michael
318ec0a701 doc: tags: move most docs after the flags, like some other commands 2022-04-14 12:37:13 -10:00
Simon Michael
5af224d534 fix: tags: also match accounts declared but not used (#1857)
By default, all account declarations and all transactions are searched;
but when there's a query involving transaction fields,
account declarations unrelated to the matched transactions are not searched.

added:
queryIsCode
queryIsTransactionRelated
2022-04-14 12:28:43 -10:00
Simon Michael
b82021e0b6 imp: accounts: demote --debug 1 output to a more appropriate 4 2022-04-14 10:58:31 -10:00
Simon Michael
5858bb7b6d imp: ghc9.2: fix an incomplete-uni-pattern warning 2022-03-25 20:45:06 -10:00
Simon Michael
b3aff7a394 imp: add: avoid deprecated time function 2022-03-25 20:10:18 -10:00
Stephen Morgan
31c7c5d1ca fix: Clean up build failures due to redundant imports and duplicate
function.
2022-03-26 11:37:32 +11: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
cbdd86f4dc imp: reg: areg: Align to first 1000 postings by default, rather than 100.
This has the same performance characteristics for a big decrease in alignment
issues. 1000 postings seems to still put it under the memory bottleneck.
2022-03-11 13:25:38 -10:00
Simon Michael
129f37cfe6 reg: tweak --align-all help (#1839) 2022-03-11 07:16:55 -10:00
Simon Michael
64d1927384 reg: document --align-all (#1839) 2022-03-11 07:16:33 -10:00
Stephen Morgan
c0cc9e73c1 dev: reg: areg: Be more clever about register and aregister alignment.
When rendering register or aregister reports, calculate the amount /
balance width based on the first 100 items, and start rendering in that
way. If you encounter a longer one, update and continue rendering. This
will result in adjustment of column width for long reports, but allows
us to save a lot more performant/efficient.

This can be disabled with the new --align-all flag.

We also only render each amount once, rather than twice as before, by
storing the rendered amount in a tuple.
2022-03-11 06:47:48 -10:00
Stephen Morgan
cbc985d411 dev: reg: areg: Speed up reg and areg by only aligning to first 1000 items. 2022-03-10 17:42:04 -10:00
Stephen Morgan
4a80551406 fix: price: Make sure inferred market prices have the correct sign with
total prices. (#1813)

Also reduce duplication for inferring market prices (previously it was
done separately in both Hledger.Data.Journal and
Hledger.Cli.Commands.Prices), and remove *TotalPriceToUnitPrice
functions, since unit prices cannot represent all total prices.

Add a helper function numDigitsInt to get the number of digits in an
integer, which has a surprising number of ways to get it wrong.
2022-03-10 17:34:49 -10:00
Stephen Morgan
19ed6d3f00 cln!: sourcepos: Use megaparsec-supplied sourcePosPretty.
Change showSourcePos to sourcePosPretty, and showSourcePosPair to
sourcePosPairPretty.
2022-03-10 16:56:28 -10:00
Stephen Morgan
73925ae965 fix: types: Ensure auto postings can match against and be matched by type: queries.
This requires checking parent accounts for any new accounts introduced by auto postings which do not exist in the original journal.

Also refactor journalFinalise to only call journalPostingsAddAccountTags once, and use fewer intermediate variables.
2022-02-03 15:32:00 -10:00
Simon Michael
807717805a feat: accounts: --types shows account types (#1820) 2022-02-01 18:06:19 -10:00
Simon Michael
336c4a7b33 imp: cleaner error messages when parsing cli (less "user error") 2022-01-31 16:44:13 -10:00
Simon Michael
9c872c2d9c imp: areg: clearer, more consistent error messages 2022-01-31 16:44:13 -10:00
Simon Michael
45127dc5f5 feat: new type: query for easy matching by account type
type:TYPES, where TYPES is any of the (case insensitive) letters
ALERXCV, matches accounts by their declared or inferred type.
(See https://hledger.org/hledger.html#account-types.)
This should work with most commands, eg:

    hledger bal type:al
    hledger reg type:x

API changes:

Journal has a new jaccounttypes map.
The journalAccountType lookup function makes it easy to check an account's type.
The journalTags and journalInheritedTags functions look up an account's tags.
Functions like journalFilterPostings and journalFilterTransactions,
and new matching functions matchesAccountExtra, matchesPostingExtra
and matchesTransactionExtra, use these to allow more powerful matching
that is aware of account types and tags.
2022-01-31 16:44:13 -10:00
Simon Michael
248ddf9378 dev: more thorough Journal anonymisation, and a note (#1817) 2022-01-30 09:47:52 -10:00
Simon Michael
56be63e6f1 feat: queries can now match account tags (#1817)
Accounts, postings, and transactions can now all be filtered by the
tags in an account's declaration. In particular it's now possible to
more reliably select accounts by type, using their type: tag rather
than their name:

    account myasset       ; type:Asset
    account myliability   ; type:Liability

    $ hledger accounts tag:type=^a
    myasset

Accounts inherit tags from their parents.

API changes:
A finalised Journal has a new jdeclaredaccounttags field
for easy lookup of account tags.
Query.matchesTaggedAccount is a tag-aware version of matchesAccount.
2022-01-30 09:47:52 -10:00
Stephen Morgan
1d9be4c2de cln: print, close: Check the show_costs_ option instead of directly
checking the --show-costs flag.
2022-01-26 08:07:11 -10:00
Stephen Morgan
ba0eec9132 ref: Return the interval split in reportSpan, to reduce the number
of different places we call splitSpan and ease refactoring.
2022-01-26 08:05:37 -10:00