diff --git a/modules/citelis/browser.py b/modules/citelis/browser.py
index e8044020..29a059ba 100644
--- a/modules/citelis/browser.py
+++ b/modules/citelis/browser.py
@@ -18,6 +18,7 @@
# along with weboob. If not, see .
+from weboob.capabilities.bank import Account
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
from .pages import LoginPage, SummaryPage, UselessPage
@@ -34,8 +35,8 @@ class CitelisBrowser(BaseBrowser):
PAGES = {
'%s://%s/userManager\.do\?reqCode=prepareLogin.*' % (PROTOCOL, DOMAIN): LoginPage,
- '%s://%s//summarySearch\.do\?reqCode=search.*' % (PROTOCOL, DOMAIN): SummaryPage,
- '%s://%s//userManager\.do\?reqCode=goToHomePage.+' % (PROTOCOL, DOMAIN): UselessPage,
+ '%s://%s/summarySearch\.do\?reqCode=search.*' % (PROTOCOL, DOMAIN): SummaryPage,
+ '%s://%s/userManager\.do\?reqCode=goToHomePage.+' % (PROTOCOL, DOMAIN): UselessPage,
}
def __init__(self, merchant_id, *args, **kwargs):
@@ -54,4 +55,9 @@ class CitelisBrowser(BaseBrowser):
def get_accounts_list(self):
self.location('%s://%s/summarySearch.do?reqCode=search' % (self.PROTOCOL, self.DOMAIN))
- # TODO
+ account = Account()
+ account.id = u'1'
+ account.currency = Account.CUR_EUR
+ account.balance = self.page.get_balance()
+ account.label = u'Synthèse financière'
+ return [account]
diff --git a/modules/citelis/pages.py b/modules/citelis/pages.py
index 901006f7..bcd172d3 100644
--- a/modules/citelis/pages.py
+++ b/modules/citelis/pages.py
@@ -18,12 +18,26 @@
# along with weboob. If not, see .
+from decimal import Decimal
+import re
+
from weboob.tools.browser import BasePage
+from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['LoginPage', 'SummaryPage', 'UselessPage']
+class Transaction(FrenchTransaction):
+ @classmethod
+ def clean_amount(cls, text):
+ text = text.strip()
+ # Convert "American" UUU.CC format to "French" UUU,CC format
+ if re.search(r'\d\.\d\d$', text):
+ text = text.replace(',', ' ').replace('.', ',')
+ return FrenchTransaction.clean_amount(text)
+
+
class LoginPage(BasePage):
def login(self, merchant_id, login, password):
self.browser.select_form(name='loginForm')
@@ -34,7 +48,24 @@ class LoginPage(BasePage):
class SummaryPage(BasePage):
- pass
+ def clean_amount(self, el, debit):
+ amount = Decimal(Transaction.clean_amount(el.text_content()))
+ if amount == Decimal('0.00'):
+ return None
+ if debit and amount > Decimal('0'):
+ return -1 * amount
+ return amount
+
+ def get_balance(self):
+ zone = self.parser.select(self.document.getroot(), '#ActionZone_Euro', 1)
+ for tr in self.parser.select(zone, '#transactionError tr'):
+ tds = self.parser.select(tr, 'td')
+ if tds and tds[0].text_content().strip() == 'Total':
+ debit, credit = self.parser.select(tr, 'td.amount', 4)[-2:] # keep the last 2
+ debit = self.clean_amount(debit, debit=True)
+ credit = self.clean_amount(credit, debit=False)
+ amount = credit or debit
+ return amount
class UselessPage(BasePage):