diff --git a/modules/boursorama/pages/account_history.py b/modules/boursorama/pages/account_history.py index 4018055b..beda0193 100644 --- a/modules/boursorama/pages/account_history.py +++ b/modules/boursorama/pages/account_history.py @@ -21,13 +21,28 @@ from decimal import Decimal from datetime import date +import re from weboob.tools.browser import BasePage from weboob.capabilities.bank import Transaction +from weboob.tools.capabilities.bank.transactions import FrenchTransaction + __all__ = ['AccountHistory'] +class Transaction(FrenchTransaction): + PATTERNS = [(re.compile(u'^CHQ\. (?P.*)'), FrenchTransaction.TYPE_CHECK), + (re.compile('^(ACHAT|PAIEMENT) CARTE (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), + FrenchTransaction.TYPE_CARD), + (re.compile('^(PRLV|TIP) (?P.*)'), + FrenchTransaction.TYPE_ORDER), + (re.compile('^RETRAIT DAB (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), + FrenchTransaction.TYPE_WITHDRAWAL), + (re.compile('^VIR( SEPA)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), + (re.compile('^AVOIR (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_PAYBACK), + (re.compile('^REM CHQ (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), + ] class AccountHistory(BasePage): @@ -51,18 +66,14 @@ class AccountHistory(BasePage): category = labeldiv.attrib.get('title', '') useless, sep, category = [part.strip() for part in category.partition(':')] - amount = tds[3].text - if amount == None: - amount = tds[4].text - amount = amount.strip(u' \n\t\x80').replace(' ', '').replace(',', '.') + credit = tds[3].text or "" + debit = tds[4].text or "" - # if we don't have exactly one '.', this is not a Decimal try the next operation = Transaction(len(self.operations)) - operation.amount = Decimal(amount) - - operation.date = d - operation.label = label + operation.parse(date=d, raw=label) + operation.set_amount(credit, debit) operation.category = category + self.operations.append(operation) def get_operations(self): diff --git a/weboob/tools/capabilities/bank/transactions.py b/weboob/tools/capabilities/bank/transactions.py index f94a7e98..22097362 100644 --- a/weboob/tools/capabilities/bank/transactions.py +++ b/weboob/tools/capabilities/bank/transactions.py @@ -40,7 +40,7 @@ class FrenchTransaction(Transaction): Clean a string containing an amount. """ return text.replace(' ', '').replace('.','') \ - .replace(',','.').strip(u' \t\u20ac\xa0€\n\r') + .replace(',','.').strip(u' \t\u20ac\xa0\x80€\n\r') def set_amount(self, credit='', debit=''): """