cragr: get IBAN on accounts
This commit is contained in:
parent
7df61bc6cb
commit
dcbab3fdca
1 changed files with 29 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright(C) 2013 Romain Bignon
|
# Copyright(C) 2013-2015 Romain Bignon
|
||||||
#
|
#
|
||||||
# This file is part of weboob.
|
# This file is part of weboob.
|
||||||
#
|
#
|
||||||
|
|
@ -81,6 +81,7 @@ class _AccountsPage(Page):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
|
iban = None
|
||||||
for tr in self.document.xpath('//table[@class="ca-table"]/tr'):
|
for tr in self.document.xpath('//table[@class="ca-table"]/tr'):
|
||||||
if not tr.attrib.get('class', '').startswith('colcelligne'):
|
if not tr.attrib.get('class', '').startswith('colcelligne'):
|
||||||
continue
|
continue
|
||||||
|
|
@ -105,6 +106,19 @@ class _AccountsPage(Page):
|
||||||
a = cols[0].find('a')
|
a = cols[0].find('a')
|
||||||
if a is not None:
|
if a is not None:
|
||||||
account._link = a.attrib['href'].replace(' ', '%20')
|
account._link = a.attrib['href'].replace(' ', '%20')
|
||||||
|
page = self.browser.get_page(self.browser.openurl(account._link))
|
||||||
|
url = page.get_iban_url()
|
||||||
|
if url:
|
||||||
|
page = self.browser.get_page(self.browser.openurl(url))
|
||||||
|
iban = account.iban = page.get_iban()
|
||||||
|
elif iban:
|
||||||
|
# In case there is no available IBAN on this account (for
|
||||||
|
# example saving account), calculate it from the previous
|
||||||
|
# IBAN.
|
||||||
|
bankcode = iban[4:9]
|
||||||
|
counter = iban[9:14]
|
||||||
|
key = 97 - ((int(bankcode) * 89 + int(counter) * 15 + int(account.id) * 3) % 97)
|
||||||
|
account.iban = iban[:4] + bankcode + counter + account.id + str(key)
|
||||||
|
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
|
|
@ -234,6 +248,20 @@ class SavingsPage(_AccountsPage):
|
||||||
|
|
||||||
|
|
||||||
class TransactionsPage(Page):
|
class TransactionsPage(Page):
|
||||||
|
def get_iban_url(self):
|
||||||
|
for link in self.document.xpath('//a[contains(text(), "IBAN")]'):
|
||||||
|
m = re.search("\('([^']+)'", link.get('href', ''))
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_iban(self):
|
||||||
|
s = ''
|
||||||
|
for font in self.document.xpath('(//td[font/b/text()="IBAN"])[1]/table//font'):
|
||||||
|
s += self.parser.tocleanstring(font)
|
||||||
|
return s
|
||||||
|
|
||||||
def get_next_url(self):
|
def get_next_url(self):
|
||||||
links = self.document.xpath('//span[@class="pager"]/a[@class="liennavigationcorpspage"]')
|
links = self.document.xpath('//span[@class="pager"]/a[@class="liennavigationcorpspage"]')
|
||||||
if len(links) < 1:
|
if len(links) < 1:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue