Commit d55ee1b5 authored by Maxime Pommier's avatar Maxime Pommier Committed by ntome

[bnporc] Add detail for mortgage loan account

parent bcac37b4
......@@ -28,7 +28,7 @@ from weboob.browser.browsers import LoginBrowser, URL, need_login
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 @@ from .pages import (
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<loan_type>.*)', 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 @@ class BNPParibasBrowser(JsonBrowserMixin, LoginBrowser):
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:]),
......
......@@ -331,6 +331,7 @@ class AccountsPage(BNPPage):
'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 @@ class AccountsPage(BNPPage):
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')])
......
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