bpent: support coming transactions
This commit is contained in:
parent
63648a8353
commit
26ebea7875
3 changed files with 41 additions and 27 deletions
|
|
@ -101,9 +101,6 @@ class BNPorcBackend(BaseBackend, ICapBank, ICapMessages):
|
||||||
return self.browser.iter_history(account)
|
return self.browser.iter_history(account)
|
||||||
|
|
||||||
def iter_coming(self, account):
|
def iter_coming(self, account):
|
||||||
if self.config['website'].get() != 'pp':
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.iter_coming_operations(account)
|
return self.browser.iter_coming_operations(account)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class BNPEnterprise(BaseBrowser):
|
||||||
PAGES = {'%s://%s/NSAccess.*' % (PROTOCOL, DOMAIN): LoginPage,
|
PAGES = {'%s://%s/NSAccess.*' % (PROTOCOL, DOMAIN): LoginPage,
|
||||||
'%s://%s/UNE\?.*' % (PROTOCOL, DOMAIN): AccountsPage,
|
'%s://%s/UNE\?.*' % (PROTOCOL, DOMAIN): AccountsPage,
|
||||||
'%s://%s/ROP\?Action=F_RELCO.+' % (PROTOCOL, DOMAIN): HistoryPage,
|
'%s://%s/ROP\?Action=F_RELCO.+' % (PROTOCOL, DOMAIN): HistoryPage,
|
||||||
|
'%s://%s/RLOPI\?.+' % (PROTOCOL, DOMAIN): HistoryPage,
|
||||||
'%s://%s/NSFR' % (PROTOCOL, DOMAIN): UnknownPage}
|
'%s://%s/NSFR' % (PROTOCOL, DOMAIN): UnknownPage}
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
|
|
@ -80,5 +81,13 @@ class BNPEnterprise(BaseBrowser):
|
||||||
d1, d2 = self.page.get_date_range()
|
d1, d2 = self.page.get_date_range()
|
||||||
self.location('/ROP?Action=F_RELCO&ch4=%s&ch5=%s&ch9=%s&ch8=2000' % (account._link_id, d1, d2))
|
self.location('/ROP?Action=F_RELCO&ch4=%s&ch5=%s&ch9=%s&ch8=2000' % (account._link_id, d1, d2))
|
||||||
|
|
||||||
for transaction in self.page.iter_history():
|
return self.page.iter_history()
|
||||||
yield transaction
|
|
||||||
|
def iter_coming_operations(self, account):
|
||||||
|
if account._link_id is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
# XXX change date here
|
||||||
|
self.location('/RLOPI?chC=%s&ch8=0000&chB=1&ch7=30/06/2013&ch9=18/09/2013' % account.id)
|
||||||
|
|
||||||
|
return self.page.iter_history(only_coming=True)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ from decimal import Decimal
|
||||||
import hashlib
|
import hashlib
|
||||||
from urlparse import parse_qs
|
from urlparse import parse_qs
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
from weboob.capabilities.bank import Account
|
from weboob.capabilities.bank import Account
|
||||||
from weboob.tools.browser import BasePage, BrokenPageError
|
from weboob.tools.browser import BasePage, BrokenPageError
|
||||||
|
|
@ -162,7 +163,7 @@ class HistoryPage(BEPage):
|
||||||
def find_table(self):
|
def find_table(self):
|
||||||
for table in self.parser.select(self.document.getroot(), 'table', 'many'):
|
for table in self.parser.select(self.document.getroot(), 'table', 'many'):
|
||||||
for td in self.parser.select(table, 'tr td'):
|
for td in self.parser.select(table, 'tr td'):
|
||||||
if td.text_content().strip() == 'OPERATIONS':
|
if re.search('^OP.RATION', td.text_content().strip()):
|
||||||
return table
|
return table
|
||||||
|
|
||||||
def get_date_range(self):
|
def get_date_range(self):
|
||||||
|
|
@ -171,27 +172,34 @@ class HistoryPage(BEPage):
|
||||||
d2 = radio.attrib['value'][10:20]
|
d2 = radio.attrib['value'][10:20]
|
||||||
return (d1, d2)
|
return (d1, d2)
|
||||||
|
|
||||||
def iter_history(self):
|
def iter_history(self, only_coming=False):
|
||||||
if not self.is_empty():
|
if self.is_empty():
|
||||||
table = self.find_table()
|
return
|
||||||
for i, tr in enumerate(self.parser.select(table, 'tr', 'many')):
|
|
||||||
tds = self.parser.select(tr, 'td')
|
table = self.find_table()
|
||||||
if len(tds) != 5 or self.parser.select(tr, 'td.thtitrefondbleu'):
|
for i, tr in enumerate(self.parser.select(table, 'tr', 'many')):
|
||||||
continue
|
tds = self.parser.select(tr, 'td')
|
||||||
tddate, tdval, tdlabel, tddebit, tdcredit = \
|
if len(tds) != 5 or self.parser.select(tr, 'td.thtitrefondbleu'):
|
||||||
[t.text_content().replace(u'\xa0', ' ').strip() for t in tds]
|
continue
|
||||||
if all((tddate, tdlabel, any((tddebit, tdcredit)))):
|
tddate, tdval, tdlabel, tddebit, tdcredit = \
|
||||||
if tddebit:
|
[t.text_content().replace(u'\xa0', ' ').strip() for t in tds]
|
||||||
tdamount = '- %s' % tddebit
|
|
||||||
else:
|
if tds[0].find('span') is None and only_coming:
|
||||||
tdamount = tdcredit
|
# coming
|
||||||
t = Transaction(i)
|
continue
|
||||||
t.set_amount(tdamount)
|
|
||||||
date = datetime.strptime(tddate, '%d/%m/%Y')
|
if all((tddate, tdlabel, any((tddebit, tdcredit)))):
|
||||||
val = datetime.strptime(tdval, '%d/%m/%Y')
|
if tddebit:
|
||||||
t.parse(date, tdlabel)
|
tdamount = '- %s' % tddebit
|
||||||
t.vdate = val
|
else:
|
||||||
yield t
|
tdamount = tdcredit
|
||||||
|
t = Transaction(i)
|
||||||
|
t.set_amount(tdamount)
|
||||||
|
date = datetime.strptime(tddate, '%d/%m/%Y')
|
||||||
|
val = datetime.strptime(tdval, '%d/%m/%Y')
|
||||||
|
t.parse(date, tdlabel)
|
||||||
|
t.vdate = val
|
||||||
|
yield t
|
||||||
|
|
||||||
|
|
||||||
class UnknownPage(BEPage):
|
class UnknownPage(BEPage):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue