creditcooppro: support coming transactions (in addition to card transactions)
This commit is contained in:
parent
efa39af957
commit
71443efb54
2 changed files with 34 additions and 19 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
|
|
||||||
from .pages import LoginPage, AccountsPage, TransactionsPage, ComingTransactionsPage
|
from .pages import LoginPage, AccountsPage, ITransactionsPage, TransactionsPage, ComingTransactionsPage, CardTransactionsPage
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['CreditCooperatif']
|
__all__ = ['CreditCooperatif']
|
||||||
|
|
@ -33,7 +33,9 @@ class CreditCooperatif(BaseBrowser):
|
||||||
'https://www.coopanet.com/banque/cpt/incoopanetj2ee.do.*': AccountsPage,
|
'https://www.coopanet.com/banque/cpt/incoopanetj2ee.do.*': AccountsPage,
|
||||||
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkReleveAction=X&numeroExterne=.*': TransactionsPage,
|
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkReleveAction=X&numeroExterne=.*': TransactionsPage,
|
||||||
'https://www.coopanet.com/banque/cpt/cpt/relevecompte.do\?tri_page=.*': TransactionsPage,
|
'https://www.coopanet.com/banque/cpt/cpt/relevecompte.do\?tri_page=.*': TransactionsPage,
|
||||||
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkOpCB=X&numeroExterne=.*': ComingTransactionsPage
|
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkOpCB=X&numeroExterne=.*': CardTransactionsPage,
|
||||||
|
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkOpEC=X&numeroExterne=.*': ComingTransactionsPage,
|
||||||
|
'https://www.coopanet.com/banque/cpt/cpt/operationEnCours.do.*': ComingTransactionsPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
@ -83,11 +85,11 @@ class CreditCooperatif(BaseBrowser):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_history(self, account):
|
def _get_history(self, link):
|
||||||
self.location('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id)
|
self.location(link)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
assert self.is_on_page(TransactionsPage)
|
assert self.is_on_page(ITransactionsPage)
|
||||||
|
|
||||||
for tr in self.page.get_history():
|
for tr in self.page.get_history():
|
||||||
yield tr
|
yield tr
|
||||||
|
|
@ -98,10 +100,13 @@ class CreditCooperatif(BaseBrowser):
|
||||||
|
|
||||||
self.location(next_url)
|
self.location(next_url)
|
||||||
|
|
||||||
|
def get_history(self, account):
|
||||||
|
return self._get_history('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id)
|
||||||
|
|
||||||
def get_coming(self, account):
|
def get_coming(self, account):
|
||||||
self.location('/banque/cpt/cpt/situationcomptes.do?lnkOpCB=X&numeroExterne='+ account.id)
|
# credit cards transactions
|
||||||
|
for tr in self._get_history('/banque/cpt/cpt/situationcomptes.do?lnkOpCB=X&numeroExterne='+ account.id):
|
||||||
assert self.is_on_page(ComingTransactionsPage)
|
yield tr
|
||||||
|
# coming transactions
|
||||||
for ctr in self.page.get_history():
|
for tr in self._get_history('/banque/cpt/cpt/situationcomptes.do?lnkOpEC=X&numeroExterne='+ account.id):
|
||||||
yield ctr
|
yield tr
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ from weboob.capabilities.bank import Account
|
||||||
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage', 'ComingTransactionsPage']
|
__all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage', 'ComingTransactionsPage', 'CardTransactionsPage', 'ITransactionsPage']
|
||||||
|
|
||||||
|
|
||||||
class LoginPage(BasePage):
|
class LoginPage(BasePage):
|
||||||
|
|
@ -85,9 +85,9 @@ class Transaction(FrenchTransaction):
|
||||||
FrenchTransaction.TYPE_WITHDRAWAL),
|
FrenchTransaction.TYPE_WITHDRAWAL),
|
||||||
(re.compile('^(?P<text>.*) RETRAIT DU (?P<dd>\d{2})(?P<mm>\d{2})(?P<yy>\d{2}) .*'),
|
(re.compile('^(?P<text>.*) RETRAIT DU (?P<dd>\d{2})(?P<mm>\d{2})(?P<yy>\d{2}) .*'),
|
||||||
FrenchTransaction.TYPE_WITHDRAWAL),
|
FrenchTransaction.TYPE_WITHDRAWAL),
|
||||||
(re.compile('^CARTE \d+ .*'), FrenchTransaction.TYPE_CARD),
|
(re.compile('^CARTE \d+ .*'), FrenchTransaction.TYPE_CARD),
|
||||||
(re.compile('^VIR(EMENT)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
|
(re.compile('^VIR(EMENT)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
|
||||||
(re.compile('^PRLV (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
|
(re.compile('^(PRLV|PRELEVEMENT) (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
|
||||||
(re.compile('^CHEQUE.*'), FrenchTransaction.TYPE_CHECK),
|
(re.compile('^CHEQUE.*'), FrenchTransaction.TYPE_CHECK),
|
||||||
(re.compile('^(AGIOS /|FRAIS) (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
|
(re.compile('^(AGIOS /|FRAIS) (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
|
||||||
(re.compile('^ABONNEMENT (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
|
(re.compile('^ABONNEMENT (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
|
||||||
|
|
@ -98,8 +98,7 @@ class Transaction(FrenchTransaction):
|
||||||
FrenchTransaction.TYPE_UNKNOWN),
|
FrenchTransaction.TYPE_UNKNOWN),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class ITransactionsPage(BasePage):
|
||||||
class TransactionsPage(BasePage):
|
|
||||||
def get_next_url(self):
|
def get_next_url(self):
|
||||||
# can be 'Suivant' or ' Suivant'
|
# can be 'Suivant' or ' Suivant'
|
||||||
next = self.document.xpath("//a[normalize-space(text()) = 'Suivant']")
|
next = self.document.xpath("//a[normalize-space(text()) = 'Suivant']")
|
||||||
|
|
@ -109,17 +108,22 @@ class TransactionsPage(BasePage):
|
||||||
|
|
||||||
return next[0].attrib["href"]
|
return next[0].attrib["href"]
|
||||||
|
|
||||||
|
def get_history(self):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
class TransactionsPage(ITransactionsPage):
|
||||||
TR_DATE = 0
|
TR_DATE = 0
|
||||||
TR_TEXT = 2
|
TR_TEXT = 2
|
||||||
TR_DEBIT = 3
|
TR_DEBIT = 3
|
||||||
TR_CREDIT = 4
|
TR_CREDIT = 4
|
||||||
|
TABLE_NAME = 'operation'
|
||||||
|
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
for tr in self.document.xpath('//table[@id="operation"]/tbody/tr'):
|
for tr in self.document.xpath('//table[@id="%s"]/tbody/tr' % self.TABLE_NAME):
|
||||||
tds = tr.findall('td')
|
tds = tr.findall('td')
|
||||||
|
|
||||||
def get_content(td):
|
def get_content(td):
|
||||||
ret = "".join([ttd.text if ttd.text else "" for ttd in td.xpath(".//td")])
|
ret = self.parser.tocleanstring(td)
|
||||||
return ret.replace(u"\xa0", " ").strip()
|
return ret.replace(u"\xa0", " ").strip()
|
||||||
|
|
||||||
date = get_content(tds[self.TR_DATE])
|
date = get_content(tds[self.TR_DATE])
|
||||||
|
|
@ -134,8 +138,14 @@ class TransactionsPage(BasePage):
|
||||||
|
|
||||||
yield t
|
yield t
|
||||||
|
|
||||||
|
class ComingTransactionsPage(TransactionsPage):
|
||||||
|
TR_DATE = 2
|
||||||
|
TR_TEXT = 1
|
||||||
|
TR_DEBIT = -2
|
||||||
|
TR_CREDIT = -1
|
||||||
|
TABLE_NAME = 'operationAVenir'
|
||||||
|
|
||||||
class ComingTransactionsPage(BasePage):
|
class CardTransactionsPage(ITransactionsPage):
|
||||||
COM_TR_COMMENT = 0
|
COM_TR_COMMENT = 0
|
||||||
COM_TR_DATE = 1
|
COM_TR_DATE = 1
|
||||||
COM_TR_TEXT = 2
|
COM_TR_TEXT = 2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue