siddhantgoel / beancount-dkb

Beancount Importers for DKB (Deutsche Kredit Bank) CSV Exports
MIT License
34 stars 13 forks source link

ERROR:root:Importer DKB CreditImporter.extract() raised an unexpected error: 'Zeitraum:' #89

Closed mh182 closed 3 years ago

mh182 commented 3 years ago

I made this bug report in case someone stumbles upon the same problem as I did. I'm new to beancount and after my initial setup of my accounts I stumbled upon beancount-dkb extractor.

I downloaded my credit card and account transactions from DKB and tried the DKB extractor which failed with following error:

$ bean-extract dkb.config ./incoming
ERROR:root:Importer DKB CreditImporter.extract() raised an unexpected error: 'Zeitraum:'
Traceback (most recent call last):
  File "/home/max/.local/pipx/venvs/beancount/lib/python3.9/site-packages/beancount/ingest/extract.py", line 182, in extract
    new_entries = extract_from_file(
  File "/home/max/.local/pipx/venvs/beancount/lib/python3.9/site-packages/beancount/ingest/extract.py", line 67, in extract_from_file
    new_entries = importer.extract(file, **kwargs)
  File "/home/max/.local/pipx/venvs/beancount/lib/python3.9/site-packages/beancount_dkb/credit.py", line 128, in extract
    expected_keys.remove(key)
KeyError: 'Zeitraum:'

After multiple exports from the DKB side I noticed that the file content changes based on the used filters on the DKB web-page. The beancount-dkb extractor only works if I used a "von"-"bis" filter. Any other filters (like "last 30 days") exported a file with the line "Zeitraum" instead of "Von:" and "Bis:", which apparently confuses the extractor.

Workaround: set your filter on the DKB web-page to a Von-Bis date and bean-extract works fine.

Here a short feedback which could improve your project. I had no idea how to work with beancount extractors. The "Usage" chapter could be improved to add minimal context how to use beancount-dkb. Or add a link to Beancount - Importing External Data to provide the context.

Btw - thanks for the work to make the DKB extractor, it saved me the time to make one.

siddhantgoel commented 3 years ago

Thanks for the bug report and the feedback.

I've updated the Usage section with a bit more context. Hope this is more helpful than before.

The Zeitraum thing sounds like a bug. Thanks for posting a workaround, but I'll most likely try to push a fix for this over the weekend, so the next version should support this metadata as well.

mh182 commented 3 years ago

Yes, the provided context would have helped me. Thanks.

siddhantgoel commented 3 years ago

I've just pushed v0.9.0 which should support Zeitraum in credit data exports. Please install that version. The workaround should no longer be necessary.