Commit Graph

2980 Commits

Author SHA1 Message Date
Simon Michael
53332ee6a5 stack: re-enable hledger-web with ghc 9.2 2022-04-15 15:07:17 -10:00
Simon Michael
133c54434a ;doc: changelogs 2022-04-14 13:59:03 -10:00
Simon Michael
8de85be658 ;doc: update manuals 2022-04-14 12:39:18 -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
4f26309328 ref: clean up Query definition 2022-04-14 11:56:37 -10:00
Simon Michael
161c911cb4 imp: Hledger.Query: new predicates, haddock cleanups
added:
matchesQuery,
queryIsAccountRelated,
queryIsTransactionOrPostingRelated,
2022-04-14 10:58:31 -10:00
Stephen Morgan
8cc59df513 fix: Ensure date2 is used for journal valuation if requested. (#1851) 2022-04-14 07:27:17 -10:00
Simon Michael
aa3807e157 ref: journalAccountTypes 2022-04-11 09:18:23 -10:00
Stephen Morgan
1aff74f702 cln: Reduce duplication in test utilities. 2022-03-26 15:35:19 -10:00
Stephen Morgan
8968733630 cln!: Clean up journal parsing.
parseAndFinaliseJournal' has been removed. In the unlikely event you
needed it in your code, you can replace it with:
parseAndFinaliseJournal' parser iopts fp t =>
initialiseAndParseJournal parser iopts fp t
>>= liftEither . journalApplyAliases (aliasesFromOpts iopts)
>>= journalFinalise iopts fp t

Some parsers have been generalised from JournalParser to TextParser.
2022-03-26 15:35:19 -10:00
Simon Michael
a2f6b30fbd cln: silence some warnings/lints 2022-03-26 08:34:21 -10:00
Simon Michael
db1818ac4a imp: consistent ghc warnings 2022-03-26 08:27:29 -10:00
Simon Michael
d9ecd1eb9d imp: update to modern warning flags 2022-03-25 20:28:34 -10:00
Stephen Morgan
bffb6c8c82 ref: smartdate: Improve ergonomics of SmartDate constructors. 2022-03-25 19:10:58 -10:00
Simon Michael
d60e1464d5 imp: fix MonadIO import (#1847) 2022-03-25 14:49:56 -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
Simon Michael
5281c5d647 imp: allow pivoting on 'status' also 2022-03-18 21:38:31 -10:00
Simon Michael
b584774a03 ci: fix a typo I fat-fingered 2022-03-18 11:03:30 -10:00
Simon Michael
2b2d643333 test: errors: make tests runnable 2022-03-18 06:59:33 -10:00
Stephen Morgan
e6bf04fce3 fix: aliases: Make sure we can escape forward slashes in account
aliases, but otherwise the regular expression handler handles escapes.
2022-03-16 19:01:03 -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
45408183fe dev: reg: areg: Strip prices early on in PostingsReport and AccountTransactionsReport, when possible.
This results in big speedups in cases when we have many transaction prices, like in examples/10000x1000x10.journal. This can be disabled with the show_costs_ option in ReportOpts.
2022-03-10 17:21:40 -10:00
Stephen Morgan
a65e64115a fix: alias: Allow escaped characters in regular expression aliases. (#982) 2022-03-10 17:00:03 -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
Simon Michael
f0e00b3a43 ;doc: update changelogs 2022-03-10 16:55:46 -10:00
Simon Michael
af7a5f98e3 ;cabal: update cabal files 2022-03-05 13:24:48 -10:00
Simon Michael
5aab2cbf40 ;pkg: bump version to 1.25.99 2022-03-05 13:24:48 -10:00
Simon Michael
e4ca7187fe doc: finalise changelogs for 1.25 2022-03-04 17:51:59 -10:00
Simon Michael
2ee914bdc7 ;doc: update changelogs 2022-03-04 17:04:50 -10:00
Simon Michael
e9c19e12ef ;cln: redundant pragma 2022-02-11 09:22:26 -10:00
Simon Michael
44211c1c57 ref: move Posting account name fns to AccountName
accountNamePostingType  accountNameWithoutPostingType  accountNameWithPostingType
joinAccountNames
concatAccountNames
accountNameApplyAliases  accountNameApplyAliasesMemo
2022-02-11 09:18:35 -10:00
Simon Michael
41d7c7f6b3 doc: lib: changelog fix 2022-02-07 11:58:29 -10:00
Stephen Morgan
2f47ae05c6 fix: csv: Allow unicode in field references for csv. (#1809) 2022-02-06 14:16:17 -10:00
Simon Michael
71f9c7985f doc: changelog updates from release branch 2022-02-05 22:09:20 -10:00
Simon Michael
ef4da90538 ;doc: update changelogs 2022-02-05 14:57:53 -10:00
Stephen Morgan
31fdcdb8ef !imp: type: Change the default account inference for Cash accounts to only match
^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|current)(:|$)

This should have no effect outside the cash report.

The rule for auto-detecting "Cash" (liquid assets) from account names
has changed in this release - see [Account types]. This is to simplify
how account types are detected and configured. If you use the cashflow
report without explicitly declaring accounts as Cash, you might notice a
change, and might need to add explicit account type: tags.
2022-02-03 15:32:00 -10:00
Stephen Morgan
2e4cfccf1b fix: types: Make sure type: query will correctly match subtypes, so
type:a will also match cash accounts, and type:e will also match
conversion accounts.
2022-02-03 15:32:00 -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
Stephen Morgan
a16c88b1b1 fix: Make sure cash and conversion account types are correctly
determined when there are no explicit declarations.
2022-02-03 15:32:00 -10:00
Stephen Morgan
36fe6bbcff fix: Allow accountNameInferType to recognise Conversion accounts. 2022-02-03 15:32:00 -10:00
Stephen Morgan
e17cd1540d fix: Correctly infer Cash accounts using accountNameInferType. 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
a22068a556 imp: better error messages for type:'s argument 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
885a4fcfec ref: journalFinalise: clarify sequence, top to bottom 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
Simon Michael
4ed80d4069 ;doc: update journalFinalise haddock 2022-01-30 09:47:52 -10:00
Stephen Morgan
df4949ad1a imp!: journal: Remove deprecated account type code syntax from account
directives.

Previously, you declare an account type with the following format:
account assets  A
This has been deprecated since 1.13, and should now be declared with one
of:
account assets  ; type:A
account assets  ; type:asset
2022-01-28 12:38:38 -10:00