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

ofx: support configurable destination directory per account #61

Merged
merged 2 commits into from
Jan 25, 2022

Conversation

jktomer
Copy link
Contributor

@jktomer jktomer commented Jan 16, 2022

Account numbers aren't a great identifier for humans; if one wants to be able
to browse the data fetched by finance-dl, it's helpful to have mnemonic names
for the directories holding data for a given account. Even failing this, some
banks use account numbers that are not valid directory names, and users may
prefer a different method to clean the generated name than the default of
substituting all invalid characters with hyphens.

This change allows the user to add an acct_dir_map entry to the finance-dl
config for an ofx source. The map is a simple dict mapping account number (as
given in the OFX output) to directory name.

If a mapping is given, it is trusted blindly; if the user specifies a
directory for an account that makes the path invalid, it's better to fail than
silently do something different from what we were explicitly asked for.

Account numbers aren't a great identifier for humans; if one wants to be able
to browse the data fetched by finance-dl, it's helpful to have mnemonic names
for the directories holding data for a given account. Even failing this, some
banks use account numbers that are not valid directory names, and users may
prefer a different method to clean the generated name than the default of
substituting all invalid characters with hyphens.

This change allows the user to add an `acct_dir_map` entry to the finance-dl
config for an ofx source. The map is a simple dict mapping account number (as
given in the OFX output) to directory name.

If a mapping is given, it is trusted blindly; if the user specifies a
directory for an account that makes the path invalid, it's better to fail than
silently do something different from what we were explicitly asked for.
@Zburatorul
Copy link
Collaborator

Looks like some minor mypy issues with the type specification of acct_dir_map.

otherwise `a.number in acct_dir_map` would fail when acct_dir_map was missing.
@jktomer
Copy link
Contributor Author

jktomer commented Jan 16, 2022

Whoops, that was a real bug actually D:

Fixed now, and tox passes.

@Zburatorul
Copy link
Collaborator

Out of curiosity, what situations do you find yourself needing a human-convenient view of the data files?
Between this and #60, I see a pattern.

Beancount-import doesn't care too much about the location/hierarchy of most of the data, save for odd quirks like this one.

I wonder if your needs point to something else? Perhaps b-i taking too long to start because you have a lot of historical data files in the same folder?

@jktomer
Copy link
Contributor Author

jktomer commented Jan 25, 2022

Out of curiosity, what situations do you find yourself needing a human-convenient view of the data files?

I'm a control freak, perhaps ;)

I do frequently end up looking at my ofx files directly (e.g. to debug beancount-import's handling of some way in which they don't match the OFX spec, or to munge it with one of the custom tools I've written to paper over ways in which some of my institutions yield broken OFX files). Similarly with e.g. Amazon receipts: I occasionally go and delete one by hand because I discover that it was broken and Amazon has since published a corrected one (silently, of course), and having fewer files per directory has advantages like letting me tab-complete their names; and sometimes I have another reason to go fetch an invoice and looking in the folder where I have them all conveniently downloaded is easier than fetching it manually from Amazon again... generally, I don't keep finance-dl's data around exclusively for use with beancount-import, so having the ability to organize it for myself is convenient for me.

Copy link
Collaborator

@Zburatorul Zburatorul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it out. Works.

@Zburatorul Zburatorul merged commit 3d4ffe3 into jbms:master Jan 25, 2022
@jktomer jktomer deleted the ofx-choose-your-destiny branch January 26, 2022 06:28
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