From 63d76431bb5f8166f4213409148b0891bfd5085b Mon Sep 17 00:00:00 2001 From: Sylvie Ye Date: Wed, 24 Jul 2019 17:41:12 +0200 Subject: [PATCH] [societegenerale] use accounts syntheses page as accounts page accounts page (which contains a list of accounts) become less detailed use accounts syntheses page (which contains complicated tree view) as accounts page accounts syntheses page contains all information we need --- modules/societegenerale/browser.py | 15 ++-------- .../societegenerale/pages/accounts_list.py | 28 ++++++------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/modules/societegenerale/browser.py b/modules/societegenerale/browser.py index 7d225ba560..dbd0632171 100644 --- a/modules/societegenerale/browser.py +++ b/modules/societegenerale/browser.py @@ -34,7 +34,7 @@ from .pages.accounts_list import ( AccountsMainPage, AccountDetailsPage, AccountsPage, LoansPage, HistoryPage, - CardHistoryPage, PeaLiquidityPage, AccountsSynthesesPage, + CardHistoryPage, PeaLiquidityPage, AdvisorPage, HTMLProfilePage, CreditPage, CreditHistoryPage, OldHistoryPage, MarketPage, LifeInsurance, LifeInsuranceHistory, LifeInsuranceInvest, LifeInsuranceInvest2, UnavailableServicePage, LoanDetailsPage, @@ -55,8 +55,7 @@ class SocieteGenerale(LoginBrowser, StatesMixin): accounts_main_page = URL(r'/restitution/cns_listeprestation.html', r'/com/icd-web/cbo/index.html', AccountsMainPage) account_details_page = URL(r'/restitution/cns_detailPrestation.html', AccountDetailsPage) - accounts = URL(r'/icd/cbo/data/liste-prestations-navigation-authsec.json', AccountsPage) - accounts_syntheses = URL(r'/icd/cbo/data/liste-prestations-authsec.json\?n10_avecMontant=1', AccountsSynthesesPage) + accounts = URL(r'/icd/cbo/data/liste-prestations-authsec.json\?n10_avecMontant=1', AccountsPage) history = URL(r'/icd/cbo/data/liste-operations-authsec.json', HistoryPage) loans = URL(r'/abm/restit/listeRestitutionPretsNET.json\?a100_isPretConso=(?P\w+)', LoansPage) loan_details_page = URL(r'icd/cbo/data/recapitulatif-prestation-authsec.json', LoanDetailsPage) @@ -189,7 +188,7 @@ def get_accounts_list(self): else: account_ibans = self.page.get_account_ibans_dict() - self.accounts_syntheses.go() + self.accounts.go() if not self.page.is_new_website_available(): # return in old pages to get accounts @@ -198,12 +197,7 @@ def get_accounts_list(self): yield acc return - # get accounts coming - account_comings = self.page.get_account_comings() - accounts = {} - - self.accounts.go() for account in self.page.iter_accounts(): account._parent_id = None for card in self.iter_cards(account): @@ -217,9 +211,6 @@ def get_accounts_list(self): if account._prestation_id in account_ibans: account.iban = account_ibans[account._prestation_id] - if account._prestation_id in account_comings: - account.coming = account_comings[account._prestation_id] - if account.type in (account.TYPE_LOAN, account.TYPE_CONSUMER_CREDIT, ): self.loans.stay_or_go(conso=(account._loan_type == 'PR_CONSO')) account = self.page.get_loan_account(account) diff --git a/modules/societegenerale/pages/accounts_list.py b/modules/societegenerale/pages/accounts_list.py index bdb83d8d2b..4cdb368ac5 100644 --- a/modules/societegenerale/pages/accounts_list.py +++ b/modules/societegenerale/pages/accounts_list.py @@ -118,9 +118,17 @@ class AccountDetailsPage(LoggedPage, HTMLPage): class AccountsPage(JsonBasePage): + def is_new_website_available(self): + if not Dict('commun/raison')(self.doc): + return True + elif 'le service est momentanement indisponible' not in Dict('commun/raison')(self.doc): + return True + self.logger.warning("SG new website is not available yet for this user") + return False + @method class iter_accounts(DictElement): - item_xpath = 'donnees' + item_xpath = 'donnees/syntheseParGroupeProduit/*/prestations' class item(ItemElement): def condition(self): @@ -229,24 +237,6 @@ class item(ItemElement): obj__internal_id = Dict('idTechnique') -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 = {} - - for product in Dict('donnees/syntheseParGroupeProduit')(self.doc): - for prestation in Dict('prestations')(product): - account_comings[Dict('id')(prestation)] = CleanDecimal(Dict('soldes/soldeEnCours'))(prestation) - return account_comings - - class LoanDetailsPage(LoggedPage, JsonPage): def set_loan_details(self, account): # If there are no available details for the loan, the statut will be "NOK" -- GitLab