From 2cd005ba47456750451ee60096ba855a3013c8ca Mon Sep 17 00:00:00 2001 From: Maxime Pommier Date: Wed, 10 Jul 2019 19:16:49 +0200 Subject: [PATCH] [bnporc] Add revolving credit details --- modules/bnporc/pp/browser.py | 24 +++++++++++++++++++++--- modules/bnporc/pp/pages.py | 7 +++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/bnporc/pp/browser.py b/modules/bnporc/pp/browser.py index c33870617e..4a24e282a1 100644 --- a/modules/bnporc/pp/browser.py +++ b/modules/bnporc/pp/browser.py @@ -168,6 +168,15 @@ def get_profile(self): return profile raise ProfileMissing(self.page.get_error_message()) + def is_loan(self, account): + return account.type in ( + Account.TYPE_LOAN, + Account.TYPE_MORTGAGE, + Account.TYPE_CONSUMER_CREDIT, + Account.TYPE_REVOLVING_CREDIT + ) + + @need_login def iter_accounts(self): if self.accounts_list is None: @@ -186,10 +195,19 @@ def iter_accounts(self): market_accounts = self.page.get_list() # get the list of 'Comptes Titres' checked_accounts = set() for account in accounts: - if account.type == Account.TYPE_MORTGAGE: + if self.is_loan(account): account = Loan.from_dict(account.to_dict()) - self.loan_details.go(data={'iban': account.id}, loan_type='creditPret') - self.page.fill_loan_details(obj=account) + if account.type in (Account.TYPE_MORTGAGE, Account.TYPE_CONSUMER_CREDIT): + self.loan_details.go(data={'iban': account.id}, loan_type='creditPret') + self.page.fill_loan_details(obj=account) + + elif account.type == Account.TYPE_REVOLVING_CREDIT: + self.loan_details.go(data={'iban': account.id}, loan_type='creditConsoProvisio') + self.page.fill_revolving_details(obj=account) + + elif account.type == Account.TYPE_LOAN: + self.loan_details.go(data={'iban': account.id}, loan_type='creditPretPersoPro') + self.page.fill_loan_details(obj=account) for market_acc in market_accounts: if all(( diff --git a/modules/bnporc/pp/pages.py b/modules/bnporc/pp/pages.py index 559bb4f62e..820ca7ce10 100644 --- a/modules/bnporc/pp/pages.py +++ b/modules/bnporc/pp/pages.py @@ -332,6 +332,8 @@ class item(ItemElement): 'PEL': Account.TYPE_SAVINGS, 'Plan Epargne Retraite Particulier': Account.TYPE_PERP, 'Crédit immobilier': Account.TYPE_MORTGAGE, + 'Réserve Provisio': Account.TYPE_REVOLVING_CREDIT, + 'Prêt personnel': Account.TYPE_CONSUMER_CREDIT, } klass = Account @@ -379,6 +381,11 @@ class fill_loan_details(ItemElement): obj_nb_payments_left = Dict('data/nbRemboursementRestant') obj_next_payment_date = Date(Dict('data/dateProchainAmortissement'), dayfirst=True) + @method + class fill_revolving_details(ItemElement): + obj_total_amount = Dict('data/montantDisponible') + obj_rate = Dict('data/tauxInterets') + class AccountsIBANPage(BNPPage): def get_ibans_dict(self): -- GitLab