Commit 44effc5b authored by Sylvie Ye's avatar Sylvie Ye Committed by Romain Bignon

[societegenerale] retrieve accounts from old website

Some users can't go on new website
parent b3b8f62a
......@@ -177,8 +177,16 @@ class SocieteGenerale(LoginBrowser, StatesMixin):
else:
account_ibans = self.page.get_account_ibans_dict()
# get accounts coming
self.accounts_syntheses.go()
if not self.page.is_new_website_available():
# return in old pages to get accounts
self.accounts_main_page.go(params={'NoRedirect': True})
for acc in self.page.iter_accounts():
yield acc
return
# get accounts coming
account_comings = self.page.get_account_comings()
self.accounts.go()
......@@ -211,6 +219,9 @@ class SocieteGenerale(LoginBrowser, StatesMixin):
if account.type == Account.TYPE_PEA and not ('Espèces' in account.label or 'ESPECE' in account.label):
return
if not account._internal_id:
raise BrowserUnavailable()
if account.type in (account.TYPE_LIFE_INSURANCE, account.TYPE_PERP, ):
# request to get json is not available yet, old request to get html response
self.account_details_page.go(params={'idprest': account._prestation_id})
......@@ -254,6 +265,9 @@ class SocieteGenerale(LoginBrowser, StatesMixin):
account.TYPE_CONSUMER_CREDIT, Account.TYPE_PERP, ):
return
if not account._internal_id:
raise BrowserUnavailable()
internal_id = account._internal_id
if account.type == account.TYPE_CARD:
internal_id = account.parent._internal_id
......
......@@ -59,13 +59,15 @@ class JsonBasePage(LoggedPage, JsonPage):
if action and 'BLOCAGE' in action:
raise ActionNeeded()
if 'le service est momentanement indisponible' in reason:
# TODO: iter account on old website
# can't access new website
if ('le service est momentanement indisponible' in reason and
Dict('commun/origine')(self.doc) != 'cbo'):
raise BrowserUnavailable()
assert 'pas encore géré' in reason, 'Error %s is not handled yet' % reason
self.browser.logger.warning('This page is not handled yet by SG')
conditions = (
'pas encore géré' in reason, # this page is not handled by SG api website
'le service est momentanement indisponible' in reason, # can't access new website
)
assert any(conditions), 'Error %s is not handled yet' % reason
class AccountsMainPage(LoggedPage, HTMLPage):
......@@ -77,6 +79,36 @@ class AccountsMainPage(LoggedPage, HTMLPage):
if 'Vous ne disposez pas de compte consultable' in error_msg:
raise NoAccountsException(error_msg)
@method
class iter_accounts(TableElement):
"""iter account on old website"""
head_xpath = '//table[@class="LGNTableA ListePrestation"]//tr[@class="LGNTableHead"]/th'
item_xpath = '//table[@class="LGNTableA ListePrestation"]//tr[has-class("LGNTableRow")]'
col_id = 'Numéro de Compte'
col_type = 'Type de Compte'
col_label = 'Libellé'
col_balance = 'Solde'
class item(ItemElement):
klass = Account
TYPES = {
'LIVRET': Account.TYPE_SAVINGS,
}
obj_id = obj_number = CleanText(TableCell('id'), replace=[(' ', '')])
obj_label = CleanText('.//span[@class="TypeCompte"]')
obj_balance = MyDecimal(TableCell('balance'))
obj_currency = Currency(CleanText(TableCell('balance')))
obj__internal_id = None
def obj_type(self):
for acc_type in self.TYPES:
if acc_type in Field('label')(self).upper():
return self.TYPES[acc_type]
return Account.TYPE_UNKNOWN
class AccountDetailsPage(LoggedPage, HTMLPage):
pass
......@@ -155,6 +187,14 @@ class AccountsPage(JsonBasePage):
return True
class AccountsSynthesesPage(JsonBasePage):
def is_new_website_available(self):
if not Dict('commun/raison')(self.doc):
return True
elif not 'le service est momentanement indisponible' in Dict('commun/raison')(self.doc):
return True
self.logger.warning("SG new website is not available yet for this user")
return False
def get_account_comings(self):
account_comings = {}
......
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