beancount / ledger2beancount

Ledger to Beancount text-based converter
GNU General Public License v3.0
79 stars 15 forks source link

Payee sub directive for accounts #248

Closed bratekarate closed 3 years ago

bratekarate commented 3 years ago

Ledger supports the subdirective payee for the account directive. Using this sub directive for an account, ledger will automatically change any posting's account that ends with :Unknown to the respective Account if the payee regex matches a transaction's payee.

See the example in https://www.ledger-cli.org/3.0/doc/ledger3.html#Command-Directives for a food expenses account.

I did not find any explicit mention of the payee sub directive for accounts in the docs of ledger2beancount, only that the alias sub directive is supported. Does that mean the payee sub directive is not supported? If not, it may be a good idea to explicitly state in the docs that no other sub directives for the account directive other than alias are supported.

It kind of makes sense that it would not be supported, as it does not make sense to replicate the functionality that is already in ledger. So the right approach would probably be to use ledger print to generate the correct transactions and then feed it to ledger2beancount. Still, I think it would still prove helpful to be informed about this by the docs explicitly, as it is quite difficult to keep an overview of incompatible features from the top of your head before converting.

tbm commented 3 years ago

No, it's not supported. I wasn't even aware of that feature.

But I think there are arguments for supporting it. I'd have to check how hard that would be.

tbm commented 3 years ago

I did not find any explicit mention of the payee sub directive for accounts in the docs of ledger2beancount, only that the alias sub directive is supported.

Actually, the alias sub-directive (under account) isn't supported either. Only the top-level alias directive is.

tbm commented 3 years ago

I've implemented support for the alias and payee sub-directives of account declarations now.

Please let me know if it's working as expected.

bratekarate commented 3 years ago

Wow, that was fast. Thanks for your work! You're implementing faster than I can reply :)

Edit: Works as expected.

tbm commented 3 years ago

Edit: Works as expected.

Great!

Please open issues if you run into any other issues.