Skip to content

Commit c1508d4

Browse files
committed
Fix Comdirect CSV bugs
1 parent 2215bea commit c1508d4

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

app/static/js/functions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ function getFilteredList() {
7676

7777
let amount_min = document.getElementById('filter-amount-min').value;
7878
if (amount_min) {
79-
amount_min = amount_min.replace(',', '.');
79+
amount_min = amount_min.replace('.', '').replace(',', '.');
8080
query_args = query_args + arg_concat + 'amount_min=' + amount_min;
8181
arg_concat = '&';
8282
}
8383

8484
let amount_max = document.getElementById('filter-amount-max').value;
8585
if (amount_max) {
86-
amount_max = amount_max.replace(',', '.');
86+
amount_max = amount_max.replace('.', '').replace(',', '.');
8787
query_args = query_args + arg_concat + 'amount_max=' + amount_max;
8888
arg_concat = '&';
8989
}

reader/Comdirect.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def from_csv(self, filepath):
2525
ausgelesenen Kontoumsätzen.
2626
"""
2727
result = []
28-
rx = re.compile(r'Auftraggeber\:\s(.*)Buchungstext\:\s(.*)')
28+
rx = re.compile(r'(?:Auftraggeber|Empfänger)\:\s(.*)Buchungstext\:\s(.*)')
2929
with open(filepath, 'r', encoding='Windows-1252') as infile:
3030

3131
# Skip the first 4 lines of the file: Standard Comdirect Header
@@ -37,24 +37,22 @@ def from_csv(self, filepath):
3737
date_format = "%d.%m.%Y"
3838
for row in reader:
3939
date_tx = row['Buchungstag']
40-
if date_tx == "offen":
41-
# Skippe offene Buchungen
40+
if re.match(r'^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$', date_tx) is None:
41+
# Skippe offene Buchungen oder Überschriften
4242
continue
4343

44-
amount = float(row['Umsatz in EUR'].replace(',', '.'))
44+
amount = float(row['Umsatz in EUR'].replace('.', '').replace(',', '.'))
4545
date_tx = self._parse_from_strftime(date_tx, date_format)
4646
valuta = self._parse_from_strftime(row['Wertstellung (Valuta)'], date_format)
47-
48-
text_tx = row['Buchungstext']
49-
match = rx.match(text_tx)
47+
text_tx_match = rx.match(row['Buchungstext'])
5048

5149
line = {
5250
'date_tx': date_tx,
5351
'valuta': valuta,
5452
'art': row['Vorgang'],
55-
'text_tx': match.group(2).strip(),
53+
'text_tx': text_tx_match.group(2).strip(),
5654
'amount': amount,
57-
'peer': match.group(1).strip(),
55+
'peer': text_tx_match.group(1).strip(),
5856
'currency': "EUR",
5957
'parsed': {},
6058
'category': None,

reader/Volksbank_Mittelhessen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def from_csv(self, filepath):
3737
# Skippe offene Buchungen / Hinweise
3838
continue
3939

40-
amount = float(row['Betrag'].replace(',', '.'))
40+
amount = float(row['Betrag'].replace('.', '').replace(',', '.'))
4141
date_tx = datetime.datetime.strptime(
4242
date_tx, date_format
4343
).replace(tzinfo=datetime.timezone.utc).timestamp()

0 commit comments

Comments
 (0)