Simon Michael
2018-10-08 19:20:06 UTC
Cc'd from https://github.com/simonmichael/hledger/issues/891 <https://github.com/simonmichael/hledger/issues/891>, do you see any problems or simpler alternatives ?
This is a proposal for the "optional strict checking" part of #217 <https://github.com/simonmichael/hledger/issues/217>, allowing us to check account names in transactions against account declarations, and report misspelled or non-permitted account names, similar to --strict/--pedantic mode in Ledger. Here's what I'm thinking:
Proposal 1:
There are different kinds of accounts in the chart of accounts:
structural parent accounts, like assets and liabilities, needed for the tree, not normally posted to
accounts corresponding to real-world accounts, like assets:bankA:checking and liabilities:visa
imaginary subaccounts of real-world accounts, like assets:bankA:checking:rent or assets:bankA:savings:travel, used eg for budget envelopes/savings goals
accounts used to balance the books and track accounting concepts, like equity:opening balances
accounts used to categorise inflows and outflows, like revenues:salary and expenses:food:groceries:bulk:rice
The first kind (structural parents) usually should not receive postings. All the others typically can receive postings. I'm calling this an account's "usability", ie whether it may be used in postings (I haven't found a better word, ideas welcome.)
You may want to limit the creation of subaccounts deeper than what has been declared. You may want to lock down the basic chart of accounts but still allow freeform subaccounts in certain places.
Syntax should be lightweight and language neutral. Declaring account usability should be orthogonal to the other functions of account directives (display order, type etc.)
We could declare an account's usability by adding characters in the metadata area (in the account directive after two or more spaces, similar to #877 <https://github.com/simonmichael/hledger/pull/877>):
. (a period) means "this account is usable"
* (a star) means "any subaccount of this account is usable (both children and deeper descendants)"
If any such declarations are found in the journal, account usability checking is enabled and hledger will raise an error if it finds postings to accounts which have not been declared usable.
Eg:
; postings to assets or assets:bank are not allowed
account assets
account assets:bank
; postings to assets:bank:checking or any subaccount are allowed
account assets:bank:checking .*
; postings to assets:bank:savings are allowed, but not to subaccounts
account assets:bank:savings .
; postings to anything under liabilities, revenues or expenses are allowed (but not to the top-level accounts)
liabilities *
revenues *
expenses *
Proposal 2:
Alternately it could be
. "this account is usable"
* "direct children of this account are usable"
** "any subaccount of this account is usable (both children and deeper)"
This gives more control. And if we want this in future, it would be better to start with it now (switching would be disruptive.) However I think it is unnecessary precision, and it's better to keep things simple.
This is a proposal for the "optional strict checking" part of #217 <https://github.com/simonmichael/hledger/issues/217>, allowing us to check account names in transactions against account declarations, and report misspelled or non-permitted account names, similar to --strict/--pedantic mode in Ledger. Here's what I'm thinking:
Proposal 1:
There are different kinds of accounts in the chart of accounts:
structural parent accounts, like assets and liabilities, needed for the tree, not normally posted to
accounts corresponding to real-world accounts, like assets:bankA:checking and liabilities:visa
imaginary subaccounts of real-world accounts, like assets:bankA:checking:rent or assets:bankA:savings:travel, used eg for budget envelopes/savings goals
accounts used to balance the books and track accounting concepts, like equity:opening balances
accounts used to categorise inflows and outflows, like revenues:salary and expenses:food:groceries:bulk:rice
The first kind (structural parents) usually should not receive postings. All the others typically can receive postings. I'm calling this an account's "usability", ie whether it may be used in postings (I haven't found a better word, ideas welcome.)
You may want to limit the creation of subaccounts deeper than what has been declared. You may want to lock down the basic chart of accounts but still allow freeform subaccounts in certain places.
Syntax should be lightweight and language neutral. Declaring account usability should be orthogonal to the other functions of account directives (display order, type etc.)
We could declare an account's usability by adding characters in the metadata area (in the account directive after two or more spaces, similar to #877 <https://github.com/simonmichael/hledger/pull/877>):
. (a period) means "this account is usable"
* (a star) means "any subaccount of this account is usable (both children and deeper descendants)"
If any such declarations are found in the journal, account usability checking is enabled and hledger will raise an error if it finds postings to accounts which have not been declared usable.
Eg:
; postings to assets or assets:bank are not allowed
account assets
account assets:bank
; postings to assets:bank:checking or any subaccount are allowed
account assets:bank:checking .*
; postings to assets:bank:savings are allowed, but not to subaccounts
account assets:bank:savings .
; postings to anything under liabilities, revenues or expenses are allowed (but not to the top-level accounts)
liabilities *
revenues *
expenses *
Proposal 2:
Alternately it could be
. "this account is usable"
* "direct children of this account are usable"
** "any subaccount of this account is usable (both children and deeper)"
This gives more control. And if we want this in future, it would be better to start with it now (switching would be disruptive.) However I think it is unnecessary precision, and it's better to keep things simple.
--
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.