diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2017-11-13 23:18:37 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2017-11-14 12:25:14 +0100 |
commit | 48364b6e52414db2f104ab0d6817905051651898 (patch) | |
tree | 4f9289b41f87e5e402a237e6eabfd6793650e54e /transfers.py | |
parent | 1eba5e9ea7990162bfc407dc557df14bf25d41d7 (diff) | |
download | finanzstatus-48364b6e52414db2f104ab0d6817905051651898.tar.gz finanzstatus-48364b6e52414db2f104ab0d6817905051651898.zip |
improve code style
Diffstat (limited to 'transfers.py')
-rwxr-xr-x | transfers.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/transfers.py b/transfers.py index fbf72b6..3271832 100755 --- a/transfers.py +++ b/transfers.py @@ -26,14 +26,16 @@ class Transaction(p.Model): created_date = p.DateField(default=datetime.date.today) accountnumber = p.CharField() sepa_entry_date = p.DateField() - sepa_amount_str = p.CharField() + sepa_amount = p.DecimalField() sepa_transaction_details = p.CharField() + sepa_status = p.CharField() + sepa_currency = p.CharField() def format_message(self): details = transaction_details.parse_transaction_details(self.sepa_transaction_details) - 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) + return '{transaction[accountnumber]} {details[Buchungstext]}: {transaction[sepa_amount]} ' \ + '{transaction[sepa_currency]} {details[Auftraggeber Name]} {details[Verwendungszweck]}'.format( + transaction=self._data, details=details) class Meta: database = db @@ -61,14 +63,13 @@ transactions = f.get_statement(account, last_transaction_date, datetime.date.tod new_transactions = [] for t in transactions: - y, m, d, *_ = t.data['entry_date'].timetuple() - entry_date = datetime.date(y, m, d) filter_pred = { 'accountnumber': config['bank']['accountnumber'], - 'sepa_entry_date': entry_date, + 'sepa_entry_date': datetime.date.fromordinal(t.data['entry_date'].toordinal()), 'sepa_transaction_details': t.data['transaction_details'], } - data = {'sepa_amount_str': str(t.data['amount'])} + data = {'sepa_amount': t.data['amount'].amount, 'sepa_status': t.data['status'], + 'sepa_currency': t.data['currency']} try: record = Transaction.get(**filter_pred) record.update(data) |