Commit Graph

3874 Commits

Author SHA1 Message Date
Simon Michael
10c523c057 ;pkg: set version to 1.42.99 2025-03-07 18:49:07 -10:00
Simon Michael
fd0bcdfede ;doc: finalise changelogs for 1.42 on 2025-03-06 2025-03-07 06:36:53 -10:00
Simon Michael
8184d20b9f ;doc: update changelogs 2025-03-07 06:36:15 -10:00
Simon Michael
e25cd526b7 ;doc: update embedded manuals 2025-03-06 16:05:55 -10:00
Dmitry Astapov
1fc7006919 run: cache input files by (iopts, name), allows commands with different iopts 2025-03-06 11:54:00 -10:00
Simon Michael
d47107ab7a ;dev:readJournal: doc 2025-03-06 05:39:23 -10:00
Simon Michael
874771d47c dev:readJournal: assume default file name "-" rather than "(string)" [#2328]
"-" implies data from standard input so "string" is perhaps more
correct, but I think this is a harmless simplification and it
makes `files` output consistent when run by `run`.
2025-03-06 05:13:37 -10:00
Simon Michael
cb373447db fix:cli:paging: support older less, don't pass --use-color [#2335]
Older less versions (eg 551) require --use-colour, and break if --use-color is passed. So we no longer attempt to enable colour in less by default.
2025-03-04 16:38:25 -10:00
Thomas Miedema
2faceb8e1b feat: csv: allow multiple matchers on the same line
`If blocks` and `If tables` now allow multiple matchers on the same line
separated by `&&` (AND) or `&& !` (AND NOT).

Example `if block` with two matchers on the same line:

	if %description amazon && %date 2025-02-22
	    account2 expenses:books

Example `if table` with two matchers on the same line:

	if,account2
	%description amazon && %date 2025-02-22, expenses:books
2025-03-01 11:21:00 -10:00
Simon Michael
d346e56b79 dev: fix warnings, update yaml file, edit [#2340] 2025-02-27 13:41:48 -10:00
gesh
a24c39f13f fix: Use POSIX API to compute tty width (#2332)
On some systems, TERM is set to a value that doesn't have a valid
terminfo entry. Rather than hackily fall back on a value for TERM that
appears to work in most contexts (TERM=dumb) but which isn't guaranteed
anywhere to be valid, use proper POSIX ioctls to get the tty width.

This has the added bonus of also working on Windows.

In fact, we already settled on computing the terminal size in this way
in hledger-lib, so this commit centralizes the choice of the logic
there.

Also added a note for alternative methods and their tradeoffs, in case
this turns out to be fragile on some systems.
2025-02-27 13:41:48 -10:00
Thomas Miedema
5129a94bd7
;cln: unittest.hs: remove bothersome PackageImports (#2337)
When running `cd hledger-lib && ghci test/unittest.hs`, ghci complains
with:

```
  test/unittest.hs:7:1: error:
      Could not find module ‘Hledger’
      It is not a module in the current program, or in any known package.
    |
  7 | import "hledger-lib" Hledger (tests_Hledger)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Failed, no modules loaded.
```

This commit removes the "hledger-lib" package-qualified import, such
that above ghci command works as expected.

However, there is a comment in hledger-lib/test/unittest.hs that says:

> package-qualified import to avoid cabal missing-home-modules warning
> (and double-building ?)

The missing-home-modules warning and the double building can indeed be
reproduced by running (after removing the "hledger-lib"
package-qualified import): `cd hledger-lib && cabal build unittest`. It
will first build `hledger-lib`, then show a warning about
missing-home-modules, and then build `hledger-lib` again.

After comparing the unittest sections of hledger.cabal and
hledger-lib.cabal, the solution turned out to be to remove `./` from
hs-source-dirs for unittest. Don't ask me why though!

Overall it's a nice cleanup.
2025-02-26 11:54:59 -10:00
Joschua Kesper
5114962b2a feat:csv: add an encoding rule, allowing non-UTF8 CSV to be read [#2319]
Previously, hledger could read CSV files containing non-ascii
characters only if they are UTF8-encoded.  Now there is a new CSV
rule, encoding ENCODING, which allows reading CSV files with other
encodings.

This adds a dependency on the encoding library, which supports fewer
encodings than text-icu but does not require a third-party C library.
To avoid build issues on various platforms, we require version 0.10+.

This adds some use of the ImplicitParams language extension, required
by encoding's API, but only in a small code region.

This also changes the type of Reader's rReadFn; it now takes
a `Handle` rather than a `Text`, allowing more flexibility.
2025-02-15 14:48:30 -10:00
Simon Michael
39f3b2c7ba ;dev: doc 2025-01-31 02:04:40 -10:00
Simon Michael
63b939a201 imp:print: --invert now also negates balance assertion/assignment amounts [#2314] 2025-01-29 09:47:29 -10:00
Simon Michael
bbb06209e7 lib: +postingNegate 2025-01-29 09:42:15 -10:00
Simon Michael
0dca0911f3 lib: negatePostingAmount -> postingNegateMainAmount 2025-01-29 09:41:51 -10:00
Simon Michael
3e838e4d0f imp:print: support --invert [#2314] 2025-01-27 05:21:36 -10:00
Simon Michael
29885d15fa dev: refactor Hledger.Write.Html etc, reducing Lucid references
Clarify the HTML lib situation a bit, and clean up some imports.

Related: #2244
2025-01-25 11:53:51 -10:00
Simon Michael
14dd2c6200 dev: rename printHtml -> styledTableHtml 2025-01-25 11:53:51 -10:00
Simon Michael
adef1a8416 lib: add dropRawOpt, cliOptsDropArgs 2025-01-21 22:02:05 -10:00
Simon Michael
edfcd3554f lib: showAmountCost(B): drop leading whitespace 2025-01-15 16:28:43 -10:00
Simon Michael
e98af39e27 imp:pivot: support pivoting on amount (quantity) or cost 2025-01-15 13:47:04 -10:00
Simon Michael
e7e0b5c868 lib: Hledger.Data.Amount: showAmountCost 2025-01-15 13:22:03 -10:00
Simon Michael
90415875f5 imp:pivot: support pivoting on commodity symbol; doc improvements 2025-01-15 12:46:09 -10:00
Simon Michael
c23087f124 fix: show a week period beginning in the previous year correctly [#2304]
Eg the week beginning 2024-12-30 (which is week 1 of 2025 because the
thursday falls in 2025) was previously shown as 2024-W01, now 2025-W01.
2024-12-20 10:41:47 -10:00
Simon Michael
1a5353b988 dev: disable doctest testing error output, color breaks it 2024-12-20 08:51:38 -10:00
Simon Michael
aefa4e8f20 imp:cli: show first line of error messages in red
error' and usageError now redden and bolden the first line of error
messages, when ANSI codes are supported and permitted.
And warn goldens and boldens the first line of warning messages.
2024-12-20 08:51:38 -10:00
Simon Michael
ffc3440313 ;doc: update embedded manuals 2024-12-09 17:58:30 -10:00
Simon Michael
f2cb3cd023 ;cabal: update cabal files 2024-12-09 17:58:25 -10:00
Simon Michael
20f1f51a9d ;pkg: set version to 1.41.99 2024-12-09 17:58:24 -10:00
Simon Michael
58d461d5ee ;doc: changelogs: fix heading 2024-12-09 16:03:40 -10:00
Simon Michael
77a25b6423 ;doc: merge 1.41 changelogs 2024-12-09 15:46:35 -10:00
Simon Michael
b663822b88 fix: print: ignore --depth entirely
Until now, a depth limit caused print to show only transactions referencing accounts as deep or deeper than that.
2024-12-09 15:37:30 -10:00
Simon Michael
917f03b828 ;doc: changelogs 2024-12-06 18:05:28 -10:00
Simon Michael
f648903b37 imp:print:beancount: don't add account tags to postings
When print is generating beancount output, turn off the usual
inheritance of account tags by postings; it would generate excessive
metadata in the journal. Beancount can do or not do that kind of
inheritance itself.
2024-12-06 05:55:42 -10:00
Simon Michael
ff28aa329a imp:print:beancount: convert tags to BC metadata
Transaction and posting tags (and posting tags inherited from accounts)
are now converted safely to Beancount-compatible transaction and posting
metadata lines.
2024-12-06 05:55:42 -10:00
Simon Michael
17332c75f9 imp:print:beancount: generate operating_currency directives from cost currencies 2024-12-06 05:55:42 -10:00
Simon Michael
d925c8a042 imp:print:beancount: add a second account name part if needed
Beancount requires account names to have at least two parts.
2024-12-06 05:55:42 -10:00
Simon Michael
6e3dfd6703 imp:print:beancount: remove virtual postings automatically 2024-12-06 05:55:42 -10:00
Simon Michael
1048791810 imp:csv: ignore whitespace, show error position when reading .latest files 2024-12-05 16:35:18 -10:00
Simon Michael
29349458b3 imp:csv:if: go back to accepting unknown csv field names [#2289]
It makes life easier when reusing common rules with different CSVs.
2024-12-04 17:45:28 -10:00
Simon Michael
99fc4cd61f imp:csv:if: show the problematic field name when warning 2024-12-04 16:47:01 -10:00
Simon Michael
054a204aa0 imp:csv:if: support & ! (AND NOT) 2024-12-03 17:25:43 -10:00
Simon Michael
3d55f260b3 imp:csv:if: warn on invalid csv field names; improve doc [#2289] 2024-12-03 16:07:57 -10:00
Simon Michael
05ae105b42 dev: Hledger.Utils.IO: warn 2024-12-03 16:07:54 -10:00
Simon Michael
a47dce073d dev:csv: refactor/document isBlockActive, matcherMatches 2024-12-03 13:51:32 -10:00
Simon Michael
1010e3dee6 imp:csv: improve debug=7 output from isBlockActive 2024-12-03 10:45:16 -10:00
Simon Michael
fd9c64a4ad pkg: allow megaparsec 9.7 [stackage#7585] 2024-12-03 08:46:29 -10:00
Stephen Morgan
74f0f37fb3 imp: queries: Allow regular expression depth queries
Previously depth-limiting was universal across all accounts, e.g. all
accounts are clipped to depth 2. However, sometimes you want certain
accounts clipped to a different depth than others, e.g. all expenses to
depth 3, while all assets to depth 2. This commit enables depth-limiting
to optionally include a regular expression, which limits the accounts it
applies to.

More than one depth limit can be passed, and they are applied to each
account name by the following rules:
- If one or more regular-expression depth limit applies, use the
  most specific one
- If no regular-expression depth limits apply, and a flat depth limit is
  supplied, use that
- Otherwise, do not do any depth limiting

For example, this will clip all accounts matching "assets" to depth 3,
all accounts matching "expenses" to depth 2, and all other accounts to
depth 1.
--depth assets=3 --depth expenses=2 --depth 1
2024-12-03 08:33:21 -10:00
Simon Michael
735beb96a7 imp:valuation: more compact and informative --debug=2 output [#2287]
Market prices are now shown using one line each,
the known prices are listed (forward / forward+reverse),
and the status of --infer-market-prices is shown.
2024-12-02 23:00:00 -10:00
Simon Michael
1ad9fbb4a8 imp:print: clean up special tags; show them more often with --verbose-tags
- These special hidden tags, used internally, have been renamed:
  - `_modified`           -> `_modified-transaction`
  - `_cost-matched`       -> `_cost-posting`
  - `_conversion-matched` -> `_conversion-posting`

- All special hidden tags now have a similarly-named visible tag,
  and `--verbose-tags` now shows those more often, which is useful
  when troubleshooting `--infer-equity`, `--infer-costs`,
  or the matching of redundant costs and conversion postings.

- The `generated-posting:` tag added by `--infer-equity` is now valueless.

- The `modified-transaction:` tag added by `--auto` now appears on its own line.
2024-11-16 14:40:03 -10:00
Simon Michael
9bf28b1b0e dev:posting*AsLines: fix some docs 2024-11-16 14:40:03 -10:00
Simon Michael
f57cd638da imp:print:beancount output: more robust account/commodity encoding
Unsupported chars are now hex-encoded, not just converted to dashes.
This helps keep account and commodity names unique, especially with
the equity conversion account names generated by --infer-equity when
using currency symbols.
(Those could also be converted to ISO 4217 codes, in theory, but
for now we just hex encode them, which is easier to make robust.)

Also, Beancount commodity symbols are no longer enclosed in
hledger-style double quotes.
2024-11-07 01:28:31 -10:00
Simon Michael
cbdbe0a855 dev: AmountFormat: add displayQuotes property to control enclosing quotes 2024-11-07 01:24:21 -10:00
Simon Michael
6adda683dc dev:Journal: cleanup 2024-11-02 18:29:15 -10:00
Simon Michael
326acbf93b imp: check recentassertions: try to make the error message clearer 2024-11-02 18:10:53 -10:00
Simon Michael
090f001eee imp:commodities: also list commodities mentioned in P directives [#2280] 2024-11-02 16:48:08 -10:00
Simon Michael
a58948c7a8 dev:Journal: cleanup, improve docs 2024-11-02 16:47:24 -10:00
Simon Michael
445e80fd41 dev:clarify: rename jcommodities to jdeclaredcommodities 2024-11-02 15:52:17 -10:00
Simon Michael
80fa7e2db6 dev:clarify: rename jinferredcommodities to jinferredcommoditystyles 2024-11-02 15:52:07 -10:00
Simon Michael
5e0a35b1da fix:journal:P directives: require a space after the symbol [#2280]
This prevents surprising parses, like
`P 2024-10-31 a0 1` parsed as `P 2024-10-31 a 01`.
2024-11-02 15:24:25 -10:00
Simon Michael
d6080c5ff1 imp: check commodities: also check commodities used in P directives [#2280] 2024-11-02 15:03:57 -10:00
Simon Michael
c66e901d8b dev: save the parse positions of PriceDirectives 2024-11-02 15:00:47 -10:00
Simon Michael
4d38c63ec8 dev: move/rename nullsourcepos 2024-11-02 14:59:43 -10:00
Simon Michael
5d2259d942 dev: Hledger.Utils.IO: cleanup 2024-11-02 12:59:44 -10:00
Simon Michael
1dabccfb46 dev: Hledger.Utils.IO: more cleanup 2024-11-02 12:51:53 -10:00
Simon Michael
4351304f06 dev: Hledger.Utils.IO: cleanup 2024-11-02 12:04:19 -10:00
Simon Michael
9c81bb2a06 dev: Hledger.Utils.IO colour helpers: cleanup 2024-11-02 11:54:28 -10:00
Simon Michael
75ff6c8218 ;cabal: update cabal files 2024-11-02 08:42:10 -10:00
Simon Michael
657fc1551f !fix: respect --color=yes in a few places that didn't; drop text-ansi dep
Hledger.Utils.IO's ansi style/color helpers now respect --color=yes,
so that eg `hledger --color=yes | less -R` shows bold headings as
you'd expect.

Hledger.Utils.IO.rgb' now takes Float arguments instead of Word8.
2024-11-01 10:40:25 -10:00
Simon Michael
234b4879c2 imp: less pager will use HLEDGER_LESS instead, if defined
When using `less` as pager, if HLEDGER_LESS is defined, it will
provide the options (instead of LESS + hledger's extra options).
You can set your own preferred options here, or you can set it
equal to LESS to use exactly those options.

[#2272]-related
2024-11-01 08:02:03 -10:00
Simon Michael
5bab9600e4 imp: simplify pager setup: just customise LESS, not MORE
[#2272]-related
2024-11-01 08:01:44 -10:00
Simon Michael
1011029356 imp: pager set extra LESS options for a nice experience when using less
Currently this sets a rather ambitious set of options,
and overrides the existing LESS:

  --chop-long-lines
  --hilite-unread
  --ignore-case
  --mouse
  --no-init
  --QUIT-AT-EOF
  --quit-if-one-screen
  --RAW-CONTROL-CHARS
  --squeeze-blank-lines
  --use-backslash
  --use-color
2024-10-31 19:13:39 -10:00
Simon Michael
30086ae249 imp: run pager more robustly; drop pager lib [#2272]
This fixes the error displayed when quitting the pager with long output.
It also replaces the pager lib with more robust homegrown pager utilities,
which should prevent a number of failure modes.
2024-10-31 18:55:09 -10:00
Simon Michael
659e493b30 ;doc: update changelogs 2024-10-30 19:01:49 -10:00
Simon Michael
50bf401ea6 dev: split debug/ghcdebug flags, comment out the latter for now
Compilation with ghc-debug is failing, and it has not yet been used
for anything. Separate the flag and leave it in place but commented for now.
2024-10-24 10:44:28 -10:00
Henning Thielemann
1a9bfcf5be cli: Commands.Aregister: implement --invert option 2024-10-23 21:55:24 -10:00
Henning Thielemann
3714ac0593 lib: Write.Ods.printFods: change type of number of fixed rows/columns from (Maybe Int) to Int
0 is a perfect value for no fixed row or column.
2024-10-22 12:05:42 -10:00
Simon Michael
d985e89bad imp: default V accounts become just E when a new V account is declared
The equity:conversion account, and its variations equity:trade(s) and equity:trading,
normally detected as V/Conversion type, now become ordinary E/Equity accounts
if some other account is declared as V/Conversion type.

This is motivated by the next commit, in which `check accounts` will
stop warning about conversion accounts and their subaccounts,
which means all of the above names and their subaccounts would remain
always exempt from strict account checking.

Now, if the user declares their own conversion account, those default
accounts will become controllable by account checking again.
Which at least reduces the allowlist a bit.

Hopefully this won't cause hassles.
2024-10-20 09:13:58 -10:00
Simon Michael
da11d74ae6 dev: refactor: clarify journalAccountTypes 2024-10-20 09:13:58 -10:00
Simon Michael
e44cbbf1a4 dev: refactor, clarify detection of cost/conversion postings 2024-10-20 09:13:58 -10:00
Simon Michael
2d90550e25 dev: cleanups 2024-10-20 09:13:58 -10:00
Henning Thielemann
4c189dde32 lib: Write.Spreadsheet.integerCell: for transaction indices 2024-10-20 08:49:36 -10:00
Simon Michael
f8cc9cdb4d ;dev: document runPager's behaviour precisely 2024-10-20 08:10:07 -10:00
Simon Michael
5bf48d721a cabal: update cabal files 2024-10-19 18:50:40 -10:00
Simon Michael
7325b75d5b imp: rename ghcdebug build flag to debug, and enable stack traces with it
Builds made with ghc 9.10+ and the 'debug' build flag, will show
(some kind of, partial) stack traces when the program ends with an
error. (And also will have ghc-debug support enabled.)

The stack traces will probably improve in due course.
2024-10-19 18:47:03 -10:00
Simon Michael
f5b10b2d40 dev: cleanups 2024-10-19 16:56:14 -10:00
Henning Thielemann
8b391e2a07 cli: Commands.Print: add export to FODS and HTML
use common Spreadsheet framework for CSV export, too
2024-10-19 16:52:54 -10:00
Simon Michael
b940254025 imp:cli: detect --color more safely in most cases
--color now also works in a config file, like --pager, except for two
cases: it does not affect colouring of debug output, or the colouring
helpers used in the check recentassertions error message.
2024-10-19 16:28:36 -10:00
Simon Michael
711d921774 imp:cli: --no-pager -> --pager, make this and --color safe options 2024-10-19 16:28:36 -10:00
Simon Michael
3e48451c3f imp: note unsafe args / config file limitation; make --no-pager safe 2024-10-19 16:28:36 -10:00
Simon Michael
ba786752d1 imp📟 add a --no-pager general flag 2024-10-19 16:28:36 -10:00
Simon Michael
db748465a8 fix📟 when the $PAGER is not in PATH, print instead of failing 2024-10-19 16:28:36 -10:00
Simon Michael
4441680d7b fix:lib:Hledger.Utils.IO.pager: avoid a crash; avoid an extra newline 2024-10-19 16:28:36 -10:00
Simon Michael
3b7420b97c feat: use a pager for all large terminal output, not just for help 2024-10-19 16:28:36 -10:00
Henning Thielemann
96e0500ea7 cli: Commands.Register.postingsReportItemAsRecord: format transaction index as integer
lib: Write.Spreadsheet.Type: new TypeInteger
2024-10-18 00:07:11 -10:00
Henning Thielemann
b23753f5ae cli: Commands.Register.postingsReportItemAsRecord: export amounts as number plus commodity
lib: Write.Spreadsheet.cellFromMixedAmount, cellsFromMixedAmount: taken from Cli.Balance
2024-10-18 00:07:11 -10:00
Henning Thielemann
d7b713f958 lib: Write.Ods.styleNames: common generation of ODS style names for both formatCell and cellConfig 2024-10-18 00:07:11 -10:00
Henning Thielemann
fe53b9b6ee lib: Write.Ods: disambiguate style names for DataMixedAmount and DataString (bugfix) 2024-10-18 00:07:11 -10:00
Henning Thielemann
991c56caef cli: Commands.Register.postingsReportAsSpreadsheet: generalize CSV output to HTML and FODS 2024-10-18 00:07:11 -10:00
Simon Michael
0f7aaa9600 imp: check accounts: simplify confusing suggestion in error message, 2 2024-10-16 21:19:51 -10:00
Simon Michael
1fa8b79640 ;doc: update manuals 2024-10-15 16:36:54 -10:00
Simon Michael
6bd5012b9b ;doc: changelogs 2024-10-15 16:36:54 -10:00
Simon Michael
36d1093b84 imp: check accounts: simplify confusing suggestion in error message 2024-10-15 16:36:54 -10:00
Henning Thielemann
9d1ba5c588 cli: CompoundBalanceCommand.compoundBalanceReportAsSpreadsheet: common function for CSV, HTML, FODS export 2024-10-14 20:59:51 -10:00
Simon Michael
71a7879213 fix:check tags: _price-matched -> _cost-matched, and whitelisted [#2247] 2024-10-14 14:49:18 -10:00
Henning Thielemann
b8497c830e lib: Write.Spreadsheet.headerCell, addRowSpanHeader, rawTableContent: taken from Commands.Balance 2024-10-14 11:35:12 -10:00
Simon Michael
2a374668e4 dev: Write.Beancount: isUpperCase -> isUpper to support ghc < 9.6 2024-10-14 11:02:21 -10:00
Simon Michael
aff3cd0591 imp:print:beancount: more robust conversion of commodity names 2024-10-11 14:56:03 -10:00
Simon Michael
4eff3ed8a0 ;cabal: update cabal files 2024-10-11 14:56:03 -10:00
Simon Michael
6dd9c92d32 lib: add Hledger.Data.Currency, currencySymbolToCode, currencyCodeToSymbol 2024-10-11 14:56:03 -10:00
Simon Michael
5f92fbd99a ;cabal: update cabal files 2024-10-10 23:25:07 -10:00
Simon Michael
66fce53c0b dev: extract beancount output helpers to Hledger.Write.Beancount 2024-10-10 23:25:07 -10:00
Simon Michael
21a84fb336 fix: calculate value correctly when P amounts have few decimal digits [#2254]
Valuation in another commoditay could sometimes be inaccurate if the P
price amounts did not have enough decimal places.
2024-10-08 23:11:57 -10:00
Simon Michael
4e6f6611a6 dev: fix DisplayName's off-by-one indent value, noted in #2246
Now displayIndent (and prrIndent) 0 means no indent, 1 means one
indent step, etc.
2024-10-08 23:11:57 -10:00
Simon Michael
6ce5e85e99 dev: clarify: rename displayDepth/prrDepth to displayIndent/prrIndent
These are about indentation for rendering, not account depth;
these are not always directly related, eg when boring parents are elided.
2024-10-08 23:11:57 -10:00
Simon Michael
8c71d071d7 imp:print:beancount:convert account names more robustly; better errors 2024-10-03 23:19:32 -10:00
Simon Michael
f54805a034 ;doc: update changelogs 2024-10-03 04:47:50 -10:00
Simon Michael
1c45496f1c dev: web: fix build with ghc <9.2 2024-09-30 17:20:13 -10:00
Simon Michael
e157bb4a6b dev: Hledger.Write.Ods: fix build with ghc <9.6 2024-09-30 17:20:13 -10:00
Simon Michael
6773e92361 dev: Hledger.Write.Ods: follow global-then-local-imports convention 2024-09-30 17:20:13 -10:00
Simon Michael
bb551bf0dc ;doc: update changelogs 2024-09-30 17:20:13 -10:00
Simon Michael
c92b601028 dev: fix warnings with ghc 9.10 / base 4.20
Older ghc versions should also still build cleanly (tested with 9.8 so far).

I don't like enabling CPP in so many modules but it's easier that
figuring out how to do it with base-compat; hopefully no noticeable
compilation impact.
2024-09-30 17:20:13 -10:00
Simon Michael
1b60ebb61f ;cabal: update cabal files 2024-09-30 17:20:13 -10:00
Simon Michael
6225ac8a22 imp!: support ghc 9.10 / base 4.20
When built with ghc 9.10.1, hledger error messages are displayed
with an extra newline following them.
https://gitlab.haskell.org/ghc/ghc/-/issues/25116
2024-09-30 17:15:59 -10:00
Simon Michael
cc7ba473ec imp: bal: html output will use a hledger.css file, like bs/cf/is 2024-09-29 21:22:38 -10:00
Henning Thielemann
5565f11c73 cli: Commands.Balance.multiBalanceReportAsSpreadsheetHelper: vertically merge cells showing account names and Total
lib: Write.Spreadsheet: add support for cell spans
2024-09-29 19:25:05 -10:00
Simon Michael
2cbea889f5 dev: lib: fix package.yaml, regen .cabal [#2244] 2024-09-29 13:27:51 -10:00
Henning Thielemann
2f9a8031b0 lib: Write.Html -> Write.Html.Lucid
Write.Html: keep common definitions for both HTML backends
2024-09-29 13:27:51 -10:00
Henning Thielemann
cc7e034d64 lib: Write.Html.Blaze: alternative to Lucid based export
for compatibility with hledger-web/yesod
2024-09-29 13:27:51 -10:00
Henning Thielemann
d8fc30f7c5 lib: Write.Html.Attribute.tableStyle: style definitions taken from Commands.Balance.multiBalanceReportAsHtml
avoid duplicate with Write.Html.printHtml

Write.Html.Attribute: remove dependency on Lucid
2024-09-29 13:27:51 -10:00
Henning Thielemann
499c626e48 lib: Write.Spreadsheet: support for anchors in HTML and FODS export
cli: Commands.Balance: new option --base-url
It adds hledger-web-compatible hyperlinks to account names.
2024-09-28 22:12:51 -10:00
Simon Michael
823be7c565 fix: csv: tags on following lines, and posting dates, also work now [#2241]
Follow-on work from #2214.
2024-09-28 18:54:43 -10:00
Simon Michael
b28468e651 dev: clarify some confusing comment parsers a bit [#2241] 2024-09-28 18:53:46 -10:00
Henning Thielemann
6ce6c72fd4 lib: Write.Html.Attributes: extracted HTML output helpers from Cli.Commands.Balance 2024-09-24 22:51:30 -10:00
Henning Thielemann
441f46fc06 lib: Tabular.AsciiWide.renderRs: simplify using flattenHeader 2024-09-24 20:50:54 -10:00
Simon Michael
9589941bb4 ;doc: update changelogs 2024-09-17 07:20:27 -07:00
Henning Thielemann
ff397f79cc lib: Write.Spreadsheet.Cell: add cellClass field for HTML style class
cmd: Commands.Balance.multiBalanceRowAsCellBuilders: add HTML style class attributes here
This way we do not need to dissect table rows in
multiBalanceReportHtmlHeadRow, multiBalanceReportHtmlBodyRow, multiBalanceReportHtmlFootRow
Eventually removed these three functions.
2024-09-11 13:51:09 -07:00
Henning Thielemann
55c1246598 cli: Commands.Balance.budgetReportAsSpreadsheet: also transpose border 2024-09-11 13:51:09 -07:00
Henning Thielemann
2ed13afed4 lib: Write.Spreadsheet: support for borders like in existing HTML export
cli: Commands.Balance: use for FODS export and balance and budget export to HTML
2024-09-11 13:51:09 -07:00
Simon Michael
30aeb662f2 doc: update manuals 2024-09-09 14:09:28 -07:00
Simon Michael
27e6eb0024 ;cabal: update cabal files 2024-09-09 14:06:06 -07:00
Simon Michael
c079725836 ;pkg: bump version to 1.40.99 2024-09-09 14:06:06 -07:00
Simon Michael
5cbbdb4670 imp: reg --sort: show supported keys in help and error message [#2211] 2024-09-09 14:04:43 -07:00
Simon Michael
3b73360584 ;doc: update changelogs 2024-09-09 14:04:43 -07:00
Simon Michael
dda3855ba2 ;cabal: update cabal files 2024-09-09 14:04:43 -07:00
Simon Michael
eaa494a4cb ;pkg: allow doclayout 0.5 2024-09-09 14:04:43 -07:00
Simon Michael
979c387663 ;doc: changelogs: 1.40 2024-09-09 14:04:08 -07:00
Michael Rees
e34fa491af Add abs implementation for MixedAmount 2024-09-05 11:56:07 +01:00
Michael Rees
52253c01f6 Add absamount as --sort field for register 2024-09-05 11:56:07 +01:00
Michael Rees
693360344c Add desc/description as possible sort field 2024-09-05 11:56:07 +01:00
Michael Rees
25bcf3eebb ;Don't apply sort spec when only sorting by date
If there is no sort spec given, then the postings are already sorted by
date, so there's no need to apply the default sort spec again.
2024-09-05 11:56:07 +01:00
Michael Rees
275c72b770 ; Use defsortspec everywhere instead of hard-coding default 2024-09-05 11:56:07 +01:00
Michael Rees
b429f57afb Show error message on conflicting --sort and -H 2024-09-05 11:56:07 +01:00
Michael Rees
b4a9f87fe4 Move SortSpec to Hledger.Reports.ReportOptions
As part of this migration, I also switched from using Data.List.splitOn
to Hledger.Utils.splitAtElement.
2024-09-05 11:56:07 +01:00
Michael Rees
00eb0aa16b feat: register: add --sort as in ledger 2024-09-05 11:56:07 +01:00
Simon Michael
3fbad1892d dev: rename some Intervals for clarity [#2218] 2024-09-04 16:07:54 +01:00
Simon Michael
038ebd8c7a fix: three more interval start date cases; add tests; cleanup [#2218] 2024-09-04 16:07:54 +01:00
Simon Michael
c8b6ca7b70 fix: 'every Nth day of month from DATE' start date [#2218] 2024-09-04 16:07:54 +01:00
Simon Michael
6fc117fa15 ;cabal: update cabal files [#2213] 2024-08-29 23:20:39 +01:00
Simon Michael
375fb07ede ;dev: cleanups 2024-08-29 10:07:02 +01:00
Henning Thielemann
3af8eb3bc6 cli: Command.Balance: use Date format for dates in LayoutTidy 2024-08-16 16:57:38 +02:00
Henning Thielemann
da61b64f94 cli: Command.Balance: support FODS export for multibalance
Data.Amount.showMixedAmountLinesPartsB: new helper function
2024-08-16 16:57:38 +02:00
Henning Thielemann
66a047aade lib: Write.Spreadsheet.Cell: add type parameter for the text type
instance Functor Cell
This way you can choose between Text, Lazy.Text, WideBuilder for cell content.
2024-08-16 16:57:38 +02:00
Henning Thielemann
f306df6d61 imp: lib: Write.Html: use Lucid to generate HTML 2024-08-16 16:57:38 +02:00
Henning Thielemann
8c42a735c2 cli: lib: Write.Spreadsheet: common data types for Write.Ods and Write.Html
Write.Html: write spreadsheet data to a HTML table

enables HTML export for the balance command
2024-08-16 16:57:38 +02:00
Henning Thielemann
29b67691fb cli: Write.Ods: also use a number cell if the total amount has a single commodity 2024-08-16 16:57:38 +02:00
Henning Thielemann
2a1f3920c6 lib: Write.Ods.escape: escape cell contents 2024-08-16 16:57:38 +02:00
Henning Thielemann
ba0db5feec cli: Write.Ods: write single amounts as numbers with units
This way you can do computations with the numbers in LibreOffice Calc.
2024-08-16 16:57:38 +02:00
Henning Thielemann
7b136600fa cli: Cli.Balance.balanceReportAsFods: use distinguished cell formatting styles 2024-08-16 16:57:38 +02:00
Henning Thielemann
0e158d0c3e cli: lib: Hledger.Write.Ods: basic support for FODS export
used in Commands.Balance
2024-08-16 16:57:38 +02:00
Henning Thielemann
14b5a1f82a imp: Hledger.Read.CsvUtils -> Write.Csv 2024-08-16 16:57:38 +02:00
Simon Michael
d19b353bfb imp: improve bad regexp error message
Eg '(?:foo)' is not malformed, it's just not supported.
https://hledger.org/hledger.html#hledgers-regular-expressions
2024-07-24 11:06:13 +01:00
Simon Michael
4b3abfd470 ;imp: check: recentassertions: improve message readability 2024-07-16 22:12:41 +01:00
Simon Michael
40620666f8 imp: cli: rename --rules-file to --rules; tweak options help
For brevity, and consistency with --conf.
--rules-file remains supported, as a hidden option.

hledger's main mode now supports the hidden legacy flags,
as the command modes do.
2024-06-25 18:37:55 +01:00
Simon Michael
969b5a89d1 dev: comment parsing tests/refactoring, fix indented timedot comments 2024-06-25 18:37:54 +01:00
Simon Michael
713c3f4067 imp: TimedotReader: trace parsing at debug level 9 2024-06-25 18:37:54 +01:00
Simon Michael
6b24c09a58 feat: config file: ignore unsupported general options; refactor 2024-06-25 18:37:54 +01:00
Simon Michael
e1991be46f feat: config file: add a real parser, support command-specific options 2024-06-25 18:37:54 +01:00
Simon Michael
4175dc50ac ;cabal: update cabal files 2024-06-25 18:37:54 +01:00
Simon Michael
f5c2ec681c dev: refactor: merge Text.Megaparsec.Custom into Hledger.Utils.Parse 2024-06-25 18:37:54 +01:00
Simon Michael
07a4b21620 dev: refactor: move emptyorcommentlinep'; hlint 2024-06-25 18:37:54 +01:00
Simon Michael
6c47fa034a ;dev: update doctests for weekly headings change [#2204] 2024-06-25 18:36:43 +01:00
Simon Michael
49c4ccd0b7 dev: Hledger.Utils.IO: fix hlint warnings 2024-06-25 07:45:27 +01:00
Victor Mihalache
60efd035f5 imp: abbreviate week naming for weekly reports 2024-06-14 09:37:32 +01:00
Simon Michael
1a242c1264 dev: refactor table rendering code
- Consolidate some table rendering helpers in Balance.hs
- Rename, document for clarity
- Extract parameters for controlling table borders
- hlint suggestions
2024-06-12 05:01:48 +01:00
Simon Michael
5b83e5c2f0 ;dev: cleanup [#2202] 2024-06-10 08:46:19 +01:00
Simon Michael
e89bea8563 fix: handle account type declarations in multiple files correctly [#2202]
Tags and types declared in account directives in sibling files or
included files are now combined more carefully.

In particular, when merging two Journals into one,

- jdeclaredaccounttags and jdeclaredaccounttypes no longer lose information;
  any duplicated/conflicting tag/type values are preserved.

- jaccounttypes now prefers the last type declared in case of
  conflict, not the first.
2024-06-10 08:32:54 +01:00
Simon Michael
8d1ad8a3fe lib: add journalDbg, for inspecting Journal fields 2024-06-10 08:26:58 +01:00
Simon Michael
0ccfc78844 ;dev: cleanup 2024-06-07 06:32:52 -07:00
Simon Michael
4f0e07d024 ;doc: changelogs: bump to latest commit 2024-06-01 14:14:24 -10:00
Simon Michael
8f24fad909 ;doc: merge 1.34 release docs 2024-06-01 14:13:57 -10:00
Simon Michael
3f3672e999 ;doc: update manuals 2024-06-01 13:30:47 -10:00
Simon Michael
d18c00e1ec ;cabal: update cabal files 2024-06-01 13:30:21 -10:00
Simon Michael
aec28842c7 ;pkg: bump version to 1.34.99 2024-06-01 13:30:20 -10:00
Simon Michael
152b20413c doc: update manuals 2024-05-29 15:32:19 -10:00
Simon Michael
1fe7e7af8c imp: cli: --color now also accepts y or n, like --pretty 2024-05-29 09:37:20 -10:00
Simon Michael
605f8446e5 fix:pkg: fix a doctest failure with ghc 8.10 2024-05-17 15:08:26 -10:00
Simon Michael
e0f017f544 ;dev: journalFinalise: doc update 2024-05-08 12:40:06 -10:00
Simon Michael
d817254290 ;doc: update changelogs 2024-05-07 16:45:21 -10:00
Simon Michael
b7e5c05da2 imp: -I can now be overridden by -s or the check command
This enables a "relaxed" workflow where you delay balance assertions
checking until strict mode is turned on: always run hledger -I, and
add -s when you're ready.
2024-05-07 15:44:06 -10:00
Simon Michael
243a96b656 dev: clarify how readJournalFiles defers checks, and use a dedicated flag 2024-05-02 21:36:32 -10:00
Simon Michael
ea58a7ccd7 imp: check: check ordereddates before balance assertions, when both are enabled 2024-05-02 21:11:04 -10:00
Simon Michael
490a46fcd2 fix: journal: parse include directives with trailing whitespace
[https://github.com/adept/full-fledged-hledger/issues/29]
2024-05-02 07:26:12 -10:00
Simon Michael
2a659e18db ;doc: changelogs: 1.33.1 2024-05-02 00:46:15 -10:00
Simon Michael
02e242c9b1 ;doc: update changelogs 2024-05-01 23:23:37 -10:00
Simon Michael
7525014c7d ;cabal: update cabal files 2024-05-01 23:04:18 -10:00
Simon Michael
8d62af8ae0 imp: Revert problematic process-1.6.19.0 bound, it seems not strictly needed [#2149] 2024-05-01 23:04:08 -10:00
Simon Michael
929f050c43 ;cabal: update cabal files 2024-05-01 16:21:13 -10:00
Simon Michael
96caa8f352 fix: detect ghc-debug support more accurately, checking hledger-lib also 2024-05-01 15:27:42 -10:00
Simon Michael
6796decb72 fix: show trailing decimal mark on cost amounts too, when needed 2024-05-01 14:17:46 -10:00
Simon Michael
d17b32c7eb imp: cli,ui,web: support ghc-debug for analysing memory/profile info
When built with the ghcdebug flag and started with --debug=-1 (or -2
to pause at startup, or -3 to pause before exit), hledger can be
controlled by ghc-debug clients like ghc-debug-brick or a custom
ghc-debug query script.

Also, refactor version string code.
2024-05-01 13:43:04 -10:00
Simon Michael
55401282a0 imp: run checks in a well-defined order; and tweak that order
Now commodities are checked before accounts, and tags before recentassertions.
Also some check doc cleanups.
2024-04-26 18:59:45 -10:00
Simon Michael
4cbf72ab1f imp!: check ordereddates: drop --date2 support; check primary dates only
date2 is a deprecated feature and was getting in the way, so has been dropped
from the ordereddates check, simplifying it.
2024-04-26 18:59:45 -10:00
Simon Michael
afe9e2c6f4 dev: move journalCheckBalanceAssertions to JournalChecks 2024-04-26 18:59:45 -10:00
Simon Michael
1c5fd0c6a3 ;doc: update changelogs 2024-04-26 17:09:17 -10:00
Simon Michael
27d5f14553 ;doc: changelogs: 1.33: fix issue links (using md-issue-refs.el) 2024-04-22 15:58:05 -10:00
Simon Michael
4ae62a1833 ;doc: update manuals 2024-04-18 13:35:28 -10:00
Simon Michael
f59cb5ff3c ;cabal: update cabal files 2024-04-18 13:33:43 -10:00
Simon Michael
f5c4d99291 ;pkg: bump version to 1.33.99 2024-04-18 13:33:42 -10:00
Simon Michael
9651082fde ;doc: bump release date to 4/18 2024-04-18 13:20:12 -10:00
Simon Michael
997653e3b9 ;doc: changelogs: 1.33 2024-04-18 13:19:34 -10:00
Simon Michael
dc8eedc16b ;cabal: update cabal files 2024-04-11 11:15:41 -10:00
Simon Michael
e4cbd88367 ;pkg:lib: disable doctests for now to allow use of process-1.6.19.0 2024-04-11 11:14:46 -10:00
Simon Michael
d3634cf4dd dev: update failng doctests 2024-04-08 00:08:48 -10:00
Simon Michael
5be3ee9e20 imp: disallow date: in expr: OR expressions, avoiding unclear semantics [#2177][#2178] 2024-04-07 23:37:28 -10:00
Simon Michael
f982a372d9 dev: matchedPostingsBeforeAndDuring: improve debug output 2024-04-07 23:14:28 -10:00
Simon Michael
06ef6de242 dev:parseBooleanQuery: refactor 2024-04-07 22:48:25 -10:00
Simon Michael
1d3e6b5543 dev:parseBooleanQuery: refactor, clarifying helper dependencies 2024-04-07 21:53:03 -10:00
Simon Michael
fae6e49407 imp: simpler, clearer date parse error messages
When the error message repeated the invalid date at the end,
it was possible to misinterpret that as a suggested fix (reported in chat).

Instead, date errors (most of them) now rely on the highlighted data
excerpt above. This is also preferable since it shows the original
date as written, not a reconstruction with a possibly different format.

Should this be the policy for all error messages going forward ?
It would be easier.
Can we assume the data excerpt is always visible along with the error message ?
It isn't shown by flycheck-hledger in emacs, eg.
2024-03-26 10:05:57 -10:00
Simon Michael
76f98f28fd ;doc: update manuals 2024-03-24 14:22:54 -10:00
aragaer
09e158d31e fix: Fill totals with correct amount of zeroes for empty reports 2024-03-17 10:52:53 -10:00
Dmitry Astapov
b0b9e69e4f ;dev:lib allow comment lines in the "if" table body 2024-03-08 07:42:58 -10:00
Simon Michael
169198ff55
Merge branch 'master' into fix-matchgroups 2024-03-02 12:15:52 -10:00
Jonathan Dowland
3b416a76ef ;cln:import: clarify haddock for getEffectiveAssignment
Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-03-02 20:56:35 +00:00
Simon Michael
3ca208a3b6 fix:queries: fix OR-ing open-ended dates, spanUnion; add spanExtend [#2177] 2024-03-01 18:10:24 -10:00
Jonathan Dowland
c5079d4f1e dev:import: call hledgerFieldValue rather than re-implementing it
Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-03-01 18:02:29 +00:00
Jonathan Dowland
1424a1f2f1 ;cln:import: update some Haddock strings to reflect #2158
Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-03-01 17:58:28 +00:00
Simon Michael
1ee0e80719 imp:errors:unbalanced transaction: show more precise amounts (#2135)
Like we used to in 1.30, but better (show all available decimal digits,
unless they're infinite in which case show 8, show trailing zeros,
show commodity symbol with zero).
2024-02-29 12:34:17 -10:00
Simon Michael
3ec432bd53 dev: rename/improve amountSetFullPrecisionUpTo, add mixedAmountSetFullPrecisionUpTo 2024-02-29 12:31:07 -10:00
Jonathan Dowland
71684f5611 ref:import: simplify renderTemplate and friends
renderTemplate and its ancillary functions did not need the
HledgerFieldName argument, so remove it.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-02-29 21:44:42 +00:00
Jonathan Dowland
b7027c8bbb feat:import: resolve matchgroup references in ConditionalBlock scope (#2158)
Adjust getEffectiveAssignment to compute an intermediary form of the
active assignments (with an additional Either wrapper to distinguish
top-level and conditional assignments) and move the remaining work to
its only caller, hledgerField.

Rework hledgerFieldValue. Instead of calling hledgerField, call
getEffectiveAssignment and--in the conditional block case--construct
a CsvRules scoped just to the active ConditionalBlock before calling
renderTemplate.

Adjust regexMatchValue to use rconditionalblocks to access conditional
blocks from the CsvRules, rather than rblocksassigning, since we haven't
narrowed the scope of that field.

The result is match group references are only expanded for match groups
that occur within the in-scope ConditionalBlock. Fixes: #2158.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-02-29 21:44:40 +00:00
Jonathan Dowland
ac7f726282 ;ref:import: consistently use hledgerField
hledgerField is an alias to the function getEffectiveAssignment: both
names are used in various parts of RulesReader.

Treat hledgerField as the canonical name, and getEffectiveAssignment
as an implementation detail of hledgerField.

Replace all uses of getEffectiveAssignment with hledgerField (except the
one in hledgerField.)

Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-02-29 21:44:39 +00:00
Jonathan Dowland
8f514ac16d ;test:import: test case for match groups (#2158)
Add a test which captures the issue of overlapping scope described
in GitHub issue #2158.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-02-29 21:44:36 +00:00
Jonathan Dowland
bd5652c1c2 ;cln:import: remove superfluous comment lines
Signed-off-by: Jonathan Dowland <jon@dow.land>
2024-02-29 21:44:32 +00:00
Simon Michael
8f1ae401f4 dev: fix some partial head/tails, silence ghc 9.8's new warnings
Note the headErr/tailErr calls will print stack traces if they fail
(small ones: five lines, one of which is the useful location info),
which may or may not be best UX.
2024-02-28 15:58:21 -10:00
Simon Michael
697e5a5671 ;cabal: update cabal files 2024-02-28 15:34:11 -10:00
Simon Michael
3798a3baef pkg: require safe >=0.3.20, for ghc 9.8 head/tail helpers 2024-02-28 14:39:53 -10:00
Simon Michael
fac3ee89af feat:allow other kinds of unicode space as digit group separators
Based on feedback in chat, I added support for several more kinds of
Unicode space character for separating digit groups, both when reading
and when displaying numbers. These are the spaces currently supported,
which are just my best guess at the ones that might show up in CSV files
now and then:

space,
no-break space,
en space,
em space,
punctuation space,
thin space,
narrow no-break space,
medium mathematical space
2024-02-28 09:12:17 -10:00