From a77b9c5ec6874f899f041912eb54a81817ff62aa Mon Sep 17 00:00:00 2001 From: Sylvie Ye Date: Tue, 29 Jan 2019 18:10:33 +0100 Subject: [PATCH] [societegenerale] add 'CREDIT_CONFIANCE' as TYPE_REVOLVING_CREDIT --- modules/societegenerale/browser.py | 9 ++++---- .../societegenerale/pages/accounts_list.py | 23 +++++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/societegenerale/browser.py b/modules/societegenerale/browser.py index 505f5f8c30..6e1ee76b28 100644 --- a/modules/societegenerale/browser.py +++ b/modules/societegenerale/browser.py @@ -221,10 +221,7 @@ def iter_history(self, account): yield tr return - if account.type == account.TYPE_REVOLVING_CREDIT: - if account._loan_type == 'PR_CONSO': - return - + if account.type == account.TYPE_REVOLVING_CREDIT and account._loan_type != 'PR_CONSO': # request to get json is not available yet, old request to get html response self.account_details_page.go(params={'idprest': account._prestation_id}) self.page.go_history_page() @@ -232,6 +229,10 @@ def iter_history(self, account): yield tr return + if account.type == account.TYPE_REVOLVING_CREDIT and not account._is_json_histo: + # Waiting for account with transactions + return + if account.type == account.TYPE_CARD: self.history.go(params={'b64e200_prestationIdTechnique': account.parent._internal_id}) for summary_card_tr in self.page.iter_card_transactions(card_number=account.number): diff --git a/modules/societegenerale/pages/accounts_list.py b/modules/societegenerale/pages/accounts_list.py index 967cedda35..88277d4803 100644 --- a/modules/societegenerale/pages/accounts_list.py +++ b/modules/societegenerale/pages/accounts_list.py @@ -114,6 +114,7 @@ class item(ItemElement): 'ASSURANCE_VIE_SOGECAP_GENERAL': Account.TYPE_LIFE_INSURANCE, 'RESERVEA': Account.TYPE_REVOLVING_CREDIT, 'COMPTE_ALTERNA': Account.TYPE_REVOLVING_CREDIT, + 'CREDIT_CONFIANCE': Account.TYPE_REVOLVING_CREDIT, 'AVANCE_PATRIMOINE': Account.TYPE_REVOLVING_CREDIT, 'PRET_EXPRESSO': Account.TYPE_CONSUMER_CREDIT, 'PRET_EVOLUTIF': Account.TYPE_CONSUMER_CREDIT, @@ -140,6 +141,11 @@ def obj__loan_type(self): return Dict('codeFamille')(self) return None + def obj__is_json_histo(self): + # For TYPE_REVOLVING_CREDIT, to get transaction + if Field('type')(self) == Account.TYPE_REVOLVING_CREDIT and \ + not Dict('produit')(self) in ('COMPTE_ALTERNA', 'AVANCE_PATRIMOINE'): + return True class AccountsSynthesesPage(JsonBasePage): def get_account_comings(self): @@ -191,27 +197,40 @@ def get_revolving_account(self, account): loan._internal_id = account._internal_id loan._prestation_id = account._prestation_id loan._loan_type = account._loan_type + loan._is_json_histo = account._is_json_histo if Dict('donnees/tabIdAllPrestations')(self.doc): for acc in Dict('donnees/tabPrestations')(self.doc): if CleanText(Dict('idPrestation'))(acc) == account._prestation_id: + # coming if Dict('encoursFinMois', default=NotAvailable)(acc): loan.coming = eval_decimal_amount('encoursFinMois/valeur', 'encoursFinMois/posDecimale')(acc) + # total amount if Dict('reserveAutorisee', default=NotAvailable)(acc): loan.total_amount = eval_decimal_amount('reserveAutorisee/valeur', 'reserveAutorisee/posDecimale')(acc) + elif Dict('montantAutorise', default=NotAvailable)(acc): + loan.total_amount = eval_decimal_amount('montantAutorise/valeur', 'montantAutorise/posDecimale')(acc) else: loan.total_amount = eval_decimal_amount('reserveMaximum/valeur', 'reserveMaximum/posDecimale')(acc) - loan.available_amount = eval_decimal_amount('reserveDispo/valeur', 'reserveDispo/posDecimale')(acc) + # available amount + if Dict('montantDisponible', default=NotAvailable)(acc): + loan.available_amount = eval_decimal_amount('montantDisponible/valeur', 'montantDisponible/posDecimale')(acc) + else: + loan.available_amount = eval_decimal_amount('reserveDispo/valeur', 'reserveDispo/posDecimale')(acc) + # used amount if Dict('reserveUtilisee', default=NotAvailable)(acc): loan.used_amount = eval_decimal_amount('reserveUtilisee/valeur', 'reserveUtilisee/posDecimale')(acc) + elif Dict('montantUtilise', default=NotAvailable)(acc): + loan.available_amount = eval_decimal_amount('montantUtilise/valeur', 'montantUtilise/posDecimale')(acc) + # next payment amount if Dict('prochaineEcheance', default=NotAvailable)(acc): loan.next_payment_amount = eval_decimal_amount('prochaineEcheance/valeur', 'prochaineEcheance/posDecimale')(acc) - else: + elif Dict('montantMensualite', default=NotAvailable)(acc): loan.next_payment_amount = eval_decimal_amount('montantMensualite/valeur', 'montantMensualite/posDecimale')(acc) loan.last_payment_amount = loan.next_payment_amount -- GitLab