Commit e04bc24f authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Romain Bignon

[barclays] Corrected iter_accounts to fetch IBANs

The is_here() of the LoansPage was catching most other accounts pages,
as a results, we never landed on AbstractAccountPage and therefore,
has_iban() always returned False and we were not fetching the IBANs
anymore.
I changed the is_here so that every account fits with the right Page.
From what I observed, only checking accounts have an IBAN so there is no
need to go to every account's detail page during iter_accounts if we do not
scrape anything on it.
This modification significantly reduces the number of requests and the
duration of iter_accounts().
parent a6da9d52
......@@ -131,11 +131,17 @@ class Barclays(LoginBrowser):
traccounts = []
for account in accounts:
self._go_to_account(account)
if account.type == Account.TYPE_CHECKING:
# Only checking accounts have an IBAN
self._go_to_account(account)
account.iban = self.iban.open().get_iban() if self.page.has_iban() else NotAvailable
if account.type == Account.TYPE_LOAN:
self._go_to_account(account)
account = self.page.get_loan_attributes(account)
if account.type == Account.TYPE_CARD:
self._go_to_account(account)
if self.page.is_immediate_card():
account.type = Account.TYPE_CHECKING
......@@ -143,11 +149,11 @@ class Barclays(LoginBrowser):
continue
account._attached_account = self.page.do_account_attachment([a for a in accounts if a.type == Account.TYPE_CHECKING])
if account.type == Account.TYPE_REVOLVING_CREDIT:
self._go_to_account(account)
account = self.page.get_revolving_attributes(account)
account.iban = self.iban.open().get_iban() if self.page.has_iban() else NotAvailable
traccounts.append(account)
self.cache['accounts'] = traccounts
......
......@@ -109,6 +109,7 @@ class AccountsPage(StatefulPage):
'E VIE MILLEIS': Account.TYPE_LIFE_INSURANCE,
'BANQUE PRIVILEGE': Account.TYPE_REVOLVING_CREDIT,
'PRET PERSONNEL': Account.TYPE_LOAN,
'CREDIT IMMOBILIE': Account.TYPE_LOAN,
}
ACCOUNT_TYPE_TO_STR = {Account.TYPE_MARKET: 'TTR',
Account.TYPE_CARD: 'CRT'
......@@ -470,7 +471,7 @@ class RevolvingAccountPage(AbstractAccountPage):
class LoanAccountPage(AbstractAccountPage):
def is_here(self):
return bool(CleanText('//span[contains(., "Détail compte")]')(self.doc))
return bool(CleanText('//span[contains(., "prêt")]')(self.doc))
def has_iban(self):
return False
......
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