Skip to content

Commit 9b762cf

Browse files
committed
Comdirect import enhancement and first filtering on parsed keys
1 parent 7476778 commit 9b762cf

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

app/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ def tag_and_cat(iban) -> dict:
461461
category=custom_rule.get('category'),
462462
tags=custom_rule.get('tags'),
463463
filters=custom_rule.get('filters'),
464-
parsed_keys=custom_rule.get('parsed_keys'),
465-
parsed_vals=custom_rule.get('parsed_vals'),
464+
parsed_keys=list(custom_rule.get('parsed', {}).keys()),
465+
parsed_vals=list(custom_rule.get('parsed', {}).values()),
466466
multi=custom_rule.get('multi', 'AND'),
467467
prio=custom_rule.get('prio', 1),
468468
prio_set=custom_rule.get('prio_set'),

reader/Comdirect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def from_pdf(self, filepath):
9393
pages="2-end",
9494
flavor="stream",
9595
row_tol=10,
96-
columns=["115,187,305,500"]
96+
columns=["115,187,305,500"]*16 #TODO: Hack-araound: https://github.com/atlanhq/camelot/issues/357#issuecomment-520986016 # disable=line-too-long
9797
)
9898

9999
if not tables:
@@ -121,12 +121,13 @@ def from_pdf(self, filepath):
121121
# Zeilen anhand der Datumsspalte zusammenfügen
122122
# Format:
123123
# all_rows # Table [ Row1: [ Cell1, Cell2, Cell3 ] , Row2: [ ... ] , ... ]
124+
re_datecheck = re.compile(r'^\d{2}\.\d{2}\.\d{4}\s\d{2}\.\d{2}\.\d{4}')
124125
result = []
125126
enumerated_table = enumerate(all_rows[start_index:end_index])
126127
for i, row in enumerated_table:
127128

128-
if row[0] == 'Buchungstag\nValuta':
129-
continue # Skip Header Rows
129+
if re_datecheck.match(row[0]) is None:
130+
continue # Skip Header and unvalid Rows
130131

131132
betrag = float(row[4].replace('.', '').replace(',', '.'))
132133
date_format = "%d.%m.%Y"

tests/helper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ def check_transaktion_list(tx_list):
3535
assert isinstance(text_tx, str) and len(text_tx), \
3636
f"'text_tx' wurde nicht oder falsch erkannt: {text_tx}"
3737

38-
# IBAN
38+
# Gegenkonto
3939
gegenkonto = entry.get('gegenkonto')
40-
assert isinstance(gegenkonto, str) and len(gegenkonto), \
41-
f"'gegenkonto' wurde nicht oder falsch erkannt: {gegenkonto}"
40+
if gegenkonto:
41+
# Nur prüfen, wenn Wert vorhanden
42+
assert isinstance(gegenkonto, str) and len(gegenkonto), \
43+
f"'gegenkonto' wurde nicht oder falsch erkannt: {entry}"
4244

4345
# Wertstellung (optional, aber bei Generic mit dabei)
4446
assert isinstance(entry.get('valuta'), float), (

0 commit comments

Comments
 (0)