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

GenericImporterSource - which data/field is used for the source_desc field? #204

Open
kosli opened this issue Jul 9, 2023 · 3 comments · May be fixed by #234
Open

GenericImporterSource - which data/field is used for the source_desc field? #204

kosli opened this issue Jul 9, 2023 · 3 comments · May be fixed by #234

Comments

@kosli
Copy link

kosli commented Jul 9, 2023

I have written a GenericImporter for my bank statements and I am automatically setting the payee and narration based on my "raw" data / statements.

Sometimes I leave the narration empty, which seems to be a problem with beancount-importer. It seems that the narration field is used/copied to the source_desc field which is used for the recognition of already confirmed transactions.

As my bank statements have their "raw" data which I would like for the source_desc matching, I tried to add them straight as metadata, but they are getting overwritten by beancount-importer.

How can i define what beancount-importer uses for the source_desc field?

@kosli
Copy link
Author

kosli commented Jul 10, 2023

I see the description in the GenericImporter and how the source_desc is being set -> https://github.com/jbms/beancount-import/blob/master/beancount_import/source/generic_importer_source.py
As this is hardcoded, it means I would need to create my own GenericImporter in case I wanna use my "raw" data for the source_desc, or if I wanna be able to use empty narration fields, which is valid beancount syntax: https://beancount.github.io/docs/beancount_language_syntax.html#payee-narration
So maybe the generic importer should be changed to rely on a combination of payee AND narration? (Or have the source_desc set / overriden by the custom importer)

@kosli
Copy link
Author

kosli commented Feb 11, 2024

Any update/feedback on this? Thanks.

@dumbPy
Copy link
Contributor

dumbPy commented Feb 15, 2024

@kosli
You may raise a PR to allow importers to set source_descby changing this

            if isinstance(posting.meta, dict):
                posting.meta["source_desc"] = entry.narration
                posting.meta["date"] = entry.date

to

            if isinstance(posting.meta, dict):
                posting.meta.setdefault("source_desc", entry.narration)
                posting.meta.setdefault("date", entry.date)

So it sets narration to source_desc only if source_desc isn't already set by the importer, and similarly for date

dumbPy added a commit to dumbPy/beancount-import that referenced this issue Apr 21, 2024
@dumbPy dumbPy linked a pull request Apr 21, 2024 that will close this issue
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 a pull request may close this issue.

2 participants