Skip to content

Commit

Permalink
Tagesgeld support v2 (#217)
Browse files Browse the repository at this point in the history
* Add support for Tagesgeld savings account with the new csv format

* Add test for identifying Tagesgeld savings account with the new csv format

---------

Co-authored-by: Max Stabel <M4a1x@users.noreply.github.com>
  • Loading branch information
M4a1x and M4a1x authored Feb 1, 2025
1 parent 257e482 commit 5b1a679
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion beancount_dkb/extractors/ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def identify(self) -> bool:
metadata_lines = self.extract_metadata_lines()

regex = re.compile(
r'^"Girokonto"'
r'^"(Girokonto|Tagesgeld)"'
+ self.csv_delimiter
+ '"'
+ re.escape(re.sub(r"\s+", "", self.iban, flags=re.UNICODE))
Expand Down
31 changes: 31 additions & 0 deletions tests/test_ec_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ def tmp_file_multiple_transaction(tmp_path, header):
return tmp_file


@pytest.fixture
def tmp_file_tagesgeld_no_transactions(tmp_path, header):
"""
Fixture for a temporary file for a Savings account (i.e. "Tagesgeld")
with no transactions
"""

tmp_file = tmp_path / f"{IBAN}.csv"
tmp_file.write_text(
_format(
"""
"Tagesgeld"{delimiter}"{iban}"
""
"Kontostand vom 30.06.2023:"{delimiter}"5.000,01 EUR"
""
{header}
""", # NOQA
dict(iban=IBAN, header=header.value, delimiter=header.delimiter),
),
encoding=ENCODING,
)

return tmp_file


def test_file_encoding_raises_deprecation_warning():
with pytest.deprecated_call():
ECImporter(IBAN, "Assets:DKB:EC", file_encoding="utf-8")
Expand All @@ -115,6 +140,12 @@ def test_identify_correct(tmp_file_single_transaction):
assert importer.identify(tmp_file_single_transaction)


def test_identify_tagesgeld(tmp_file_tagesgeld_no_transactions):
importer = ECImporter(IBAN, "Assets:DKB:Savings")

assert importer.identify(tmp_file_tagesgeld_no_transactions)


def test_extract_no_transactions(tmp_file_no_transactions):
importer = ECImporter(IBAN, "Assets:DKB:EC")

Expand Down

0 comments on commit 5b1a679

Please sign in to comment.