Commit 9aa87930 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by ntome

[cmes/cices/epsens] Corrected pocket table for CCB accounts

CCB accounts (compte courant bloqué) have no investments but they do
have a specific table for Pockets.

Closes: 10687@zendesk
parent 65ca4aaf
......@@ -17,11 +17,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword
from .pages import (
LoginPage, NewAccountsPage, OperationsListPage, OperationPage, ActionNeededPage,
LoginPage, AccountsPage, OperationsListPage, OperationPage, ActionNeededPage,
)
......@@ -30,19 +32,21 @@ class CmesBrowser(LoginBrowser):
login = URL(r'(?P<client_space>.*)fr/identification/authentification.html', LoginPage)
action_needed = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/premiers-pas/saisir-vos-coordonnees.*',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/conditions-generales-d-utilisation/index.html',
ActionNeededPage)
action_needed = URL(
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/premiers-pas/saisir-vos-coordonnees.*',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/conditions-generales-d-utilisation/index.html',
ActionNeededPage
)
accounts = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/tableau-de-bord/index.html',
NewAccountsPage)
accounts = URL(
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/tableau-de-bord/index.html',
AccountsPage
)
operations_list = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/operations/index.html',
OperationsListPage)
operations_list = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/operations/index.html', OperationsListPage)
operation = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P<idx>\d+)',
OperationPage)
operation = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P<idx>\d+)', OperationPage)
client_space = 'espace-client/'
......@@ -71,8 +75,11 @@ class CmesBrowser(LoginBrowser):
@need_login
def iter_investment(self, account):
if 'compte courant bloqué' in account.label.lower():
# CCB accounts have Pockets but no Investments
return []
self.accounts.stay_or_go(subsite=self.subsite, client_space=self.client_space)
return self.page.iter_investment(account=account)
return self.page.iter_investments(account=account)
@need_login
def iter_history(self, account):
......@@ -85,6 +92,12 @@ class CmesBrowser(LoginBrowser):
@need_login
def iter_pocket(self, account):
for inv in self.iter_investment(account=account):
for pocket in self.page.iter_pocket(inv=inv):
self.accounts.stay_or_go(subsite=self.subsite, client_space=self.client_space)
if 'compte courant bloqué' in account.label.lower():
# CCB accounts have a specific table containing only Pockets
for pocket in self.page.iter_ccb_pockets(account=account):
yield pocket
else:
for inv in self.iter_investment(account=account):
for pocket in self.page.iter_pocket(inv=inv):
yield pocket
......@@ -23,7 +23,8 @@ import re
from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.browser.elements import ListElement, ItemElement, method
from weboob.browser.filters.standard import (
CleanText, CleanDecimal, Date, Regexp, Field, Currency, Upper, MapIn, Eval
CleanText, CleanDecimal, Date, Regexp, Field, Currency,
Upper, MapIn, Eval,
)
from weboob.browser.filters.html import Link
from weboob.capabilities.bank import Account, Investment, Pocket, NotAvailable
......@@ -82,7 +83,7 @@ ACCOUNTS_TYPES = {
}
class NewAccountsPage(LoggedPage, HTMLPage):
class AccountsPage(LoggedPage, HTMLPage):
@method
class iter_accounts(ListElement):
item_xpath = '//th[text()= "Nom du support" or text()="Nom du profil" or text()="Nom du compte"]/ancestor::table/ancestor::table'
......@@ -121,7 +122,7 @@ class NewAccountsPage(LoggedPage, HTMLPage):
row.xpath('//div[contains(@id, "dv::s::%s")]' % id_diff[0].rsplit(':', 1)[0])[0] if id_diff else None,
)
def iter_investment(self, account):
def iter_investments(self, account):
for row, elem_repartition, elem_pocket, elem_diff in self.iter_invest_rows(account=account):
inv = Investment()
inv._account = account
......@@ -165,6 +166,22 @@ class NewAccountsPage(LoggedPage, HTMLPage):
yield pocket
def iter_ccb_pockets(self, account):
# CCB accounts have a specific table with more columns and specific attributes
for row in self.doc.xpath('//th/div[contains(., "%s")]/ancestor::table//table/tbody/tr' % account.label):
pocket = Pocket()
pocket._account = account
pocket.investment = None
pocket.label = CleanText('.//td[1]')(row)
pocket.amount = CleanDecimal.French('.//td[last()]')(row)
if 'DISPONIBLE' in CleanText('.//td[2]')(row):
pocket.condition = Pocket.CONDITION_AVAILABLE
pocket.availability_date = NotAvailable
else:
pocket.condition = Pocket.CONDITION_DATE
pocket.availability_date = Date(CleanText('.//td[2]'), dayfirst=True)(row)
yield pocket
class OperationPage(LoggedPage, HTMLPage):
......
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