adding support for sub account
This commit is contained in:
parent
5158aabe98
commit
f3f19f450f
2 changed files with 75 additions and 42 deletions
|
|
@ -22,7 +22,7 @@ import urllib
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
|
|
||||||
from .pages import LoginPage, AccountsPage, TransactionsPage, UnavailablePage
|
from .pages import LoginPage, AccountsPage, TransactionsPage, CBTransactionsPage, UnavailablePage
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AXABanque']
|
__all__ = ['AXABanque']
|
||||||
|
|
@ -31,12 +31,13 @@ __all__ = ['AXABanque']
|
||||||
class AXABanque(BaseBrowser):
|
class AXABanque(BaseBrowser):
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
DOMAIN = 'www.axabanque.fr'
|
DOMAIN = 'www.axabanque.fr'
|
||||||
PAGES = {'https?://www.axabanque.fr/connexion/index.html.*': LoginPage,
|
PAGES = {'https?://www.axabanque.fr/connexion/index.html.*': LoginPage,
|
||||||
'https?://www.axabanque.fr/login_errors/indisponibilite.*': UnavailablePage,
|
'https?://www.axabanque.fr/login_errors/indisponibilite.*': UnavailablePage,
|
||||||
'https?://www.axabanque.fr/.*page-indisponible.html.*': UnavailablePage,
|
'https?://www.axabanque.fr/.*page-indisponible.html.*': UnavailablePage,
|
||||||
'https?://www.axabanque.fr/transactionnel/client/liste-comptes.html': AccountsPage,
|
'https?://www.axabanque.fr/transactionnel/client/liste-comptes.html': AccountsPage,
|
||||||
'https?://www.axabanque.fr/webapp/axabanque/jsp/panorama.faces': TransactionsPage,
|
'https?://www.axabanque.fr/webapp/axabanque/jsp/panorama.faces': TransactionsPage,
|
||||||
'https?://www.axabanque.fr/webapp/axabanque/jsp/detail.*.faces': TransactionsPage,
|
'https?://www.axabanque.fr/webapp/axabanque/jsp/detailCarteBleu.*.faces': CBTransactionsPage,
|
||||||
|
'https?://www.axabanque.fr/webapp/axabanque/jsp/detail(?!CarteBleu).*.faces': TransactionsPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_logged(self):
|
def is_logged(self):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||||
from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard
|
from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage', 'UnavailablePage']
|
__all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage', 'CBTransactionsPage', 'UnavailablePage']
|
||||||
|
|
||||||
|
|
||||||
class BasePage(_BasePage):
|
class BasePage(_BasePage):
|
||||||
|
|
@ -110,44 +110,49 @@ class AccountsPage(BasePage):
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
for table in self.document.getroot().cssselect('div#table-panorama table.table-client'):
|
for table in self.document.getroot().cssselect('div#table-panorama table.table-produit'):
|
||||||
account = Account()
|
|
||||||
|
|
||||||
tds = table.xpath('./tbody/tr')[0].findall('td')
|
tds = table.xpath('./tbody/tr')[0].findall('td')
|
||||||
if len(tds) < 3:
|
if len(tds) < 3:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
link = table.xpath('./tfoot//a')[0]
|
boxes = table.xpath('./tbody//tr')
|
||||||
if not 'onclick' in link.attrib:
|
foot = table.xpath('./tfoot//tr')
|
||||||
continue
|
|
||||||
|
|
||||||
args = self.js2args(link.attrib['onclick'])
|
for box in boxes:
|
||||||
|
account = Account()
|
||||||
|
|
||||||
self.logger.debug('Args: %r' % args)
|
if len(box.xpath('.//a')) != 0 and 'onclick' in box.xpath('.//a')[0].attrib:
|
||||||
if not 'paramNumCompte' in args:
|
args = self.js2args(box.xpath('.//a')[0].attrib['onclick'])
|
||||||
try:
|
account.label = u'{0} {1}'.format(unicode(table.xpath('./caption')[0].text.strip()), unicode(box.xpath('.//a')[0].text.strip()))
|
||||||
label = unicode(table.xpath('./caption')[0].text.strip())
|
elif len(foot[0].xpath('.//a')) != 0 and 'onclick' in foot[0].xpath('.//a')[0].attrib:
|
||||||
except Exception:
|
args = self.js2args(foot[0].xpath('.//a')[0].attrib['onclick'])
|
||||||
label = 'Unable to determine'
|
account.label = unicode(table.xpath('./caption')[0].text.strip())
|
||||||
self.logger.warning('Unable to get account ID for %r' % label)
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
account.id = args['paramNumCompte']
|
self.logger.debug('Args: %r' % args)
|
||||||
account.label = unicode(table.xpath('./caption')[0].text.strip())
|
if not 'paramNumCompte' in args:
|
||||||
|
try:
|
||||||
|
label = unicode(table.xpath('./caption')[0].text.strip())
|
||||||
|
except Exception:
|
||||||
|
label = 'Unable to determine'
|
||||||
|
self.logger.warning('Unable to get account ID for %r' % label)
|
||||||
|
continue
|
||||||
|
|
||||||
account_type_str = table.attrib['class'].split(' ')[-1][len('tableaux-comptes-'):]
|
account.id = args['paramNumCompte'] + args['paramNumContrat']
|
||||||
account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
|
account_type_str = table.attrib['class'].split(' ')[-1][len('tableaux-comptes-'):]
|
||||||
|
account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
|
||||||
|
|
||||||
currency_title = table.xpath('./thead//th[@class="montant"]')[0].text.strip()
|
currency_title = table.xpath('./thead//th[@class="montant"]')[0].text.strip()
|
||||||
m = re.match('Montant \((\w+)\)', currency_title)
|
m = re.match('Montant \((\w+)\)', currency_title)
|
||||||
if not m:
|
if not m:
|
||||||
self.logger.warning('Unable to parse currency %r' % currency_title)
|
self.logger.warning('Unable to parse currency %r' % currency_title)
|
||||||
else:
|
else:
|
||||||
account.currency = account.get_currency(m.group(1))
|
account.currency = account.get_currency(m.group(1))
|
||||||
|
|
||||||
account.balance = Decimal(FrenchTransaction.clean_amount(u''.join([txt.strip() for txt in tds[-1].itertext()])))
|
account.balance = Decimal(FrenchTransaction.clean_amount(u''.join([txt.strip() for txt in box.cssselect("td.montant")[0].itertext()])))
|
||||||
account._args = args
|
account._args = args
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
|
|
||||||
class Transaction(FrenchTransaction):
|
class Transaction(FrenchTransaction):
|
||||||
|
|
@ -249,3 +254,30 @@ class TransactionsPage(BasePage):
|
||||||
t.set_amount(credit, debit)
|
t.set_amount(credit, debit)
|
||||||
|
|
||||||
yield t
|
yield t
|
||||||
|
|
||||||
|
class CBTransactionsPage(TransactionsPage):
|
||||||
|
COL_CB_CREDIT = 2
|
||||||
|
|
||||||
|
def get_history(self):
|
||||||
|
tables = self.document.xpath('//table[@id="idDetail:dataCumulAchat"]')
|
||||||
|
transactions =list()
|
||||||
|
for tr in tables[0].xpath('.//tr'):
|
||||||
|
tds = tr.findall('td')
|
||||||
|
if len(tds) < 3:
|
||||||
|
continue
|
||||||
|
|
||||||
|
t = Transaction(0)
|
||||||
|
date = u''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()])
|
||||||
|
raw = u''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()])
|
||||||
|
credit = u''.join([txt.strip() for txt in tds[self.COL_CB_CREDIT].itertext()])
|
||||||
|
debit = ""
|
||||||
|
|
||||||
|
t.parse(date, re.sub(r'[ ]+', ' ', raw))
|
||||||
|
t.set_amount(credit, debit)
|
||||||
|
transactions.append(t)
|
||||||
|
|
||||||
|
for histo in super(CBTransactionsPage, self).get_history():
|
||||||
|
transactions.append(histo)
|
||||||
|
|
||||||
|
transactions.sort(key=lambda transaction: transaction.date, reverse=True)
|
||||||
|
return iter(transactions)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue