Commit fa51a969 authored by Martin Sicot's avatar Martin Sicot Committed by Romain Bignon

[boursorama] Details for loans retrieved

Closes: 7505@zendesk
parent e6ba29be
......@@ -193,6 +193,7 @@ class BoursoramaBrowser(RetryLoginBrowser, StatesMixin):
if self.accounts_list is not None:
break
self.accounts_list = []
self.loans_list = []
self.accounts_list.extend(self.pro_accounts.go().iter_accounts())
self.accounts_list.extend(self.accounts.go().iter_accounts())
......@@ -210,11 +211,15 @@ class BoursoramaBrowser(RetryLoginBrowser, StatesMixin):
# there is 1 page for all accounts (one for tit and one for pro)
break
for account in list(self.accounts_list):
if account.type == Account.TYPE_CARD and account.url not in valid_card_url:
self.accounts_list.remove(account)
elif account.type == Account.TYPE_LOAN:
self.location(account.url)
self.loans_list.append(self.page.get_loan())
self.accounts_list.remove(account)
self.accounts_list.extend(self.loans_list)
cards = [acc for acc in self.accounts_list if acc.type == Account.TYPE_CARD]
if cards:
self.go_cards_number(cards[0].url)
......@@ -222,7 +227,7 @@ class BoursoramaBrowser(RetryLoginBrowser, StatesMixin):
self.page.populate_cards_number(cards)
for account in self.accounts_list:
if account.type not in (Account.TYPE_CARD, Account.TYPE_LOAN, Account.TYPE_LIFE_INSURANCE):
if account.type not in (Account.TYPE_CARD, Account.TYPE_LOAN, Account.TYPE_CONSUMER_CREDIT, Account.TYPE_MORTGAGE, Account.TYPE_REVOLVING_CREDIT, Account.TYPE_LIFE_INSURANCE):
account.iban = self.iban.go(webid=account._webid).get_iban()
for card in cards:
......
......@@ -31,13 +31,13 @@ from weboob.browser.elements import ListElement, ItemElement, method, TableEleme
from weboob.browser.filters.standard import (
CleanText, CleanDecimal, Field, Format,
Regexp, Date, AsyncLoad, Async, Eval, RegexpError, Env,
Currency as CleanCurrency,
Currency as CleanCurrency, Map,
)
from weboob.browser.filters.json import Dict
from weboob.browser.filters.html import Attr, Link, TableCell, AbsoluteLink
from weboob.capabilities.bank import (
Account, Investment, Recipient, Transfer, AccountNotFound,
AddRecipientBankError, TransferInvalidAmount,
AddRecipientBankError, TransferInvalidAmount, Loan,
)
from weboob.tools.capabilities.bank.investments import create_french_liquidity
from weboob.capabilities.base import NotAvailable, empty, Currency
......@@ -333,6 +333,41 @@ class AccountsPage(LoggedPage, HTMLPage):
yield m.groups()
class LoanPage(LoggedPage, HTMLPage):
LOAN_TYPES = {
"PRÊT PERSONNEL": Account.TYPE_CONSUMER_CREDIT,
}
@method
class get_loan(ItemElement):
klass = Loan
obj_id = CleanDecimal('//h3[contains(@class, "account-number")]/strong')
obj_label = CleanText('//h2[contains(@class, "page-title__account")]//div[@class="account-edit-label"]/span')
obj_total_amount = CleanDecimal('//p[contains(text(), "Montant emprunt")]/span', replace_dots=True)
obj_currency = CleanCurrency('//p[contains(text(), "Montant emprunt")]/span')
obj_duration = CleanDecimal('//p[contains(text(), "Nombre prévisionnel d\'échéances restantes")]/span')
obj_subscription_date = Date(CleanText('//p[contains(text(), "Date de départ du prêt")]/span'))
obj_maturity_date = Date(CleanText('//p[contains(text(), "Date prévisionnelle d\'échéance finale")]/span'))
obj_rate = CleanDecimal('//p[contains(text(), "Taux nominal en vigueur du prêt")]/span')
obj_nb_payments_left = CleanDecimal('//p[contains(text(), "Nombre prévisionnel d\'échéances restantes")]/span')
obj_nb_payments_total = CleanDecimal('//p[contains(text(), "Nombre d\'écheances totales")]/span')
obj_next_payment_amount = CleanDecimal('//p[contains(text(), "Montant de la prochaine échéance")]/span', replace_dots=True)
obj_next_payment_date = Date(CleanText('//p[contains(text(), "Date de la prochaine échéance")]/span'))
def obj_balance(self):
balance = CleanDecimal('//p[contains(text(), "Capital restant dû")]/span', replace_dots=True)(self)
if balance > 0:
balance *= -1
return balance
def obj_type(self):
_type = CleanText('//h2[contains(@class, "page-title__account")]//div[@class="account-edit-label"]/span')
return Map(_type, self.page.LOAN_TYPES, default=Account.TYPE_LOAN)(self)
class CardCalendarPage(LoggedPage, RawPage):
def is_here(self):
return b'VCALENDAR' in self.doc
......@@ -762,10 +797,6 @@ class AccbisPage(LoggedPage, HTMLPage):
accounts.extend(cards)
class LoanPage(LoggedPage, HTMLPage):
pass
class ErrorPage(HTMLPage):
def on_load(self):
error = (Attr('//input[@required][@id="profile_lei_type_identifier"]', 'data-message', default=None)(self.doc) or
......
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