diff --git a/modules/bp/pages/accounthistory.py b/modules/bp/pages/accounthistory.py
index 6eb1ccbd..ce5f1471 100644
--- a/modules/bp/pages/accounthistory.py
+++ b/modules/bp/pages/accounthistory.py
@@ -18,19 +18,35 @@
# along with weboob. If not, see .
-from decimal import Decimal
-from datetime import date
import re
-from weboob.capabilities.bank import Transaction
+from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.tools.browser import BasePage
__all__ = ['AccountHistory']
-class AccountHistory(BasePage):
+class Transaction(FrenchTransaction):
+ PATTERNS = [(re.compile(u'^(?PCHEQUE) (?P.*)'), FrenchTransaction.TYPE_CHECK),
+ (re.compile(r'^(?PACHAT CB) (?P.*) (?P\d{2})\.(?P\d{2}).(?P\d{2})'),
+ FrenchTransaction.TYPE_CARD),
+ (re.compile('^(?P(PRELEVEMENT DE|TELEREGLEMENT|TIP)) (?P.*)'),
+ FrenchTransaction.TYPE_ORDER),
+ (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT),
+ (re.compile('^CARTE \w+ (?P\d{2})/(?P\d{2})/(?P\d{2}) A (?P\d+)H(?P\d+) (?PRETRAIT DAB) (?P.*)'),
+ FrenchTransaction.TYPE_WITHDRAWAL),
+ (re.compile('^(?PRETRAIT DAB) (?P\d{2})/(?P\d{2})/(?P\d{2}) (?P\d+)H(?P\d+) (?P.*)'),
+ FrenchTransaction.TYPE_WITHDRAWAL),
+ (re.compile('^(?PVIR(EMEN)?T?) (DE |POUR )?(?P.*)'),
+ FrenchTransaction.TYPE_TRANSFER),
+ (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK),
+ (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK),
+ (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK),
+ (re.compile('^(?PREMISE DE CHEQUE) (?P.*)'), FrenchTransaction.TYPE_DEPOSIT),
+ ]
+class AccountHistory(BasePage):
def get_history(self):
mvt_table = self.document.xpath("//table[@id='mouvements']", smart_strings=False)[0]
mvt_ligne = mvt_table.xpath("./tbody/tr")
@@ -38,13 +54,9 @@ class AccountHistory(BasePage):
operations = []
for mvt in mvt_ligne:
- operation = Transaction(len(operations))
-
- d = mvt.xpath("./td/span")[0].text.strip().split('/')
- operation.date = date(*reversed([int(x) for x in d]))
-
- tmp = mvt.xpath("./td/span")[1]
- operation.raw = unicode(self.parser.tocleanstring(tmp).strip())
+ op = Transaction(len(operations))
+ op.parse(date=mvt.xpath("./td/span")[0].text.strip(),
+ raw=unicode(self.parser.tocleanstring(mvt.xpath('./td/span')[1]).strip()))
r = re.compile(r'\d+')
@@ -55,11 +67,8 @@ class AccountHistory(BasePage):
for t in tmp:
if r.search(t.text):
amount = t.text
- amount = ''.join(amount.replace('.', '').replace(',', '.').split())
- if amount[0] == "-":
- operation.amount = - Decimal(amount[1:])
- else:
- operation.amount = Decimal(amount)
- operations.append(operation)
+ op.set_amount(amount)
+
+ operations.append(op)
return operations