From d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9 Mon Sep 17 00:00:00 2001 From: Maxime Pommier Date: Wed, 10 Jul 2019 19:06:57 +0200 Subject: [PATCH] =?UTF-8?q?[bnporc]=C2=A0Add=20detail=20for=20mortgage=20l?= =?UTF-8?q?oan=20account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/bnporc/pp/browser.py | 10 ++++++++-- modules/bnporc/pp/pages.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/bnporc/pp/browser.py b/modules/bnporc/pp/browser.py index 367bc638c8..c33870617e 100644 --- a/modules/bnporc/pp/browser.py +++ b/modules/bnporc/pp/browser.py @@ -28,7 +28,7 @@ from weboob.capabilities.base import find_object from weboob.capabilities.bank import ( AccountNotFound, Account, AddRecipientStep, AddRecipientTimeout, - TransferInvalidRecipient, + TransferInvalidRecipient, Loan, ) from weboob.capabilities.profile import ProfileMissing from weboob.tools.decorators import retry @@ -47,7 +47,7 @@ MarketListPage, MarketPage, MarketHistoryPage, MarketSynPage, BNPKeyboard, RecipientsPage, ValidateTransferPage, RegisterTransferPage, AdvisorPage, AddRecipPage, ActivateRecipPage, ProfilePage, ListDetailCardPage, ListErrorPage, - UselessPage, TransferAssertionError, + UselessPage, TransferAssertionError, LoanDetailsPage, ) @@ -95,6 +95,7 @@ class BNPParibasBrowser(JsonBrowserMixin, LoginBrowser): '/fr/client/100-connexion', '/fr/systeme/page-indisponible', ConnectionThresholdPage) accounts = URL('udc-wspl/rest/getlstcpt', AccountsPage) + loan_details = URL('caraccomptes-wspl/rpc/(?P.*)', LoanDetailsPage) ibans = URL('rib-wspl/rpc/comptes', AccountsIBANPage) history = URL('rop-wspl/rest/releveOp', HistoryPage) transfer_init = URL('virement-wspl/rest/initialisationVirement', TransferInitPage) @@ -185,6 +186,11 @@ 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: + 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) + for market_acc in market_accounts: if all(( market_acc['securityAccountNumber'].endswith(account.number[-4:]), diff --git a/modules/bnporc/pp/pages.py b/modules/bnporc/pp/pages.py index 9c7520c143..559bb4f62e 100644 --- a/modules/bnporc/pp/pages.py +++ b/modules/bnporc/pp/pages.py @@ -331,6 +331,7 @@ class item(ItemElement): 'PEA Titres': Account.TYPE_PEA, 'PEL': Account.TYPE_SAVINGS, 'Plan Epargne Retraite Particulier': Account.TYPE_PERP, + 'Crédit immobilier': Account.TYPE_MORTGAGE, } klass = Account @@ -368,6 +369,17 @@ def parse(self, el): self.env['account_type'] = Dict('idFamilleCompte')(el) +class LoanDetailsPage(BNPPage): + @method + class fill_loan_details(ItemElement): + obj_total_amount = Dict('data/montantPret') + obj_maturity_date = Date(Dict('data/dateEcheanceRemboursement'), dayfirst=True) + obj_duration = Dict('data/dureeRemboursement') + obj_rate = Dict('data/tauxRemboursement') + obj_nb_payments_left = Dict('data/nbRemboursementRestant') + obj_next_payment_date = Date(Dict('data/dateProchainAmortissement'), dayfirst=True) + + class AccountsIBANPage(BNPPage): def get_ibans_dict(self): return dict([(a['ibanCrypte'], a['iban']) for a in self.path('data.listeRib.*.infoCompte')]) -- GitLab