Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown account guessing when payee has changed #25

Closed
501st-alpha1 opened this issue May 1, 2017 · 3 comments
Closed

Unknown account guessing when payee has changed #25

501st-alpha1 opened this issue May 1, 2017 · 3 comments

Comments

@501st-alpha1
Copy link
Contributor

Currently ledger-autosync can guess the unknown account based on previous transactions with the same payee. However, the payee output by ledger-autosync isn't usually in the format that I want for my ledger file, so I rewrite it as needed. (Example: ledger-autosync gives Debit Card Purchase - STARBUCKS as the payee for one transaction. I don't care about the first part, and the second part is shouty, so I change the payee to Starbucks.) Unfortunately, this breaks the account guessing, which causes me to additionally need to rewrite the unknown account.

I have a couple ideas of how to fix this. The first is: would it be possible to save the payee that ledger-autosync outputs to e.g. a tag, and match on that? (I assume I could add a Payee: directive, but that would probably also affect any ledger output.)

Second idea: Ledger recognizes a payee sub-directive to the account directive, as follows (from the Ledger docs):

account Expenses:Food
    payee ^(KFC|Popeyes)$

...

The payee sub-directive, which can occur multiple times, provides regexes that identify the account if that payee is encountered and an account within its transaction ends in the name "Unknown". Example:

2012-02-27 KFC
    Expenses:Unknown      $10.00  ; Read now as "Expenses:Food"
    Assets:Cash

Could ledger-autosync apply these regexes to find the matching account to use? I realize I could add the payee sub-directives and use a generic unknown account, but I'd rather have the correct account in my ledger file, so it's clear without searching through the headers for the payee directive.

@egh
Copy link
Owner

egh commented May 2, 2017

Thanks for the feedback! Those both sound like good ideas. I'd also like to improve payee matching (e.g. http://tomszilagyi.github.io/payment-matching/) but I think giving the user an option to configure payee matching via some sort of configuration, ideally in the ledger file itself, would be very useful.

I'd worry about the second option creating some feature drift between support for ledger and hledger, because it is not supported by ledger. So far I have been able to keep ledger-autosync working the same in hledger and ledger, and it would be nice to keep it that way. It might be possible to parse ledger files for account directives, but then I'd need to support include etc. to keep it working the same.

The first options seems viable. I'll need to explore how this could work in ledger and hledger. I imagine it would be possible to have a single AutosyncPayee metadata tag map all payees to that original, so your ledger files wouldn't need to include a lot of AutosyncPayee: Debit Card Purchase - STARBUCKS all over.

@501st-alpha1
Copy link
Contributor Author

@egh Would you be open to a PR implementing the AutosyncPayee tag mapping?

The post you linked to looks interesting too, but I think that would be mostly separate from the issue I'm having, since the author uses the original payee in their ledger file (and possibly appends something to it).

@egh
Copy link
Owner

egh commented Dec 31, 2018

@501st-alpha1 Sure! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants