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
This commit is contained in:
Stephen Morgan 2022-01-29 08:57:22 +11:00 committed by Simon Michael
parent 929f13ec03
commit df4949ad1a
4 changed files with 7 additions and 14 deletions

View File

@ -347,12 +347,6 @@ accountdirectivep = do
-- the account name, possibly modified by preceding alias or apply account directives -- the account name, possibly modified by preceding alias or apply account directives
acct <- modifiedaccountnamep 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 -- maybe a comment, on this and/or following lines
(cmt, tags) <- lift transactioncommentp (cmt, tags) <- lift transactioncommentp
@ -362,8 +356,7 @@ accountdirectivep = do
-- an account type may have been set by account type code or a tag; -- an account type may have been set by account type code or a tag;
-- the latter takes precedence -- the latter takes precedence
let let
mtypecode' :: Maybe Text = lookup accountTypeTagName tags <|> (T.singleton <$> mtypecode) metype = parseAccountTypeCode <$> lookup accountTypeTagName tags
metype = parseAccountTypeCode <$> mtypecode'
-- update the journal -- update the journal
addAccountDeclaration (acct, cmt, tags) addAccountDeclaration (acct, cmt, tags)
@ -1010,7 +1003,7 @@ tests_JournalReader = testGroup "JournalReader" [
,testGroup "accountdirectivep" [ ,testGroup "accountdirectivep" [
testCase "with-comment" $ assertParse accountdirectivep "account a:b ; a comment\n" testCase "with-comment" $ assertParse accountdirectivep "account a:b ; a comment\n"
,testCase "does-not-support-!" $ assertParseError accountdirectivep "!account a:b\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" ,testCase "account-type-tag" $ assertParseStateOn accountdirectivep "account a:b ; type:asset\n"
jdeclaredaccounts jdeclaredaccounts
[("a:b", AccountDeclarationInfo{adicomment = "type:asset\n" [("a:b", AccountDeclarationInfo{adicomment = "type:asset\n"

View File

@ -3037,7 +3037,7 @@ account assets:bank:checking
Here is the full syntax of account directives: Here is the full syntax of account directives:
```journal ```journal
account ACCTNAME [ACCTTYPE] [;COMMENT] account ACCTNAME [;type:ACCTTYPE] [COMMENT]
[;COMMENTS] [;COMMENTS]
[LEDGER-STYLE SUBDIRECTIVES, IGNORED] [LEDGER-STYLE SUBDIRECTIVES, IGNORED]
``` ```

View File

@ -13,11 +13,11 @@ b
# "b" is a liability. "b:bb" is an asset. # "b" is a liability. "b:bb" is an asset.
< <
; a liability ; a liability
account asset L account asset ; type:L
; an asset ; an asset
account b:bb A account b:bb ; type:A
; a liability ; a liability
account b L account b ; type:L
2018/1/1 2018/1/1
(asset:a) 1 (asset:a) 1

View File

@ -329,7 +329,7 @@ hledger -f - balance --no-total -E -B
# 27. The equity account used by --infer-equity can be customised # 27. The equity account used by --infer-equity can be customised
hledger -f- print --infer-equity hledger -f- print --infer-equity
<<< <<<
account equity:trades V account equity:trades ; type:V
2011/01/01 2011/01/01
expenses:foreign currency €100 @ $1.35 expenses:foreign currency €100 @ $1.35