Support coming operations

This commit is contained in:
Florent 2014-08-28 11:52:15 +02:00
commit 732417b94a
3 changed files with 39 additions and 5 deletions

View file

@ -96,6 +96,11 @@ class INGBackend(BaseBackend, CapBank, CapBill):
account = self.get_account(account)
return self.browser.get_investments(account)
def iter_coming(self, account):
if not isinstance(account, Account):
account = self.get_account(account)
return self.browser.get_coming(account)
def iter_subscription(self):
return self.browser.get_subscriptions()

View file

@ -49,7 +49,6 @@ class IngBrowser(LoginBrowser):
# CapBill
billpage = URL('/protected/pages/common/estatement/eStatement.jsf', BillsPage)
def __init__(self, *args, **kwargs):
self.birthday = kwargs.pop('birthday', None)
self.where = None
@ -77,6 +76,31 @@ class IngBrowser(LoginBrowser):
self.where = "start"
return self.page.get_list()
@need_login
def get_coming(self, account):
if account.type != Account.TYPE_CHECKING and\
account.type != Account.TYPE_SAVINGS:
raise NotImplementedError()
if self.where != "start":
self.accountspage.go()
data = {"AJAX:EVENTS_COUNT": 1,
"AJAXREQUEST": "_viewRoot",
"ajaxSingle": "index:setAccount",
"autoScroll": "",
"index": "index",
"index:setAccount": "index:setAccount",
"javax.faces.ViewState": account._jid,
"cptnbr": account._id
}
self.accountspage.go(data=data)
self.where = "history"
jid = self.page.get_history_jid()
if jid is None:
self.logger.info('There is no history for this account')
return
return self.page.get_coming()
@need_login
def get_history(self, account):
if account.type == Account.TYPE_MARKET:

View file

@ -131,10 +131,7 @@ class AccountsList(LoggedPage, HTMLPage):
obj_coming = NotAvailable
obj__jid = Attr('//input[@name="javax.faces.ViewState"]', 'value')
@method
class get_transactions(ListElement):
item_xpath = '//div[@class="temporaryTransactionList"]//table'
class generic_transactions(ListElement):
class item(ItemElement):
klass = Transaction
@ -152,6 +149,14 @@ class AccountsList(LoggedPage, HTMLPage):
return False
return True
@method
class get_coming(generic_transactions):
item_xpath = '//div[@class="transactions cc future"]//table'
@method
class get_transactions(generic_transactions):
item_xpath = '//div[@class="temporaryTransactionList"]//table'
def get_history_jid(self):
span = self.doc.xpath('//span[@id="index:panelASV"]')
if len(span) > 1: