From df4949ad1a3de99721636aaf1c54479739e5ddab Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Sat, 29 Jan 2022 08:57:22 +1100 Subject: [PATCH] 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 --- hledger-lib/Hledger/Read/JournalReader.hs | 11 ++--------- hledger/hledger.m4.md | 2 +- hledger/test/journal/directive-account.test | 6 +++--- hledger/test/journal/transaction-prices.test | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 88aafa8f2..72807cabb 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -347,12 +347,6 @@ accountdirectivep = do -- the account name, possibly modified by preceding alias or apply account directives acct <- modifiedaccountnamep - -- maybe an account type code (ALERX) after two or more spaces - -- XXX added in 1.11, deprecated in 1.13, remove in 1.14 - mtypecode :: Maybe Char <- lift $ optional $ try $ do - skipNonNewlineSpaces1 -- at least one more space in addition to the one consumed by modifiedaccountp - choice $ map char "ALERXV" - -- maybe a comment, on this and/or following lines (cmt, tags) <- lift transactioncommentp @@ -362,8 +356,7 @@ accountdirectivep = do -- an account type may have been set by account type code or a tag; -- the latter takes precedence let - mtypecode' :: Maybe Text = lookup accountTypeTagName tags <|> (T.singleton <$> mtypecode) - metype = parseAccountTypeCode <$> mtypecode' + metype = parseAccountTypeCode <$> lookup accountTypeTagName tags -- update the journal addAccountDeclaration (acct, cmt, tags) @@ -1010,7 +1003,7 @@ tests_JournalReader = testGroup "JournalReader" [ ,testGroup "accountdirectivep" [ testCase "with-comment" $ assertParse accountdirectivep "account a:b ; a comment\n" ,testCase "does-not-support-!" $ assertParseError accountdirectivep "!account a:b\n" "" - ,testCase "account-type-code" $ assertParse accountdirectivep "account a:b A\n" + ,testCase "account-type-code" $ assertParse accountdirectivep "account a:b ; type:A\n" ,testCase "account-type-tag" $ assertParseStateOn accountdirectivep "account a:b ; type:asset\n" jdeclaredaccounts [("a:b", AccountDeclarationInfo{adicomment = "type:asset\n" diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index fe79d3381..d11e9f77c 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -3037,7 +3037,7 @@ account assets:bank:checking Here is the full syntax of account directives: ```journal -account ACCTNAME [ACCTTYPE] [;COMMENT] +account ACCTNAME [;type:ACCTTYPE] [COMMENT] [;COMMENTS] [LEDGER-STYLE SUBDIRECTIVES, IGNORED] ``` diff --git a/hledger/test/journal/directive-account.test b/hledger/test/journal/directive-account.test index a2b6c44ee..d7d028788 100644 --- a/hledger/test/journal/directive-account.test +++ b/hledger/test/journal/directive-account.test @@ -13,11 +13,11 @@ b # "b" is a liability. "b:bb" is an asset. < ; a liability -account asset L +account asset ; type:L ; an asset -account b:bb A +account b:bb ; type:A ; a liability -account b L +account b ; type:L 2018/1/1 (asset:a) 1 diff --git a/hledger/test/journal/transaction-prices.test b/hledger/test/journal/transaction-prices.test index 4b917d394..d0352b5ad 100644 --- a/hledger/test/journal/transaction-prices.test +++ b/hledger/test/journal/transaction-prices.test @@ -329,7 +329,7 @@ hledger -f - balance --no-total -E -B # 27. The equity account used by --infer-equity can be customised hledger -f- print --infer-equity <<< -account equity:trades V +account equity:trades ; type:V 2011/01/01 expenses:foreign currency €100 @ $1.35