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

[societegenerale] retrieve accounts from old website

Some users can't go on new website
parent b3b8f62a
......@@ -177,8 +177,16 @@ def get_accounts_list(self):
account_ibans =
# get accounts coming
if not
# return in old pages to get accounts
self.accounts_main_page.go(params={'NoRedirect': True})
for acc in
yield acc
# get accounts coming
account_comings =
......@@ -211,6 +219,9 @@ def iter_history(self, account):
if account.type == Account.TYPE_PEA and not ('Espèces' in account.label or 'ESPECE' in account.label):
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 @@ def iter_coming(self, account):
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 @@ def on_load(self):
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 @@ def is_accounts(self):
if 'Vous ne disposez pas de compte consultable' in error_msg:
raise NoAccountsException(error_msg)
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
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):
......@@ -155,6 +187,14 @@ def obj__is_json_histo(self):
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