declaring account types

27 views
Skip to first unread message

Simon Michael

unread,
Sep 27, 2018, 5:44:43 PM9/27/18
to hledger
I'd welcome your thoughts or review on https://github.com/simonmichael/hledger/pull/877,
which fixes the long-standing dependence on english account names in bs/cf/is.
Here are the commits:


Previously you had to use one of the standard english account names
(assets, liabilities..) for top-level accounts, if you wanted to use
the bs/bse/cf/is commands.
Now, account directives can specify which of the big five categories
an account belongs to - asset, liability, equity, revenue or expense -
by writing one of the letters A, L, E, R or X two or more spaces after
the account name (where the numeric account code used to be).

This might change. Some thoughts influencing the current syntax:
- easy to type and read
- does not require multiple lines
- does not depend on any particular account numbering scheme
- allows more types later if needed
- still anglocentric, but only a little
- could be treated as syntactic sugar for account tags later
- seems to be compatible with (ignored by) current Ledger

The current design permits unlimited account type declarations anywhere
in the account tree. So you could declare a liability account somewhere
under assets, and maybe a revenue account under that, and another asset
account even further down. In such cases you start to see oddities like
accounts appearing in multiple places in a tree-mode report. In theory
the reports will still behave reasonably, but this has not been tested
too hard. In any case this is clearly too much freedom. I have left it
this way, for now, in case it helps with:

- modelling contra accounts ?
- multiple files. I suspect the extra expressiveness may come in handy
  when combining multiple files with account type declarations,
  rewriting account names, apply parent accounts etc.
  If we only allowed type declarations on top-level accounts, or
  only allowed a single account of each type, complications seem likely.
These commands now detect the account types declared by account directives.
Whenever such declarations are not present, built-in regular expressions
are used, as before.

Simon Michael

unread,
Sep 27, 2018, 5:58:41 PM9/27/18
to hledger
I forgot to provide a clear example. The idea is you declare the types of your five top-level accounts. In english, the standard account names are recognised automatically so this would be redundant, but you could write:

; account types are ALERX. At least two spaces between account name and type.
account assets       A
account liabilities  L
account equity       E
account revenues     R
account expenses     X

While in french, you could write, if you were using names from https://fr.wikipedia.org/wiki/Plan_comptable_g%C3%A9n%C3%A9ral_(France)#Cadre_comptable :

account Comptes de capitaux        L
account Comptes d'immobilisations  A
account ???                        E
account Comptes de produits        R
account Comptes de charges         X

I'm not sure where Equity fits in the french chart of accounts. Does this point out a weakness in this ALERX scheme ?


Reply all
Reply to author
Forward
0 new messages