Commit 0ceb3e67 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by ntome

[bred] Cosmetic changes

parent a0022fe8
......@@ -43,24 +43,24 @@ __all__ = ['BredBrowser']
class BredBrowser(LoginBrowser):
BASEURL = 'https://www.bred.fr'
home = URL('/$', HomePage)
login = URL('/transactionnel/Authentication', LoginPage)
error = URL('.*gestion-des-erreurs/erreur-pwd',
'.*gestion-des-erreurs/opposition',
'/pages-gestion-des-erreurs/erreur-technique',
'/pages-gestion-des-erreurs/message-tiers-oppose', ErrorPage)
universe = URL('/transactionnel/services/applications/menu/getMenuUnivers', UniversePage)
token = URL(r'/transactionnel/services/rest/User/nonce\?random=(?P<timestamp>.*)', TokenPage)
move_universe = URL('/transactionnel/services/applications/listes/(?P<key>.*)/default', MoveUniversePage)
switch = URL('/transactionnel/services/rest/User/switch', SwitchPage)
loans = URL('/transactionnel/services/applications/prets/liste', LoansPage)
accounts = URL('/transactionnel/services/rest/Account/accounts', AccountsPage)
iban = URL('/transactionnel/services/rest/Account/account/(?P<number>.*)/iban', IbanPage)
life_insurances = URL('/transactionnel/services/applications/avoirsPrepar/getAvoirs', LifeInsurancesPage)
search = URL('/transactionnel/services/applications/operations/getSearch/', SearchPage)
profile = URL('/transactionnel/services/rest/User/user', ProfilePage)
emails = URL('/transactionnel/services/applications/gestionEmail/getAdressesMails', EmailsPage)
error_code = URL('/.*\?errorCode=.*', ErrorCodePage)
home = URL(r'/$', HomePage)
login = URL(r'/transactionnel/Authentication', LoginPage)
error = URL(r'.*gestion-des-erreurs/erreur-pwd',
r'.*gestion-des-erreurs/opposition',
r'/pages-gestion-des-erreurs/erreur-technique',
r'/pages-gestion-des-erreurs/message-tiers-oppose', ErrorPage)
universe = URL(r'/transactionnel/services/applications/menu/getMenuUnivers', UniversePage)
token = URL(r'/transactionnel/services/rest/User/nonce\?random=(?P<timestamp>.*)', TokenPage)
move_universe = URL(r'/transactionnel/services/applications/listes/(?P<key>.*)/default', MoveUniversePage)
switch = URL(r'/transactionnel/services/rest/User/switch', SwitchPage)
loans = URL(r'/transactionnel/services/applications/prets/liste', LoansPage)
accounts = URL(r'/transactionnel/services/rest/Account/accounts', AccountsPage)
iban = URL(r'/transactionnel/services/rest/Account/account/(?P<number>.*)/iban', IbanPage)
life_insurances = URL(r'/transactionnel/services/applications/avoirsPrepar/getAvoirs', LifeInsurancesPage)
search = URL(r'/transactionnel/services/applications/operations/getSearch/', SearchPage)
profile = URL(r'/transactionnel/services/rest/User/user', ProfilePage)
emails = URL(r'/transactionnel/services/applications/gestionEmail/getAdressesMails', EmailsPage)
error_code = URL(r'/.*\?errorCode=.*', ErrorCodePage)
def __init__(self, accnum, login, password, *args, **kwargs):
kwargs['username'] = login
......
......@@ -38,21 +38,22 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile(r'^.*Virement (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
(re.compile(r'PRELEV SEPA (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'.*Prélèvement.*'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'^(REGL|Rgt)(?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'^(?P<text>.*) Carte \d+\s+ LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2})'),
FrenchTransaction.TYPE_CARD),
(re.compile(r'^Débit mensuel.*'), FrenchTransaction.TYPE_CARD_SUMMARY),
(re.compile(r"^Retrait d'espèces à un DAB (?P<text>.*) CARTE [X\d]+ LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2})"),
FrenchTransaction.TYPE_WITHDRAWAL),
(re.compile(r'^Paiement de chèque (?P<text>.*)'), FrenchTransaction.TYPE_CHECK),
(re.compile(r'^(Cotisation|Intérêts) (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
(re.compile(r'^(Remise Chèque|Remise de chèque)\s*(?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
(re.compile(r'^Versement (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
(re.compile(r'^(?P<text>.*)LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2})\s*(?P<text2>.*)'),
FrenchTransaction.TYPE_UNKNOWN),
PATTERNS = [
(re.compile(r'^.*Virement (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
(re.compile(r'PRELEV SEPA (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'.*Prélèvement.*'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'^(REGL|Rgt)(?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'^(?P<text>.*) Carte \d+\s+ LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2})'),
FrenchTransaction.TYPE_CARD),
(re.compile(r'^Débit mensuel.*'), FrenchTransaction.TYPE_CARD_SUMMARY),
(re.compile(r"^Retrait d'espèces à un DAB (?P<text>.*) CARTE [X\d]+ LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2})"),
FrenchTransaction.TYPE_WITHDRAWAL),
(re.compile(r'^Paiement de chèque (?P<text>.*)'), FrenchTransaction.TYPE_CHECK),
(re.compile(r'^(Cotisation|Intérêts) (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
(re.compile(r'^(Remise Chèque|Remise de chèque)\s*(?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
(re.compile(r'^Versement (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
(re.compile(r'^(?P<text>.*)LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2})\s*(?P<text2>.*)'),
FrenchTransaction.TYPE_UNKNOWN),
]
......@@ -135,7 +136,7 @@ class AccountsPage(MyJsonPage):
accounts_list = []
for content in self.get_content():
for content in self.get_content():
if accnum != '00000000000' and content['numero'] != accnum:
continue
for poste in content['postes']:
......@@ -266,12 +267,12 @@ class SearchPage(LoggedPage, JsonPage):
raise ParseError('There are several transactions with the same ID, probably an infinite loop')
seen.add(t.id)
d = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation'))/1000)
d = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation')) / 1000)
op['details'] = [re.sub(r'\s+', ' ', i).replace('\x00', '') for i in op['details'] if i] # sometimes they put "null" elements...
label = re.sub(r'\s+', ' ', op['libelle']).replace('\x00', '')
raw = ' '.join([label] + op['details'])
t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit'))/1000)
vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation')))/1000)
t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit')) / 1000)
vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation'))) / 1000)
t.parse(d, raw, vdate=vdate)
t.amount = Decimal(str(op['montant']))
if 'categorie' in op:
......
......@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.capabilities.bank import CapBankWealth, AccountNotFound, Account
from weboob.capabilities.base import find_object
......@@ -38,21 +39,23 @@ class BredModule(Module, CapBankWealth, CapProfile):
VERSION = '1.6'
DESCRIPTION = u'Bred'
LICENSE = 'LGPLv3+'
CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Mot de passe'),
Value('website', label=u"Site d'accès", default='bred',
choices={'bred': 'BRED', 'dispobank': 'DispoBank'}),
Value('accnum', label=u'Numéro du compte bancaire (optionnel)', default='', masked=False)
)
BROWSERS = {'bred': BredBrowser,
'dispobank': DispoBankBrowser,
}
CONFIG = BackendConfig(
ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Mot de passe'),
Value('website', label="Site d'accès", default='bred',
choices={'bred': 'BRED', 'dispobank': 'DispoBank'}),
Value('accnum', label='Numéro du compte bancaire (optionnel)', default='', masked=False),
)
BROWSERS = {
'bred': BredBrowser,
'dispobank': DispoBankBrowser,
}
def create_default_browser(self):
self.BROWSER = self.BROWSERS[self.config['website'].get()]
return self.create_browser(self.config['accnum'].get().replace(' ','').zfill(11),
return self.create_browser(self.config['accnum'].get().replace(' ', '').zfill(11),
self.config['login'].get(),
self.config['password'].get())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment