Commit Graph

4480 Commits

Author SHA1 Message Date
g. nicholas d'andrea
e678e09704 feat: accounts: add Gain (G) account type as subtype of Revenue [#2522]
Add a new account type Gain with single-letter code G as a subtype of
Revenue, similar to how Cash is a subtype of Asset and Conversion is a
subtype of Equity. This enables tracking capital gains/losses separately
while still including them in income statements and close --retain.

Usage: account revenues:capital  ; type: G

- type:G matches only Gain accounts
- type:R matches both Revenue and Gain (subtype matching)
- Auto-detection from account names matching:
  ^(income|revenue)s?:(capital[- ]?)?(gains?|loss(es)?)(:|$)
  e.g. income:gains, revenue:capital-gains, income:losses
2026-01-08 19:18:13 -10:00
Simon Michael
e36f55c98a ;add: allow older haskeline again, it's needed for stackage (reopens [#2410])
For now, `hledger add` with the stackage build of hledger 1.51.2+ will once again show ANSI junk.
Dev builds, the github release binaries, stackage builds of hledger-1.50..1.51.1,
and stackage hledger builds in future snapshots with a GHC that provides the fixed haskeline,
will remain free of that bug.
2026-01-08 18:15:35 -10:00
Simon Michael
1eaf37ca0f ;doc:changelogs: 1.51.2 2026-01-08 02:10:53 -10:00
Simon Michael
98fdffd516 ;doc: hledger's regular expressions: no lazy quantifiers 2026-01-06 21:42:32 -10:00
Simon Michael
e7d7c49562 imp: -f now errors if given a glob matching no files, like LEDGER_FILE
Previously LEDGER_FILE=foo hledger add did, but hledger -f foo add didn't.
Now they both consistently will error if given a glob
(a path contining [, {, *, or ?) that matches nothing,
rather than auto-creating a file with a glob-like name.

Hledger.Utils.IO:
expandPathOrGlob
2026-01-06 21:39:59 -10:00
Simon Michael
88f6c16dd5 fix:add,import: autocreate missing journal files again (but later) [#2514]
This restores the pre-1.50.3 behaviour of add and import, which once
again auto-create a missing file (specified by -f or LEDGER_FILE or
the builtin default path) rather than giving an error.
This fixes #2514 and refines the fix for [#2485].

There's also an improvement: they no longer create it unconditionally at the start;
they create lazily, when they have data to write.

Hledger.Read:
defaultExistingJournalPath
defaultExistingJournalPathSafely
readPossibleJournalFile

Hledger.Cli.Utils:
withPossibleJournal
2026-01-06 21:39:59 -10:00
Simon Michael
9b0555e657 ;doc:COMMON TASKS:Setting LEDGER_FILE: updates 2025-12-29 09:30:40 -10:00
Dmitry Astapov
edfea86656 ;roi: rephrase IRR solver errors a bit 2025-12-27 09:43:53 -10:00
Dmitry Astapov
1c37dc44a7 ;roi: more input sanity checks (fixes #2505) 2025-12-27 09:43:53 -10:00
Simon Michael
2fb09f0d1e cabal: update cabal files 2025-12-26 17:10:47 -10:00
Simon Michael
1a0a81d9e7 fix: add, ui: better fix for add's [#2410], also fixes ui's [#2512]
By using newer haskeline fixing https://github.com/haskell/haskeline/issues/130.
2025-12-26 17:09:26 -10:00
Simon Michael
91d019741e ;pkg: allow base 4.22 / ghc 9.14 2025-12-26 15:17:16 -10:00
Simon Michael
82cf87c61b ;doc: merge change docs from 1.51.1 2025-12-08 11:02:51 -10:00
Simon Michael
81846aa747 ;doc:changelogs, relnotes: merge 1.50.5 2025-12-08 10:19:24 -10:00
Simon Michael
665e2d0a55 fix:journal:include: relative includes from a symlinked file work again [#2503] 2025-12-08 09:36:13 -10:00
Simon Michael
67b2063809 imp!:aregister, journal: same-day txns respect order of -f options
If transactions on the same date are coming from two files specified
with -f options, we expect them to be displayed in parse order, ie
respecting the order of the -f options. This wasn't always the case,
now it is.

Also, transactions' tindex field is now unique across all files,
where previously it started at 1 in each file. This affects hledger
data generally, not just the aregister command.
2025-12-07 17:21:36 -10:00
Simon Michael
28f2180649 imp:areg: keep no matched account error on one line 2025-12-07 16:51:26 -10:00
Simon Michael
6bdaef89c0 ;dev:journal:include: more tests, note a new regression like [#2499] 2025-12-06 11:07:57 -10:00
Simon Michael
41a81fa527 ;doc:changelogs:edits 2025-12-05 07:34:52 -10:00
Simon Michael
cda2eb7d74 ;doc: update embedded manuals 2025-12-05 01:12:50 -10:00
Simon Michael
b59bce2137 ;cabal: update cabal files 2025-12-05 01:10:17 -10:00
Simon Michael
1cd3b3d95a ;pkg: set version to 1.51.99 2025-12-05 01:10:16 -10:00
Simon Michael
93da076299 ;doc: finalise changelogs for 1.51 on 2025-12-05 2025-12-05 00:35:49 -10:00
Simon Michael
42b0f4a66f ;doc: changelogs 2025-12-04 19:49:33 -10:00
Simon Michael
2f18c85879 ;doc: update embedded manuals 2025-12-04 17:15:51 -10:00
Simon Michael
3c672dee55 ;doc:changelogs:1.50.4 2025-12-04 16:17:50 -10:00
Simon Michael
a184ccddd1 ;doc:journal:include: edits 2025-12-04 09:20:54 -10:00
Simon Michael
8cd113389a fix:journal:include: drop 1.50's exclusion of glob-matched dot paths [#2498]
1.50* attempted to work around Glob's implicit searching of non-top-level dot dirs.
This was overzealous; it meant that journal's include completely
excluded paths involving a glob and a dot dir or dot file anywhere in the path.

Now, the pre-1.50 behaviour is restored:
`*` and `**` won't implicitly match dot files or top-level dot directories.
They will implicitly search non-top-level dot directories, as before (#Glob#49).
2025-12-04 05:54:54 -10:00
Simon Michael
ade7ff83eb dev:test:journal:include: add missing symlinks 2025-12-01 12:22:56 -08:00
Simon Michael
53b923160c dev:test: exclude perf tests from func tests more robustly 2025-12-01 12:12:42 -08:00
Simon Michael
81744d81a1 fix:journal:include: fix some regressions with glob matching in 1.50-1.50.3
Before 1.50, journal's include directive's handling of glob patterns (*, **, ?, etc.)
had these limitations:

- ** always searched intermediate dot directories
- ** matched only directories, not files

In 1.50-1.50.3, it had different limitations, some unintended:

- it ignored all dot files, dot dirs, and symbolic links to dot dirs,
  even when explicitly mentioned in the pattern (unless using --old-glob)
- it showed symbolic links dereferenced, eg in `hledger files` output

Now it has fewer limitations, mainly this:

- it ignores all dot files and dot dirs, even when explicitly mentioned (unless using --old-glob)

Ie it no longer ignores symbolic links to dot dirs, and it no longer shows symbolic links dereferenced.
Also: including the current file is now always harmless, whether using a glob pattern or not.

Internally, file paths in the "include file stack" (jincludefilestack) are now just absolute,
but not canonicalised; showing symbolic links un-dereferenced in output and error messages seems
generally more useful. This might affect output elsewhere also.
(Those paths are still canonicalised on the fly when checking for include cycles,
not so efficiently: each time an include directive is parsed, all the current parent files
and all the new glob-matched include files will be re-canonicalised.
Hopefully this is unnoticeable.)
2025-12-01 11:28:51 -08:00
Simon Michael
92a3ea48f9 dev:test:journal: clean up, expand include tests 2025-12-01 11:00:42 -08:00
Simon Michael
bb9ec4eadf ;dev:test:perf: edits 2025-12-01 11:00:42 -08:00
Simon Michael
8847c9aeb6 ;doc:changelogs 2025-11-26 13:48:43 -08:00
Simon Michael
4d0550f1b4 ;dev: add performance tests, logging to perf.log, run by just perftest 2025-11-20 12:26:57 -10:00
Simon Michael
64b97b2658 ;doc: update embedded manuals 2025-11-19 22:25:44 -10:00
Simon Michael
d5ceb7bba3 ;doc: update command docs 2025-11-19 22:25:25 -10:00
Simon Michael
f58d3835b1 imp:stats: one-line mode; fix -o; doc updates
The new -1 flag prints a single line of output in machine-friendly
tab-separated format, including the program version, journal file
name, and performance stats.

Also -o now redirects all output, including the performance stats.
2025-11-19 22:23:47 -10:00
Simon Michael
0835a2485f ;doc:csv: CSV fields and hledger fields: edits 2025-11-19 10:45:45 -10:00
Simon Michael
c0ec0f4381 ;doc:csv: CSV fields and hledger fields: edits 2025-11-19 10:44:20 -10:00
Simon Michael
19efd392b9 ;doc:csv: Regular expressions in CSV rules: edits 2025-11-19 10:19:10 -10:00
Simon Michael
2a8fdccdd4 ;doc:csv: Regular expressions in CSV rules: edits 2025-11-19 10:17:08 -10:00
Simon Michael
35fbad37c4 ;doc:csv: Regular expressions in CSV rules 2025-11-19 10:06:37 -10:00
Simon Michael
1fec479d35 ;doc:csv: CSV fields and hledger fields 2025-11-19 10:06:37 -10:00
Simon Michael
6c86648e02 ;doc: update embedded manuals 2025-11-18 18:25:11 -10:00
Simon Michael
99bbc22de1 ;doc: update command docs 2025-11-18 18:25:03 -10:00
Simon Michael
518d367b88 ;dev: update internal error message 2025-11-18 17:50:05 -10:00
Simon Michael
e04c2ee0d7 fix:add: clean up typos after an over-eager search-replace 2025-11-18 17:47:34 -10:00
Simon Michael
4e66d43984 ;doc: add the 1.50.3 changelogs 2025-11-18 17:46:50 -10:00
Simon Michael
4493f0615b dev:add: refactor, simplify names 2025-11-18 10:32:34 -10:00