summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2017-11-10 10:02:43 +0100
committerYves Fischer <yvesf-git@xapek.org>2017-11-10 10:02:43 +0100
commit7b41c5dc809159028566367fbf1f60df67eba1cb (patch)
tree25e9fb64a046cdbb753ac979228d3ce8b4daf748
parenta003cf9f8caf45a3792793d2a58ae6f8f71cfc15 (diff)
downloadfinanzstatus-7b41c5dc809159028566367fbf1f60df67eba1cb.tar.gz
finanzstatus-7b41c5dc809159028566367fbf1f60df67eba1cb.zip
improve transaction details parsing
-rw-r--r--transaction_details.py19
-rwxr-xr-xtransfers.py2
2 files changed, 6 insertions, 15 deletions
diff --git a/transaction_details.py b/transaction_details.py
index a7ecf6c..dec0ee7 100644
--- a/transaction_details.py
+++ b/transaction_details.py
@@ -40,21 +40,12 @@ VERWENDUNGSZWECK_KEYS = {
def parse_transaction_details(details):
detail_str = ''.join(d.strip() for d in details.splitlines())
- result = {}
- for key, value in DETAIL_KEYS.items():
- result[value] = None
- for key, value in VERWENDUNGSZWECK_KEYS.items():
- result[value] = None
+ detail_str = detail_str[3:]
+ result = dict(map(lambda k: [k,None], DETAIL_KEYS.values()))
+ result.update(dict(map(lambda k: [k,None], VERWENDUNGSZWECK_KEYS.values())))
pre_result = {}
- segment = ''
- segment_type = ''
- for index, char in enumerate(detail_str):
- if char != '?':
- segment += char
- continue
- pre_result[segment_type] = segment if not segment_type else segment[2:]
- segment_type = detail_str[index+1] + detail_str[index+2]
- segment = ''
+ for segment in detail_str.split('?'):
+ pre_result[segment[0:2]] = segment[2:]
for key, value in pre_result.items():
if key in DETAIL_KEYS:
result[DETAIL_KEYS[key]] = value
diff --git a/transfers.py b/transfers.py
index 3580ce8..e3ee1a1 100755
--- a/transfers.py
+++ b/transfers.py
@@ -31,7 +31,7 @@ class Transaction(p.Model):
def format_message(self):
details = transaction_details.parse_transaction_details(self.sepa_transaction_details)
- return "{accountnumber} {details[Buchungstext]}: {amount_str} {details[Verwendungszweck]}".format(
+ return "{accountnumber} {details[Buchungstext]}: {amount_str} {details[Auftraggeber Name]} {details[Verwendungszweck]}".format(
entry_date=self.sepa_entry_date, accountnumber=self.accountnumber, amount_str=self.sepa_amount_str,
details=details)