diff --git a/modules/banqueaccord/pages.py b/modules/banqueaccord/pages.py
index e1681826..c04dc2e0 100644
--- a/modules/banqueaccord/pages.py
+++ b/modules/banqueaccord/pages.py
@@ -18,6 +18,7 @@
# along with weboob. If not, see .
+from dateutil.relativedelta import relativedelta
from decimal import Decimal, InvalidOperation
import re
from cStringIO import StringIO
@@ -32,6 +33,10 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['LoginPage', 'IndexPage', 'AccountsPage', 'OperationsPage']
+class Transaction(FrenchTransaction):
+ PATTERNS = [(re.compile(ur'^(?P.*?) - traité le \d+/\d+$'), FrenchTransaction.TYPE_CARD)]
+
+
class VirtKeyboard(MappedVirtKeyboard):
symbols={'0':('8664b9cdfa66b4c3a1ec99c35a2bf64b','9eb80c6e99410eaac32905b2c77e65e5','37717277dc2471c8a7bf37e2068a8f01'),
'1':('1f36986f9d27dde54ce5b08e8e285476','9d0aa7a0a2bbab4f2c01ef1e820cb3f1'),
@@ -105,13 +110,44 @@ class IndexPage(LoggedPage, HTMLPage):
def condition(self):
return self.el.get('onclick') is not None
+ loan_init_date = Transaction.Date(CleanText('//table//td[contains(text(), "Date de sous")]/../td[2]'))
+ loan_next_date = Transaction.Date(CleanText('//table//td[contains(text(), "Prochaine")]/../td[2]'))
+ loan_nb = CleanText('//table//td[contains(text(), "Nombre de mensu") and contains(text(), "rembours")]/../td[2]')
+ loan_total_amount = CleanDecimal('//table//td/strong[contains(text(), "Montant emprunt")]/../../td[2]', replace_dots=False)
+ loan_amount = CleanDecimal('//table//td/strong[contains(text(), "Montant de la")]/../../td[2]', replace_dots=False)
+
def get_loan_balance(self):
- xpath = '//table//td/strong[contains(text(), "Montant emprunt")]/../../td[2]'
try:
- return - CleanDecimal(xpath, replace_dots=False)(self.doc)
+ total_amount = - self.loan_total_amount(self.doc)
except InvalidOperation:
return None
+ nb = int(self.loan_nb(self.doc))
+ amount = self.loan_amount(self.doc)
+
+ return total_amount + (nb*amount)
+
+ def iter_loan_transactions(self):
+ init_date = self.loan_init_date(self.doc)
+ next_date = self.loan_next_date(self.doc)
+ nb = int(self.loan_nb(self.doc))
+ total_amount = - self.loan_total_amount(self.doc)
+ amount = self.loan_amount(self.doc)
+
+ for _ in xrange(nb):
+ next_date = next_date - relativedelta(months=1)
+ tr = Transaction()
+ tr.raw = tr.label = u'Mensualité'
+ tr.date = tr.rdate = tr.vdate = next_date
+ tr.amount = amount
+ yield tr
+
+ tr = Transaction()
+ tr.raw = tr.label = u'Emprunt initial'
+ tr.date = tr.rdate = init_date
+ tr.amount = total_amount
+ yield tr
+
def get_card_name(self):
return CleanText('//h1[1]')(self.doc)
@@ -136,12 +172,9 @@ class AccountsPage(LoggedPage, HTMLPage):
return balance
-class Transaction(FrenchTransaction):
- PATTERNS = [(re.compile(ur'^(?P.*?) - traité le \d+/\d+$'), FrenchTransaction.TYPE_CARD)]
-
class OperationsPage(LoggedPage, HTMLPage):
@method
- class get_history(ListElement):
+ class iter_transactions(ListElement):
item_xpath = '//div[contains(@class, "mod-listeoperations")]//table/tbody/tr'
class credit(ItemElement):