From c062b14c5d4e34c8feafe8e8631e8fbe2a51cb08 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 7 Dec 2023 08:55:05 -1000 Subject: [PATCH] imp: auto-declare builtin tag names like type: and t: (#2119) Now using type: in account declarations or generating t: with timedot letters won't cause the `tags` check to fail. If a user declares any of these explicitly with a tag directive, it does not cause an error. --- hledger-lib/Hledger/Data/JournalChecks.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Data/JournalChecks.hs b/hledger-lib/Hledger/Data/JournalChecks.hs index dba78ce7a..a5a3ba3a9 100644 --- a/hledger-lib/Hledger/Data/JournalChecks.hs +++ b/hledger-lib/Hledger/Data/JournalChecks.hs @@ -186,7 +186,7 @@ journalCheckTags j = do -- where -- col = T.length (showTransactionLineFirstPart txn') + 2 -- col2 = col + T.length tagname - 1 - declaredtags = journalTagsDeclared j + declaredtags = journalTagsDeclared j ++ builtinTags msg = (unlines [ "%s:%d:" ,"%s" @@ -197,6 +197,19 @@ journalCheckTags j = do ,"tag %s" ]) +-- | Tag names which have special significance to hledger. +builtinTags = [ + "type" -- declares an account's type + ,"t" -- generated by timedot letters notation + -- optionally generated on periodic transactions and auto postings + ,"generated-transaction" + ,"generated-posting" + -- used internally, not shown (but queryable) + ,"_generated-transaction" + ,"_generated-posting" + ,"_conversion-matched" + ] + -- | In each tranaction, check that any conversion postings occur in adjacent pairs. journalCheckPairedConversionPostings :: Journal -> Either String () journalCheckPairedConversionPostings j =