diff --git a/modules/cmes/browser.py b/modules/cmes/browser.py
index 11ae936a27a3432efde734e1d61aec5ea985fd0d..b640c3394029fcc70edc1f180c0a2389729a9713 100644
--- a/modules/cmes/browser.py
+++ b/modules/cmes/browser.py
@@ -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 .
+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.*)fr/identification/authentification.html', LoginPage)
- action_needed = URL(r'(?P.*)(?P.*)fr/epargnants/premiers-pas/saisir-vos-coordonnees.*',
- r'(?P.*)(?P.*)fr/epargnants/conditions-generales-d-utilisation/index.html',
- ActionNeededPage)
+ action_needed = URL(
+ r'(?P.*)(?P.*)fr/epargnants/premiers-pas/saisir-vos-coordonnees.*',
+ r'(?P.*)(?P.*)fr/epargnants/conditions-generales-d-utilisation/index.html',
+ ActionNeededPage
+ )
- accounts = URL(r'(?P.*)(?P.*)fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html',
- r'(?P.*)(?P.*)fr/epargnants/tableau-de-bord/index.html',
- NewAccountsPage)
+ accounts = URL(
+ r'(?P.*)(?P.*)fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html',
+ r'(?P.*)(?P.*)fr/epargnants/tableau-de-bord/index.html',
+ AccountsPage
+ )
- operations_list = URL(r'(?P.*)(?P.*)fr/epargnants/operations/index.html',
- OperationsListPage)
+ operations_list = URL(r'(?P.*)(?P.*)fr/epargnants/operations/index.html', OperationsListPage)
- operation = URL(r'(?P.*)(?P.*)fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P\d+)',
- OperationPage)
+ operation = URL(r'(?P.*)(?P.*)fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P\d+)', OperationPage)
client_space = 'espace-client/'
@@ -71,8 +75,11 @@ def iter_accounts(self):
@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 @@ def iter_history(self, account):
@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
diff --git a/modules/cmes/pages.py b/modules/cmes/pages.py
index 1b5096ec636b813966abd3c4b0a067e34159794d..ea496cc5c6edebc68bb2b917bb635513f7a2155d 100644
--- a/modules/cmes/pages.py
+++ b/modules/cmes/pages.py
@@ -23,7 +23,8 @@
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 @@ def on_load(self):
}
-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 @@ def iter_invest_rows(self, account):
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 @@ def iter_pocket(self, inv):
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):