summaryrefslogtreecommitdiff
path: root/transfers.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2017-11-09 23:41:34 +0100
committerYves Fischer <yvesf-git@xapek.org>2017-11-09 23:41:34 +0100
commita003cf9f8caf45a3792793d2a58ae6f8f71cfc15 (patch)
tree0875ce492de53eb45404924fac868775ecf31049 /transfers.py
parent11cb0bba576fb9a041c29ba37cf4e1b2e2c387c2 (diff)
downloadfinanzstatus-a003cf9f8caf45a3792793d2a58ae6f8f71cfc15.tar.gz
finanzstatus-a003cf9f8caf45a3792793d2a58ae6f8f71cfc15.zip
improve transaction details formatting
Diffstat (limited to 'transfers.py')
-rwxr-xr-xtransfers.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/transfers.py b/transfers.py
index c14055f..3580ce8 100755
--- a/transfers.py
+++ b/transfers.py
@@ -7,6 +7,7 @@ import logging
from fints.client import FinTS3PinTanClient
import peewee as p
from slixmpp import ClientXMPP
+import transaction_details
logging.basicConfig(level=logging.INFO)
@@ -28,6 +29,12 @@ class Transaction(p.Model):
sepa_amount_str = p.CharField()
sepa_transaction_details = p.CharField()
+ def format_message(self):
+ details = transaction_details.parse_transaction_details(self.sepa_transaction_details)
+ return "{accountnumber} {details[Buchungstext]}: {amount_str} {details[Verwendungszweck]}".format(
+ entry_date=self.sepa_entry_date, accountnumber=self.accountnumber, amount_str=self.sepa_amount_str,
+ details=details)
+
class Meta:
database = db
indexes = ((('accountnumber', 'sepa_entry_date', 'sepa_transaction_details'), True),)
@@ -79,7 +86,7 @@ cl = ClientXMPP(config['jabber']['jid'], config['jabber']['password'])
def session_start(event):
cl.send_presence()
for t in new_transactions:
- message = "{} {} {}".format(t.accountnumber, t.sepa_amount_str, t.sepa_transaction_details)
+ message = t.format_message()
cl.send_message(config['jabber']['recipient'], message, mtype='chat')
logging.info("Sent info %s", message)
cl.disconnect()