Commit 0ab82a57 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[creditmutuel] Handle new loans

There are loans which we did not handle.
parent 03af9a79
......@@ -53,7 +53,8 @@ from .pages import (
ExternalTransferPage, RevolvingLoanDetails, RevolvingLoansList,
ErrorPage, SubscriptionPage, NewCardsListPage, CardPage2, FiscalityConfirmationPage,
ConditionsPage, MobileConfirmationPage, UselessPage, DecoupledStatePage, CancelDecoupled,
OtpValidationPage, OtpBlockedErrorPage, TwoFAUnabledPage
OtpValidationPage, OtpBlockedErrorPage, TwoFAUnabledPage,
LoansOperationsPage,
)
......@@ -108,6 +109,8 @@ class CreditMutuelBrowser(TwoFactorBrowser):
r'/(?P<subbank>.*)fr/banque/nr/nr_devbooster.aspx.*',
r'(?P<subbank>.*)fr/banque/CRP8_GESTPMONT.aspx\?webid=.*&trnref=.*&contract=\d+&cardid=.*&cardmonth=\d+',
OperationsPage)
# This loans_operations contains operation for some loans, but not all of them.
loans_operations = URL(r'/(?P<subbank>.*)fr/banque/gec9.aspx.*', LoansOperationsPage)
coming = URL(r'/(?P<subbank>.*)fr/banque/mvts_instance.cgi.*', ComingPage)
info = URL(r'/(?P<subbank>.*)fr/banque/BAD.*', EmptyPage)
change_pass = URL(r'/(?P<subbank>.*)fr/validation/change_password.cgi',
......
......@@ -30,7 +30,8 @@ from collections import OrderedDict
from weboob.browser.pages import HTMLPage, FormNotFound, LoggedPage, pagination, XMLPage, PartialHTMLPage
from weboob.browser.elements import ListElement, ItemElement, SkipItem, method, TableElement
from weboob.browser.filters.standard import (
Filter, Env, CleanText, CleanDecimal, Field, Regexp, Async, AsyncLoad, Date, Format, Type, Currency,
Filter, Env, CleanText, CleanDecimal, Field, Regexp, Async,
AsyncLoad, Date, Format, Type, Currency,
)
from weboob.browser.filters.html import Link, Attr, TableCell, ColumnNotFound
from weboob.exceptions import (
......@@ -207,6 +208,7 @@ class OtpBlockedErrorPage(PartialHTMLPage):
return CleanText('//div[contains(@class, "bloctxt err")]')(self.doc)
class EmptyPage(LoggedPage, HTMLPage):
REFRESH_MAX = 10.0
......@@ -804,6 +806,7 @@ class Transaction(FrenchTransaction):
(re.compile(r'^CHEQUE( (?P<text>.*))?$'), FrenchTransaction.TYPE_CHECK),
(re.compile(r'^(F )?COTIS\.? (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
(re.compile(r'^(REMISE|REM CHQ) (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
(re.compile(r'^(?P<text>(ÉCHÉANCE|Echéance)).*'), FrenchTransaction.TYPE_LOAN_PAYMENT),
]
_is_coming = False
......@@ -825,7 +828,11 @@ class OperationsPage(LoggedPage, HTMLPage):
item_xpath = '//table[has-class("liste")]//tbody/tr'
class item(Transaction.TransactionElement):
condition = lambda self: len(self.el.xpath('./td')) >= 3 and len(self.el.xpath('./td[@class="i g" or @class="p g" or contains(@class, "_c1")]')) > 0
def condition(self):
return (
len(self.el.xpath('./td')) >= 3
and len(self.el.xpath('./td[@class="i g" or @class="p g" or contains(@class, "_c1")]')) > 0
)
class OwnRaw(Filter):
def __call__(self, item):
......@@ -890,6 +897,42 @@ class OperationsPage(LoggedPage, HTMLPage):
return CleanDecimal.French('//span[contains(text(), "Dont opérations enregistrées")]', default=NotAvailable)(self.doc)
class LoansOperationsPage(OperationsPage):
@method
class get_history(Pagination, Transaction.TransactionsElement):
head_xpath = '//table[has-class("liste")]/thead/tr/th'
item_xpath = '//table[has-class("liste")]/tr'
class item(Transaction.TransactionElement):
def condition(self):
return (
len(self.el.xpath('./td')) >= 3
and len(self.el.xpath('./td[@class="i g" or @class="p g" or contains(@class, "_c1")]')) > 0
and 'Echéance' in CleanText(TableCell('raw'))(self)
and 'Intérêts' in CleanText(TableCell('raw'))(self)
)
# Crédit = Echéance / Débit = Intérêts (and Assurance sometimes)
# 'Intérêts' do not affect the loans value.
obj_gross_amount = CleanDecimal.French(TableCell('credit'))
# Need to set it manually to NotAvailable otherwise Transaction.TransactionElement
# set its value to TableCell('credit')
obj_amount = NotAvailable
def obj_commission(self):
raw = Field('raw')(self)
if 'Assurance' in raw and 'Intérêts' in raw:
# There is 2 values in the 'debit' TableCell if we have
# Assurance and Intérêts...
interets, assurance = Regexp(CleanText(TableCell('debit')), r'([\d, ]+)', r'\1', nth='*')(self)
return (
CleanDecimal.French(sign=lambda x: -1).filter(interets)
- CleanDecimal.French().filter(assurance)
)
return CleanDecimal.French(TableCell('debit'), sign=lambda x: -1)(self)
class CardsOpePage(OperationsPage):
def select_card(self, card_number):
if CleanText('//select[@id="iso"]', default=None)(self.doc):
......
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