Commit Graph

2502 Commits

Author SHA1 Message Date
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
Stephen Morgan
91441bad8f test: Make sure --today is passed to --forecast tests so they keep
working.
2022-01-31 15:12:04 -10:00
Simon Michael
248ddf9378 dev: more thorough Journal anonymisation, and a note (#1817) 2022-01-30 09:47:52 -10:00
Simon Michael
3472c3cb6d ;dev: number anon tests 2022-01-30 09:47:52 -10:00
Simon Michael
3d57fa32c2 ;doc: querying by tags, on accounts and generally (#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
2f48307c63 dev: query-tag.test -> format 3 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
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
Stephen Morgan
2a51b6e9a4 fix: layout: Commodity symbols should be omitted in --layout=bare when
all amounts are zero. (#1789)
2022-01-26 07:58:14 -10:00
Stephen Morgan
55a022a941 fix: strict: Make sure forecast transactions and auto postings are
checked with --strict. (#1810)
2022-01-26 07:57:13 -10:00
Patrik Keller
2cf4c221de Manual: clarify reference from --strict to check 2022-01-26 07:45:13 -10:00
Simon Michael
e16fa51dd5 imp: nicer invalid balance assignment errors (fix tests) 2022-01-21 17:45:23 -10:00
Stephen Morgan
8cd9e81c34 fix: budget: Make sure boring parents of unbudgeted accounts are not
elided if they have a budget. (#1800)

This only affects calls with --budget and -E, but not with --no-elide.
2022-01-21 09:11:04 -10:00
Simon Michael
d9b0184720 ;doc: changeslogs: edit 2022-01-21 08:38:59 -10:00
Simon Michael
41b68714ff ;doc: update manuals 2022-01-21 08:32:29 -10:00
Simon Michael
fbf826a813 ;doc: update CLI usage texts 2022-01-21 08:32:29 -10:00
Simon Michael
8daef36c29 ;doc: update changelogs 2022-01-21 08:32:29 -10:00
Simon Michael
1716a3e55c ;doc: roi: dear lord fix links again 2022-01-21 08:20:05 -10:00
Simon Michael
209a726e26 ;doc: roi: make links useful in plain text docs
And update how-to url.
2022-01-21 08:17:55 -10:00
Simon Michael
beeb7b157c ;doc: roi: fix link 2022-01-21 08:13:26 -10:00
Simon Michael
bf2ac4f18b ;doc: roi: formatting 2022-01-21 08:13:26 -10:00
Stephen Morgan
57d055b643 fix: cost: Add inferred equity postings during journal finalisation, so
they can be matched by queries.
2022-01-16 18:37:18 -10:00
Simon Michael
f7a3f510be ;doc: describe no-symbol commodity checking (#1772) 2022-01-16 08:24:30 -10:00
Stephen Morgan
5006e26995 imp: check: Do not check commodities for zero amounts with empty
commodity. (#1767)
2022-01-16 08:11:02 -10:00
Simon Michael
dbcd235f9e ;doc: update manuals 2022-01-15 08:56:45 -10:00
Simon Michael
6e12be15df ;doc: update CLI usage texts 2022-01-15 08:56:45 -10:00
Simon Michael
9444e20c3d ;doc: update changelogs 2022-01-15 08:56:45 -10:00
Simon Michael
fb834777a6 ;fix: doc: update help/help-feedback links (#1807) 2022-01-15 08:53:48 -10:00
Stephen Morgan
f13ac2812f imp: smartdates: Simplify and generalise the SmartDate constructor and
parsers to allow for arbitrary numbers of periods in relative dates.

We now accept smart dates like “in 5 days, 5 weeks ahead, in -6 months, 2 quarters ago”.
2022-01-11 13:31:29 -10:00
Simon Michael
0e5ae2baac ;doc: update changelogs 2022-01-06 06:42:34 -10:00
Simon Michael
d82210cea9 ;doc: update changelogs 2022-01-05 18:09:23 -10:00
Simon Michael
757c548c17 ;doc: update changelogs 2022-01-05 08:12:44 -10:00
Simon Michael
d1bc3bbb32 ;doc: update changelogs 2022-01-01 15:55:08 -10:00
Simon Michael
326b2309bc ;doc: csv: tweak 2021-12-30 09:22:57 -10:00
Dmitry Astapov
ce54fb8ae9 ;roi: fixes #1791 (fix TWR when investment=0, several pnls per day) 2021-12-27 08:10:22 -10:00
Simon Michael
737ab13284 journal: doc updates for aliases corrupting account names (#1788) 2021-12-22 15:14:37 -10:00
Simon Michael
713f7eab65 journal: doc updates for aliases corrupting account names (#1788) 2021-12-22 15:08:01 -10:00
Simon Michael
9c173bc18b journal: tests/docs for aliases corrupting account names (#1788) 2021-12-22 14:59:13 -10:00
Simon Michael
cfee37ab36 ;doc: fix conversion & cost lists 2021-12-21 11:01:39 -10:00
Simon Michael
e92a266064 ;doc: update manuals 2021-12-21 10:55:05 -10:00
Simon Michael
d10f3df27b ;doc: fix conversion & cost depth 2021-12-21 10:54:47 -10:00
Simon Michael
4bf0d76a1f ;doc: update manuals 2021-12-21 10:53:19 -10:00
Simon Michael
82cd81c066 doc: new CONVERSION & COST section after #1554 2021-12-21 10:50:13 -10:00
Stephen Morgan
8eedbbbe87 imp: cost: Generate totally balanced conversion postings for amounts 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.
2021-12-21 10:50:13 -10:00
Simon Michael
5561eeb8a4 ;doc: fix two unlinked urls 2021-12-17 10:00:19 -10:00
Simon Michael
c23808a163 ;doc: queries: fix "rewriting accounts" links 2021-12-15 11:14:01 -10:00
Simon Michael
45db32b84f ;doc: update changelogs 2021-12-10 12:50:21 -10:00
Simon Michael
a98e6125f1 ;doc: changelogs: 1.24.1 2021-12-10 12:47:43 -10:00