support CIF accounts

This commit is contained in:
Romain Bignon 2012-04-28 15:25:49 +02:00
commit 15f536d09b
2 changed files with 19 additions and 2 deletions

View file

@ -140,6 +140,9 @@ class BNPorc(BaseBrowser):
return None
def iter_history(self, id):
if id is None:
return iter([])
if not self.is_on_page(AccountsList):
self.location('/NSFR?Action=DSP_VGLOBALE')
@ -178,6 +181,9 @@ class BNPorc(BaseBrowser):
return self.page.iter_operations()
def iter_coming_operations(self, id):
if id is None:
return iter([])
if not self.is_on_page(AccountsList):
self.location('/NSFR?Action=DSP_VGLOBALE')
execution = self.page.get_execution_id()

View file

@ -18,6 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
import re
from decimal import Decimal
from weboob.capabilities.bank import Account
@ -50,12 +51,22 @@ class AccountsList(BasePage):
def _parse_account(self, tr):
account = Account()
account.id = tr.xpath('.//td[@class="libelleCompte"]/input')[0].attrib['id'][len('libelleCompte'):]
account._link_id = account.id
if len(str(account.id)) == 23:
account.id = str(account.id)[5:21]
account.label = u''+tr.xpath('.//td[@class="libelleCompte"]/a')[0].text.strip()
a = tr.xpath('.//td[@class="libelleCompte"]/a')[0]
m = re.match(r'javascript:goToStatements\(\'(\d+)\'', a.get('onclick', ''))
if m:
account._link_id = m.group(1)
else:
# Can't get history for this account.
account._link_id = None
# To prevent multiple-IDs for CIF (for example), add an arbitrary char in ID.
account.id += 'C'
account.label = u''+a.text.strip()
tds = tr.findall('td')
account.balance = self._parse_amount(tds[3].find('a'))