Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate conversion postings for priced amounts. #1554

Merged
merged 2 commits into from
Dec 21, 2021

Conversation

Xitian9
Copy link
Collaborator

@Xitian9 Xitian9 commented May 4, 2021

A potential implementation of the proposals in #1177. This is almost certainly not the final behaviour, but I'm putting this up to solicit feedback on a solid proposal. Let me know your thoughts!

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 not converting to cost, this is now treated as:

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

@Xitian9 Xitian9 force-pushed the priceconversion branch 8 times, most recently from dcf3189 to 4bd42c9 Compare May 6, 2021 06:08
@Xitian9 Xitian9 mentioned this pull request May 7, 2021
@simonmichael simonmichael added the needs:review To unblock: needs more code/docs/design review by someone label May 15, 2021
@Xitian9 Xitian9 force-pushed the priceconversion branch 2 times, most recently from 5c02f12 to d338e79 Compare June 4, 2021 10:29
@Xitian9 Xitian9 marked this pull request as ready for review June 8, 2021 14:34
@Xitian9 Xitian9 force-pushed the priceconversion branch 3 times, most recently from e57b1c4 to 4173241 Compare June 9, 2021 02:12
@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. journal The journal file format, and its features. labels Jul 1, 2021
@Xitian9 Xitian9 force-pushed the priceconversion branch 2 times, most recently from f843436 to de77ce2 Compare July 6, 2021 00:45
@simonmichael simonmichael force-pushed the master branch 7 times, most recently from 495727d to 56bc295 Compare July 11, 2021 09:16
@Xitian9
Copy link
Collaborator Author

Xitian9 commented Sep 28, 2021

Showing conversion postings with --explicit seems reasonable too, but if we have a separate flag we probably want to keep those orthogonal.

@Xitian9
Copy link
Collaborator Author

Xitian9 commented Nov 14, 2021

We used to have just two cost modes – Cost and NoCost – in which case a flag was sufficient. We now have three – Cost, NoCost, and ConversionCost. The flag --cost will still access Cost mode, but there is no way to select between NoCost and ConversionCost. NoCost is used by print and close and ConversionCost is used by all other commands. I think we need more fine-grained control, for example --cost=cost/--cost, --cost=conversion, or --cost=nocost.

Any thoughts on this proposal?

@simonmichael
Copy link
Owner

I think it needs draft docs ? That would help me assess it.

@Xitian9
Copy link
Collaborator Author

Xitian9 commented Nov 25, 2021

I've added the enhanced --cost option, some tests, and docs in a new commit. Let me know what you think.

@simonmichael
Copy link
Owner

Maybe this would be better as a separate flag ? I think it's not variations of how to calculate cost, but rather a choice of whether to generate and show conversion postings, independent of whether reporting cost or not ?

@simonmichael
Copy link
Owner

simonmichael commented Nov 26, 2021

From trying to write feedback, I see this is a complex topic, such that I think we need to flesh out the specification/draft doc, here on this issue because #1177 is huge. Apologies if I have forgotten past discussion/context. It looks like my last coherent thoughts on this were here. Am I right in thinking this PR is aimed at the second bullet point ("Let's implement conversion rate inference from a balanced @-free transaction - it seems possible and would allow -B and --infer-value to work without the need for @ notation") ?

@simonmichael
Copy link
Owner

No, I think that was not right; this PR doesn't address that bullet point.

Instead I think it aims to help people who are using @ notation, or implicit @ (autoconversion), to produce reports where the equity balance is correct and the accounting equation can balance (by generating the required equity postings where they are missing).

Would that be accurate ? Let's nail down

Goals:
User-visible changes:
Impact/compatibility:
Interactions:

@Xitian9
Copy link
Collaborator Author

Xitian9 commented Nov 26, 2021

Instead I think it aims to help people who are using @ notation, or implicit @ (autoconversion), to produce reports where the equity balance is correct and the accounting equation can balance (by generating the required equity postings where they are missing).

Would that be accurate ?

Yes, that's correct. Current behaviour without -B/--cost will generate unbalanced postings; this automatically generates equity postings so that @/@@ transactions are balanced.

Let's nail down

Goals: User-visible changes: Impact/compatibility: Interactions:

Goals:

  • Transactions involving transaction prices can be balanced (preferably by default or by explicit choice)
  • Users can continue to get previous --cost behaviour if desired
  • Users can get previous unbalanced transactions if desired (for simplicity)

Impact/compatibility:

  • If default behaviour is changed then there will be extra postings generated. They will be in special equity accounts, so this should cause minimal interference.
  • If default behaviour is not changed, then there should be no noticeable effect without explicitly calling for it.

Interactions:

  • None currently seen, as we have to deal with costing anyway. Perhaps some weird interaction with --gain that I'm not thinking of.

@Xitian9
Copy link
Collaborator Author

Xitian9 commented Nov 26, 2021

Maybe this would be better as a separate flag ? I think it's not variations of how to calculate cost, but rather a choice of whether to generate and show conversion postings, independent of whether reporting cost or not ?

I think this is not quite correct. If we're reporting cost, then generating conversion postings will make transactions unbalanced, exactly the problem we were trying to avoid.

I think the following are things that could (conceivably) be done:

2021-11-26  Test
    assets:stock    1 stock @ 1 EUR
    assets:cash    -1 EUR
  1. Do not use transaction cost. Currently the default. This creates unbalanced transactions.
$ hledger register
2021-11-26 Test                 assets:stock               1 stock       1 stock
                                assets:cash                 -1 EUR        -1 EUR
                                                                         1 stock

$ hledger print
2021-11-26 Test
    assets:stock    1 stock @ 1 EUR
    assets:cash              -1 EUR
  1. Do not use transaction cost, and generate conversion postings. The above, but transactions are balanced.
$ hledger register
2021-11-26 Test                 assets:stock               1 stock       1 stock
                                eq:co:stock:EUR           -1 stock             0
                                eq:co:EUR:stock              1 EUR         1 EUR
                                assets:cash                 -1 EUR             0

$ hledger print
2021-11-26 Test
    assets:stock                        1 stock
    equity:conversion:stock:EUR        -1 stock  ; generated-posting:
    equity:conversion:EUR:stock           1 EUR  ; generated-posting:
    assets:cash                          -1 EUR
  1. Use transaction cost. Currently available with --cost. This creates balanced transactions.
$ hledger register
2021-11-26 Test                 assets:stock                 1 EUR         1 EUR
                                assets:cash                 -1 EUR             0

$ hledger print
2021-11-26 Test
    assets:stock           1 EUR
    assets:cash           -1 EUR
  1. Use transaction cost, but generate conversion postings. This creates unbalanced transactions. An affront to nature. Begs for death.
$ hledger register
2021-11-26 Test                 assets:stock               1 EUR       1 EUR
                                eq:co:stock:EUR         -1 stock       1 EUR
                                                                    -1 stock
                                eq:co:EUR:stock            1 EUR       2 EUR
                                                                    -1 stock
                                assets:cash               -1 EUR       1 EUR
                                                                    -1 stock

$ hledger print
2021-11-26 Test
    assets:stock                          1 EUR
    equity:conversion:stock:EUR        -1 stock  ; generated-posting:
    equity:conversion:EUR:stock           1 EUR  ; generated-posting:
    assets:cash                          -1 EUR

The way I see it, 2 and 3 make the most sense. 2 should be default, 3 is a common need. 1 makes sense for the print command, and since it's both simpler and longstanding default should be maintained for those who want it. 4 does not make sense.

@simonmichael simonmichael removed needs:review To unblock: needs more code/docs/design review by someone needs:design To unblock: needs more thought/planning, leading to a spec/plan labels Nov 27, 2021
@simonmichael
Copy link
Owner

I have posted an attempted summary of this proposal, with some open questions, at https://hledger.org/conversion2.html#xitians-1554 .

…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.
@simonmichael simonmichael merged commit 82cd81c into simonmichael:master Dec 21, 2021
@simonmichael
Copy link
Owner

See #hledger chat log for much other discussion. Now in master - thanks a lot @Xitian9 !

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 24, 2023
* hledger 1.28 2022-12-01

Features

- The `accounts` command has new flags: `--undeclared` (show accounts used but not declared), `--unused` (show accounts declared but not used),  and `--find` (find the first account matched by the first command argument, a convenience for scripts). Also `-u` and `-d` short flags have been added for `--used` and `--declared`.

- A new CSV rule `intra-day-reversed` helps generate transactions in correct order with CSVs where records are reversed within each day.

- CSV rules can now correctly convert CSV date-times with a implicit or explicit timezone to dates in your local timezone. Previously, CSV date-times with a different time zone from yours could convert to off-by-one
  dates, because the CSV's timezone was ignored.
  Now,

  1. When a CSV has date-times with an implicit timezone different from yours, you can use the `timezone` rule to declare it.

  2. CSV date-times with a known timezone (either declared by `timezone` or parsed with `%Z`) will be localised to the system timezone
     (or to the timezone set with the `TZ` environment variable).

  (#1936)

Improvements

- print --match now respects -o and -O.

- print --match now returns a non-zero exit code when there is no acceptable match.

- Support megaparsec 9.3. (Felix Yan)

- Support GHC 9.4.

Fixes

- In CSV rules, when assigning a parenthesised account name to   `accountN`, extra whitespace is now ignored, allowing unbalanced postings to be detected correctly.

Scripts/addons

- bin/hledger-move helps record transfers involving subaccounts and costs,
  eg when withdrawing some or all of an investment balance containing many lots and costs.

- bin/hledger-git no longer uses the non-existent git record command.
  (#1942) (Patrick Fiaux)

- bin/watchaccounts is a small shell script for watching the account tree as you make changes.

* hledger 1.27.1 2022-09-18

Fixes

- Balance commands using `-T -O html` no longer fail with an error
  when there is no data to report.
  (#1933)

* hledger 1.27 2022-09-01

Features

- `hledger check recentassertions` (and flycheck-hledger in Emacs if
  you enable this check) requires that all balance-asserted accounts
  have a balance assertion within 7 days before their latest posting.

  This helps remind you to not only record transactions, but also to
  regularly check account balances against the real world, to catch
  errors sooner and avoid a time-consuming hunt.

- The --infer-costs general flag has been added, as the inverse
  operation to --infer-equity.  --infer-costs detects commodity
  conversion transactions which have been written with equity
  conversion postings (the traditional accounting notation) and adds
  PTA cost notation (@@) to them (allowing cost reporting).
  See https://hledger.org/hledger.html#equity-conversion-postings .
  (Stephen Morgan)

Improvements

- Many error messages have been improved. Most error messages now use
  a consistent, more informative format.
  (#1436)

- The accounts command has a new --directives flag which makes it
  show valid account directives which you can paste into a journal.

- The accounts command has a new --positions flag which shows where
  accounts were declared, useful for troubleshooting.
  (#1909)

- Bump lower bounds for Diff and githash. (Andrew Lelechenko)

- GHC 8.6 and 8.8 are no longer supported. Building hledger now
  requires GHC 8.10 or greater.

Fixes

- Account display order is now calculated correctly even when accounts
  are declared in multiple files.
  (#1909)

- At --debug 5 and up, account declarations info is logged.
  (#1909)

- hledger aregister and hledger-ui now show transactions correctly
  when there is a type: query.
  (#1905)

- bal: Allow cumulative gain and valuechange reports.
  Previously, --cumulative with --gain or --valuechange would produce an
  empty report. This fixes this issue to produce a reasonable report.
  (Stephen Morgan)

- bal: budget goal amounts now respect -c styles (fixes #1907)

- bal: budget goals now respect -H (#1879)

- bal: budget goals were ignoring rule-specified start date

- cf/bs/is: Fixed non-display of child accounts when there is an
  intervening account of another type.
  (#1921) (Stephen Morgan)

- roi: make sure empty cashflows are skipped when determining first cashflow (Charlotte Van Petegem)
  Empty cashflows are added when the begin date of the report is before the first
  transaction.

Scripts/addons

- https://hledger.org/scripts.html - an overview of scripts and addons in bin/.

- paypaljson, paypaljson2csv - download txns from paypal API

- hledger-check-postable.hs - check that no postings are made to accounts with a postable:(n|no) tag

- hledger-addon-example.hs - script template

* hledger 1.26.1 2022-07-11

- require safe 0.3.19+ to avoid deprecation warning

* hledger 1.26 2022-06-04

Improvements

- `register` and `aregister` have been made faster, by

  - considering only the first 1000 items for choosing column
    widths. You can restore the old behaviour (guaranteed alignment
    across all items) with the new `--align-all` flag.
    ([#1839](simonmichael/hledger#1839), Stephen Morgan)

  - discarding cost data more aggressively, giving big speedups for
    large journals with many costs.
  	([#1828](simonmichael/hledger#1828), Stephen Morgan)

- Most error messages from the journal reader and the `check` command now use
  a consistent layout, with an "Error:" prefix, line and column numbers,
  and an excerpt highlighting the problem. Work in progress.
  ([#1436](simonmichael/hledger#1436)) (Simon Michael, Stephen Morgan)

- `hledger check ordereddates` now always checks all transactions
  (previously it could be restricted by query arguments).

- The `--pivot` option now supports a `status` argument, to pivot on transaction status.

- Update bash completions (Jakob Schöttl)

Fixes

- Value reports with `--date2` and a report interval (like `hledger bal -VM --date2`)
  were failing with a "expected all spans to have an end date" error since 1.22;
  this is now fixed.
  ([#1851](simonmichael/hledger#1851), Stephen Morgan)

- In CSV rules, interpolation of a non-existent field like `%999` or `%nosuchfield`
  is now ignored (previously it inserted that literal text).
  Note this means such an error will not be reported;
  Simon chose this as the more convenient behaviour when converting CSV.
  Experimental.
  ([#1803](simonmichael/hledger#1803), [#1814](simonmichael/hledger#1814)) (Stephen Morgan)

- `--infer-market-price` was inferring a negative price when selling.
  ([#1813](simonmichael/hledger#1813), Stephen Morgan)

- Allow an escaped forward slash in regular expression account aliases.
  ([#982](simonmichael/hledger#982), Stephen Morgan)

- The `tags` command now also lists tags from unused account declarations.
  It also has improved command-line help layout.
  ([#1857](simonmichael/hledger#1857))

- `hledger accounts` now shows its debug output at a more appropriate level (4).

* hledger 1.25 2022-03-04

Breaking changes

- Journal format's `account NAME  TYPECODE` syntax, deprecated in 1.13, has been dropped.
  Please use `account NAME  ; type:TYPECODE` instead.
  (Stephen Morgan)

- The rule for auto-detecting "cash" (liquid asset) accounts in the `cashflow` report
  has changed: it's now "all accounts under a top-level `asset` account, with
  `cash`, `bank`, `checking` or `saving` in their name" (case insensitive, variations allowed).
  So if you see a change in your `cashflow` reports, you might need to add
  `account` directives with `type:C` tags, declaring your top-most cash accounts.

Features

- The new `type:TYPECODES` query matches accounts by their accounting type.
  Account types are declared with a `type:` tag in account directives,
  or inferred from common english account names, or inherited from parent accounts,
  as described at [Declaring accounts > Account types].
  This generalises the account type detection of `balancesheet`, `incomestatement` etc.,
  so you can now select accounts by type without needing fragile account name regexps.
  Also, the `accounts` command has a new `--types` flag to show account types.
  Eg:

      hledger bal type:AL  # balance report showing assets and liabilities
      hledger reg type:x   # register of all expenses
      hledger acc --types  # list accounts and their types

  ([#1820](simonmichael/hledger#1820),
  [#1822](simonmichael/hledger#1822))
  (Simon Michael, Stephen Morgan)

- The `tag:` query can now also match account tags, as defined in account directives.
  Subaccounts inherit tags from their parents.
  Accounts, postings and transactions can be filtered by account tag.
  ([#1817](simonmichael/hledger#1817))

- The new `--infer-equity` flag replaces the `@`/`@@` price notation in commodity
  conversion transactions with more correct equity postings (when not using `-B/--cost`).
  This makes these transactions fully balanced, and preserves the accounting equation.
  For example:

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

      $ hledger print --infer-equity
      2000-01-01
        a                               1 AAA
        equity:conversion:AAA-BBB:AAA  -1 AAA
        equity:conversion:AAA-BBB:BBB   2 BBB
        b                              -2 BBB

  `equity:conversion` is the account used by default. To use a different account,
  declare it with an account directive and the new `V` (`Conversion`) account type.
  Eg:

      account Equity:Trading    ; type:V

  ([#1554](simonmichael/hledger#1554)) (Stephen Morgan, Simon Michael)

- Balance commands (`bal`, `bs` etc.) can now generate easy-to-process "tidy" CSV data
  with `-O csv --layout tidy`.
  In tidy data, every variable is a column and each row represents a single data point
  (cf <https://vita.had.co.nz/papers/tidy-data.html>).
  ([#1768](simonmichael/hledger#1768),
  [#1773](simonmichael/hledger#1773),
  [#1775](simonmichael/hledger#1775))
  (Stephen Morgan)

Improvements

- Strict mode (`-s/--strict`) now also checks periodic transactions (`--forecast`)
  and auto postings (`--auto`).
  ([#1810](simonmichael/hledger#1810)) (Stephen Morgan)

- `hledger check commodities` now always accepts zero amounts which have no commodity symbol.
  ([#1767](simonmichael/hledger#1767)) (Stephen Morgan)

- Relative [smart dates](hledger.html#smart-dates) may now specify an arbitrary number of some period into the future or past).
  Some examples:
  - `in 5 days`
  - `in -6 months`
  - `5 weeks ahead`
  - `2 quarters ago`

  (Stephen Morgan)

- CSV output now always disables digit group marks (eg, thousands separators),
  making it more machine readable by default.
  ([#1771](simonmichael/hledger#1771)) (Stephen Morgan)

- Unicode may now be used in field names/references in CSV rules files.
  ([#1809](simonmichael/hledger#1809)) (Stephen Morgan)

- Error messages improved:
  - Balance assignments
  - aregister
  - Command line parsing (less "user error")

Fixes

- `--layout=bare` no longer shows a commodity symbol for zero amounts.
  ([#1789](simonmichael/hledger#1789)) (Stephen Morgan)

- `balance --budget` no longer elides boring parents of unbudgeted accounts
  if they have a budget.
  ([#1800](simonmichael/hledger#1800)) (Stephen Morgan)

- `roi` now reports TWR correctly

  - when there are several PnL changes occurring on a single day
  - and also when investment is fully sold/withdrawn/discounted at the end of a particular reporting period.

  ([#1791](simonmichael/hledger#1791)) (Dmitry Astapov)

Documentation

- There is a new CONVERSION & COST section, replacing COSTING.
  ([#1554](simonmichael/hledger#1554))

- Some problematic interactions of account aliases with other features have been noted.
  ([#1788](simonmichael/hledger#1788))

- Updated: [Declaring accounts > Account types](https://hledger.org/hledger.html#account-types)

* hledger-lib 1.28 2022-12-01

- Hledger.Utils.Debug's debug logging helpers have been unified.
  The "trace or log" functions log to stderr by default, or to a file
  if ",logging" is appended to the program name (using withProgName).
  The debug log file is PROGNAME.log (changed from debug.log).

- Moved from Hledger.Utils.Debug to Hledger.Utils.Parse:
  traceParse
  traceParseAt
  dbgparse

- Moved from Hledger.Utils.Debug to Hledger.Utils.Print:
  pshow
  pshow'
  pprint
  pprint'
  colorOption
  useColorOnStdout
  useColorOnStderr
  outputFileOption
  hasOutputFile

- Rename Hledger.Utils.Print -> Hledger.Utils.IO, consolidate utils there.

- Hledger.Utils cleaned up.

- Hledger.Data.Amount: showMixedAmountOneLine now also shows costs.
  Note that different costs are kept separate in amount arithmetic.

- Hledger.Read.Common: rename/add amount parsing helpers.

  added:
   parseamount
   parseamount'
   parsemixedamount
   parsemixedamount'

  removed:
   amountp'
   mamountp'

- Hledger.Utils.Parse:
  export customErrorBundlePretty,
  for pretty-printing hledger parse errors.

- Support megaparsec 9.3. (Felix Yan)

- Support GHC 9.4.

- Update cabal files to match hpack 0.35/stack 2.9

* hledger-lib 1.27 2022-09-01

Breaking changes

- Support for GHC 8.6 and 8.8 has been dropped.
  hledger now requires GHC 8.10 or newer.

- Hledger.Data.Amount: `amount` has been dropped; use `nullamt` instead.

- journal*AccountQuery functions have been dropped; use a type: query instead.
  cbcsubreportquery no longer takes Journal as an argument.
  (#1921)

Misc. changes

- Hledger.Utils.Debug now re-exports Debug.Breakpoint from the
  breakpoint library, so that breakpoint's helpers can be used easily
  during development.

- Hledger.Utils.Debug:
  dlog has been replaced by more reliable functions for debug-logging
  to a file (useful for debugging TUI apps like hledger-ui):

  dlogTrace
  dlogTraceAt
  dlogAt
  dlog0
  dlog1
  dlog2
  dlog3
  dlog4
  dlog5
  dlog6
  dlog7
  dlog8
  dlog9

- Hledger.Utils.Debug: pprint' and pshow' have been added,
  forcing monochrome output.

- Hledger.Utils.String: add quoteForCommandLine

- Hledger.Data.Errors: export makeBalanceAssertionErrorExcerpt

- Hledger.Utils.Parse: export HledgerParseErrors

- Debug logging from journalFilePath and the include directive will
  now show "(unknown)" instead of an empty string.

* hledger-lib 1.26.1 2022-07-11

- require safe 0.3.19+ to avoid deprecation warning

* hledger-lib 1.26 2022-06-04

Breaking changes

- readJournal, readJournalFile, readJournalFiles now return
  `ExceptT String IO a` instead of `IO (Either String a)`.
  Internally, this increases composability and avoids some ugly case handling.
  It means that these must now be evaluated with `runExceptT`.
  That can be imported from `Control.Monad.Except` in the `mtl` package,
  but `Hledger.Read` also re-exports it for convenience.

  New variants readJournal', readJournalFiles', readJournalFile' are
  also provided; these are like the old functions but more convenient,
  assuming default input options and needing one less argument.
  (Stephen Morgan)

- parseAndFinaliseJournal' (a variant of parseAndFinaliseJournal) has been removed.
  In the unlikely event you needed it in your code, you can replace:
  ```haskell
  parseAndFinaliseJournal' parser iopts fp t
  ```
  with:
  ```haskell
  initialiseAndParseJournal parser iopts fp t
  >>= liftEither . journalApplyAliases (aliasesFromOpts iopts)
  >>= journalFinalise iopts fp t
  ```

- Some parsers have been generalised from JournalParser to TextParser.
  (Stephen Morgan)

Misc. changes

- Allow doclayout 0.4.

- Our doctests now run with GHC 9.2+ only, to avoid doctest issues.

- Hledger.Data.JournalChecks: some Journal checks have been moved and renamed:
  journalCheckAccounts,
  journalCheckCommodities,
  journalCheckPayees

- Hledger.Data.Errors: new error formatting helpers
  makeTransactionErrorExcerpt,
  makePostingErrorExcerpt,
  transactionFindPostingIndex

- HledgerParseErrors is a new type alias for our parse errors.
  CustomErr has been renamed to HledgerParseErrorData.

- Hledger.Query: added
  matchesQuery,
  queryIsCode,
  queryIsTransactionRelated

- Improve ergonomics of SmartDate constructors.
  (Stephen Morgan)

- Hledger.Utils: 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.
  ([#1813](simonmichael/hledger#1813) (Stephen Morgan)

* hledger-lib 1.25 2022-03-04

- hledger-lib now builds with GHC 9.2 and latest deps.
  ([#1774](simonmichael/hledger#1774)

- 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.

- Journal has a new jdeclaredaccounttags field
  for easy lookup of account tags.
  Query.matchesTaggedAccount is a tag-aware version of matchesAccount.

- Some account name functions have moved from Hledger.Data.Posting
  to Hledger.Data.AccountName:
  accountNamePostingType, accountNameWithPostingType, accountNameWithoutPostingType,
  joinAccountNames, concatAccountNames, accountNameApplyAliases, accountNameApplyAliasesMemo.

- Renamed: CommodityLayout to Layout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. journal The journal file format, and its features. needs:discussion To unblock: needs more discussion/review/exploration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants