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

Allow filtering transactions by payee #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

501st-alpha1
Copy link

I wanted to use this tool to calculate the values that would appear on my W2s, so I needed a way to filter by payee. I hacked together this solution that just splits the account name on --, so the following line in a command file:

$fw2_line01_gross_wages "Income:Wages -- Acme Inc" =

will assign to $fw2_line01_gross_wages the total of Income:Wages for any transactions involving Acme Inc.

I'm not happy with the syntax, but I couldn't think of anything better. Do you have any other ideas?

@zdw
Copy link
Owner

zdw commented Apr 8, 2017

This looks reasonable, although I concur on the syntax. Maybe there's a better way to do this - two spaces or a tab is used to separate account from amount, so we know that's a case that can't be in the account name - if we went that way could extend it even further as need arises, such as: Income:Wages payee:'Acme Inc',othertag:'value' with account name, 2 spaces, then comma separated quoted key/value tags (github's comment system engine appears to make the two spaces into one when saving the comment, so imagine there are two there)

One note - the way you're structuring your Ledger files may make it harder in the long run to sort out sub-account totals. For example, in the structure I use, I put the name of the customer as a part of the account, so I can do this using the built in regex support:

$f1040sc_line01_gross_reciepts "Customers:.*:Payments" = 

which gets the sum of Customers:Foo:Payments and Customers:Bar:Payments, as the .* matches both accounts. If you were to change your ledger files to use say Income:Wages:Acme as the account name, selecting based on payee wouldn't be needed.

Also, when sending pull requests, it's best to squash all the changes into one commit.

@501st-alpha1
Copy link
Author

Maybe there's a better way to do this - two spaces or a tab is used to separate account from amount, so we know that's a case that can't be in the account name

Good point, that sounds much better.

If you were to change your ledger files to use say Income:Wages:Acme as the account name, selecting based on payee wouldn't be needed.

That is another valid option, but the reason I have avoided that so far is I prefer not to duplicate information unnecessarily, and I already have the name of the company as the payee, so I'd rather not also have it as a sub-account.

Also, when sending pull requests, it's best to squash all the changes into one commit.

No problem, I wasn't sure what the policy was for this repo.

When I have time later I'll make that syntax change and squash everything down to one commit.

Per discussion in
zdw#1, use two spaces
to split account name from payee, since Ledger accounts may not
contain more than one space in a row.
@501st-alpha1 501st-alpha1 force-pushed the feature/filter-transactions-by-payee branch from e05bf0c to d2ad161 Compare June 7, 2017 21:45
@501st-alpha1
Copy link
Author

@zdw I've updated my PR.

@zdw
Copy link
Owner

zdw commented Jun 20, 2017

This updated PR looks good. I don't have a license assigned to this repo, and I should add one before I start accepting contributions.

Would the Apache-2.0 (preferred), or the BSD 3-clause (like ledger) be OK?

@501st-alpha1
Copy link
Author

I have no preference between those two licenses. Since this is a separate program, I don't think you are limited by what license Ledger uses, if that's what you're asking.

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

Successfully merging this pull request may close these issues.

2 participants