support empty dates for transactions
This commit is contained in:
parent
3870559155
commit
63dc4e05da
2 changed files with 11 additions and 3 deletions
|
|
@ -91,7 +91,7 @@ class TransactionsFormatter(IFormatter):
|
|||
label = obj.label
|
||||
if not label and hasattr(obj, 'raw'):
|
||||
label = obj.raw
|
||||
return ' %-10s %-12s %-50s %10.2f' % (obj.date.strftime('%Y-%m-%d'), _type[:12], label[:50], obj.amount)
|
||||
return ' %-10s %-12s %-50s %10.2f' % (obj.date.strftime('%Y-%m-%d') if not empty(obj.date) else '', _type[:12], label[:50], obj.amount)
|
||||
|
||||
|
||||
class TransferFormatter(IFormatter):
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import re
|
|||
from weboob.capabilities.bank import Transaction
|
||||
from weboob.capabilities import NotAvailable
|
||||
from weboob.tools.misc import to_unicode
|
||||
from weboob.tools.log import getLogger
|
||||
|
||||
|
||||
__all__ = ['FrenchTransaction']
|
||||
|
|
@ -36,6 +37,10 @@ class FrenchTransaction(Transaction):
|
|||
"""
|
||||
PATTERNS = []
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
Transaction.__init__(self, *args, **kwargs)
|
||||
self.logger = getLogger('FrenchTransaction')
|
||||
|
||||
@classmethod
|
||||
def clean_amount(klass, text):
|
||||
"""
|
||||
|
|
@ -87,8 +92,11 @@ class FrenchTransaction(Transaction):
|
|||
date = datetime.date(int(date[4:8]), int(date[2:4]), int(date[0:2]))
|
||||
elif '/' in date:
|
||||
date = datetime.date(*reversed([int(x) for x in date.split('/')]))
|
||||
if date.year < 100:
|
||||
date = date.replace(year=2000 + date.year)
|
||||
if not isinstance(date, (datetime.date, datetime.datetime)):
|
||||
self.logger.warning('Unable to parse date %r' % date)
|
||||
date = NotAvailable
|
||||
elif date.year < 100:
|
||||
date = date.replace(year=2000 + date.year)
|
||||
|
||||
self.date = date
|
||||
self.rdate = date
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue