From 54ad584f4c8ae3285de18728932070a46f1054b0 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 27 Feb 2012 16:34:30 +0100 Subject: [PATCH] Add the new field for Compte Courant --- modules/ing/browser.py | 2 +- modules/ing/pages/account_history.py | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 14e852b6..2555b146 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -89,7 +89,7 @@ class Ing(BaseBrowser): self.location('https://secure.ingdirect.fr/general?command=goToAccount&account=%d&zone=COMPTE' % int(id)) else: raise NotImplementedError() - return self.page.get_operations() + return self.page.get_transactions() # TODO # def get_coming_operations diff --git a/modules/ing/pages/account_history.py b/modules/ing/pages/account_history.py index 3759f6ad..e66514d2 100644 --- a/modules/ing/pages/account_history.py +++ b/modules/ing/pages/account_history.py @@ -27,10 +27,19 @@ from weboob.capabilities.base import NotAvailable __all__ = ['AccountHistoryCC', 'AccountHistoryLA'] + + class AccountHistoryCC(BasePage): + types = { + 'Carte achat': Transaction.TYPE_CARD, + 'Virement': Transaction.TYPE_TRANSFER, + 'Carte retrait': Transaction.TYPE_WITHDRAWAL, + u'Prélèvement': Transaction.TYPE_ORDER, + 'Autre': Transaction.TYPE_UNKNOWN, + } def on_loaded(self): - self.operations = [] + self.transactions = [] table = self.document.findall('//tbody')[0] i = 1 for tr in table.xpath('tr'): @@ -38,22 +47,24 @@ class AccountHistoryCC(BasePage): texte = tr.text_content().split('\n') op = Transaction(id) op.label = texte[2] + op.raw = texte[2] # nothing to parse op.date = date(*reversed([int(x) for x in texte[0].split('/')])) op.category = texte[4] + op.type = self.types.get(texte[4], Transaction.TYPE_UNKNOWN) amount = texte[5].replace('\t','').strip().replace(u'€', '').replace(',', '.').replace(u'\xa0', u'') op.amount = float(amount) - self.operations.append(op) + self.transactions.append(op) i += 1 - def get_operations(self): - return self.operations + def get_transactions(self): + return self.transactions class AccountHistoryLA(BasePage): def on_loaded(self): - self.operations = [] + self.transactions = [] i = 1 history = self.document.xpath('//tr[@align="center"]') history.pop(0) @@ -71,10 +82,10 @@ class AccountHistoryLA(BasePage): op.amount = float(amount) - self.operations.append(op) + self.transactions.append(op) i += 1 - def get_operations(self): - return self.operations + def get_transactions(self): + return self.transactions