Skip to content

Commit baca5f8

Browse files
committed
fix:check:tags: add date and date2 to the implicitly-declared special tags
And add tests/comments.
1 parent a964fd2 commit baca5f8

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed

hledger-lib/Hledger/Data/JournalChecks.hs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,23 @@ journalCheckTags j = do
198198
])
199199

200200
-- | Tag names which have special significance to hledger.
201+
-- Keep synced with check-tags.test and hledger manual > Special tags.
201202
builtinTags = [
202-
"type" -- declares an account's type
203-
,"t" -- declares the (user defined, single letter) type of a 15m unit of time parsed from timedot format
204-
-- generated by close
205-
,"balances" -- balance assertions transaction
206-
,"retain" -- retain earnings transaction
207-
,"start" -- opening balances, closing balances or balance assignment transaction
208-
-- optionally generated on periodic transactions and auto postings
209-
,"generated-transaction"
210-
,"generated-posting"
211-
,"modified"
212-
-- used internally, not shown (but queryable)
213-
,"_generated-transaction"
214-
,"_generated-posting"
215-
,"_modified"
216-
,"_conversion-matched"
203+
"date" -- overrides a posting's date
204+
,"date2" -- overrides a posting's secondary date
205+
,"type" -- declares an account's type
206+
,"t" -- appears on postings generated by timedot letters
207+
,"assert" -- appears on txns generated by close --assert
208+
,"retain" -- appears on txns generated by close --retain
209+
,"start" -- appears on txns generated by close --migrate/--close/--open/--assign
210+
,"generated-transaction" -- with --verbose-tags, appears on generated periodic txns
211+
,"generated-posting" -- with --verbose-tags, appears on generated auto postings
212+
,"modified" -- with --verbose-tags, appears on txns which have had auto postings added
213+
-- hidden tags used internally (and also queryable):
214+
,"_generated-transaction" -- always exists on generated periodic txns
215+
,"_generated-posting" -- always exists on generated auto postings
216+
,"_modified" -- always exists on txns which have had auto postings added
217+
,"_conversion-matched" -- exists on postings which have been matched with a nearby @/@@ cost notation
217218
]
218219

219220
-- | In each tranaction, check that any conversion postings occur in adjacent pairs.

hledger/test/check-tags.test

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,42 @@ $ hledger -f - check tags
3939
$ hledger -f - check tags
4040
>2 /tag "ptag" has not been declared/
4141
>=1
42+
43+
# ** 6. Built-in special tags are implicitly declared and won't make check tags fail.
44+
# Keep synced with JournalChecks.builtinTags.
45+
<
46+
2024-01-01
47+
; date:
48+
; date2:
49+
; type:
50+
; t:
51+
; assert:
52+
; retain:
53+
; start:
54+
; generated-transaction:
55+
; generated-posting:
56+
; modified:
57+
; _generated-transaction:
58+
; _generated-posting:
59+
; _modified:
60+
; _conversion-matched:
61+
$ hledger -f - check tags
62+
63+
# ** 7. Declaring the built-in special tags is harmless.
64+
# Keep synced with JournalChecks.builtinTags.
65+
<
66+
tag date ; overrides a posting's date
67+
tag date2 ; overrides a posting's secondary date
68+
tag type ; declares an account's type
69+
tag t ; generated by letters in timedot data (with the letter as tag value)
70+
tag assert ; appears on txns generated by close --assert
71+
tag retain ; appears on txns generated by close --retain
72+
tag start ; appears on txns generated by close --migrate/--close/--open/--assign
73+
tag generated-transaction ; with --verbose-tags, appears on generated periodic txns
74+
tag generated-posting ; with --verbose-tags, appears on generated auto postings
75+
tag modified ; with --verbose-tags, appears on txns which have had auto postings added
76+
tag _generated-transaction ; always exists on generated periodic txns
77+
tag _generated-posting ; always exists on generated auto postings
78+
tag _modified ; always exists on txns which have had auto postings added
79+
tag _conversion-matched ; exists on postings which have been matched with a nearby @/@@ cost notation
80+
$ hledger -f - check tags

0 commit comments

Comments
 (0)