diff --git a/weboob/backends/bnporc/pages/account_coming.py b/weboob/backends/bnporc/pages/account_coming.py
index 522208cf..20ecbf3c 100644
--- a/weboob/backends/bnporc/pages/account_coming.py
+++ b/weboob/backends/bnporc/pages/account_coming.py
@@ -16,6 +16,9 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import re
+from datetime import date
+
from weboob.tools.browser import BasePage
from weboob.capabilities.bank import Operation
@@ -24,6 +27,12 @@ __all__ = ['AccountComing']
class AccountComing(BasePage):
+ LABEL_PATTERNS = [('^FACTURECARTEDU(?P
\d{2})(?P\d{2})(?P\d{2})(?P.*)',
+ u'CB %(yy)s-%(mm)s-%(dd)s: %(text)s'),
+ ('^PRELEVEMENT(?P.*)', 'Order: %(text)s'),
+ ('^ECHEANCEPRET(?P.*)', u'Loan payment n°%(text)s'),
+ ]
+
def on_loaded(self):
self.operations = []
@@ -32,7 +41,8 @@ class AccountComing(BasePage):
tds = tr.findall('td')
if len(tds) != 3:
continue
- date = tds[0].getchildren()[0].attrib.get('name', '')
+ d = tds[0].getchildren()[0].attrib.get('name', '')
+ d = date(int(d[0:4]), int(d[4:6]), int(d[6:8]))
label = u''
label += tds[1].text or u''
label = label.replace(u'\xa0', u'')
@@ -41,10 +51,16 @@ class AccountComing(BasePage):
if child.tail: label += child.tail
if tds[1].tail: label += tds[1].tail
label = label.strip()
+
+ for pattern, text in self.LABEL_PATTERNS:
+ m = re.match(pattern, label)
+ if m:
+ label = text % m.groupdict()
+
amount = tds[2].text.replace('.', '').replace(',', '.')
operation = Operation(len(self.operations))
- operation.date = date
+ operation.date = d
operation.label = label
operation.amount = float(amount)
self.operations.append(operation)
diff --git a/weboob/backends/bnporc/pages/account_history.py b/weboob/backends/bnporc/pages/account_history.py
index db582b35..49f03405 100644
--- a/weboob/backends/bnporc/pages/account_history.py
+++ b/weboob/backends/bnporc/pages/account_history.py
@@ -16,6 +16,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+from datetime import date
+
from weboob.tools.browser import BasePage
from weboob.capabilities.bank import Operation
@@ -32,8 +34,7 @@ class AccountHistory(BasePage):
tds = tr.findall('td')
if len(tds) != 4:
continue
- date = u''
- date = tds[0].text
+ d = date(*reversed([int(x) for x in tds[0].text.split('/')]))
label = u''
label += tds[1].text
label = label.replace(u'\xa0', u'')
@@ -51,7 +52,7 @@ class AccountHistory(BasePage):
else:
operation.amount = - float(amount)
- operation.date = date
+ operation.date = d
operation.label = label
self.operations.append(operation)
diff --git a/weboob/capabilities/bank.py b/weboob/capabilities/bank.py
index c260ed30..ba1a0805 100644
--- a/weboob/capabilities/bank.py
+++ b/weboob/capabilities/bank.py
@@ -16,7 +16,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-from datetime import datetime
+from datetime import datetime, date
from .base import IBaseCap, CapBaseObject
@@ -48,7 +48,7 @@ class Account(CapBaseObject):
class Operation(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
- self.add_field('date', (basestring,datetime))
+ self.add_field('date', (basestring,datetime,date))
self.add_field('label', unicode)
self.add_field('amount', float)
@@ -59,7 +59,7 @@ class Transfer(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('amount', float)
- self.add_field('date', (basestring,datetime))
+ self.add_field('date', (basestring,datetime,date))
self.add_field('origin', (int,long,basestring))
self.add_field('recipient', (int,long,basestring))