First work on transfer

This commit is contained in:
Florent 2012-09-24 17:06:16 +02:00 committed by Romain Bignon
commit af96a09be0
4 changed files with 58 additions and 11 deletions

View file

@ -79,3 +79,9 @@ class INGBackend(BaseBackend, ICapBank):
account = self.get_account(account)
for recipient in self.browser.get_recipients(account):
yield recipient
def transfer(self, account, recipient, amount, reason):
with self.browser:
if not isinstance(account, Account):
account = self.get_account(account)
self.browser.transfer(account, recipient, amount, reason)

View file

@ -19,9 +19,9 @@
import hashlib
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
from weboob.capabilities.bank import Account
from weboob.capabilities.bank import Account, TransferError
from .pages import AccountsList, LoginPage, LoginPage2, \
AccountHistory, TransferPage
AccountHistory, TransferPage, TransferConfirmPage
__all__ = ['Ing']
@ -30,14 +30,16 @@ __all__ = ['Ing']
class Ing(BaseBrowser):
DOMAIN = 'secure.ingdirect.fr'
PROTOCOL = 'https'
DEBUG_HTTP = True
ENCODING = None # refer to the HTML encoding
PAGES = {'.*displayTRAccountSummary.*': AccountsList,
'.*displayLogin.jsf': LoginPage,
'.*displayLogin.jsf.*': LoginPage2,
'.*accountDetail.jsf.*': AccountHistory,
'.*displayTRHistoriqueLA.*': AccountHistory,
'.*transferManagement.jsf': TransferPage,
'.*DisplayDoTransferCommand.*': TransferPage
PAGES = {'.*displayTRAccountSummary.*': AccountsList,
'.*displayLogin.jsf': LoginPage,
'.*displayLogin.jsf.*': LoginPage2,
'.*accountDetail.jsf.*': AccountHistory,
'.*displayTRHistoriqueLA.*': AccountHistory,
'.*transferManagement.jsf': TransferPage,
'.*DisplayDoTransferCommand.*': TransferPage,
'.*transferCreateValidation.jsf': TransferConfirmPage
}
CERTHASH = "fba557b387cccc3d71ba038f9ef1de4d71541d7954744c79f6a7ff5f3cd4dc12"
@ -127,3 +129,21 @@ class Ing(BaseBrowser):
self.get_history(account.id).next()
self.location('https://secure.ingdirect.fr/general?command=DisplayDoTransferCommand')
return self.page.get_recipients()
def transfer(self, account, recipient, amount, reason):
found = False
# Automatically get the good transfer page
self.logger.debug('Search %s' % recipient)
for destination in self.get_recipients(account):
self.logger.debug('Found %s ' % destination.id)
if destination.id == recipient:
found = True
break
if found:
self.page.transfer(recipient, amount, reason)
if not self.is_on_page(TransferConfirmPage):
raise TransferError("Recipient not found")
else:
self.page.confirm()
else:
raise TransferError()

View file

@ -21,7 +21,7 @@
from .accounts_list import AccountsList
from .account_history import AccountHistory
from .login import LoginPage, LoginPage2, ConfirmPage, MessagePage
from .transfer import TransferPage
from .transfer import TransferPage, TransferConfirmPage
class AccountPrelevement(AccountsList):
@ -29,4 +29,4 @@ class AccountPrelevement(AccountsList):
__all__ = ['AccountsList', 'AccountHistory', 'LoginPage',
'LoginPage2', 'ConfirmPage', 'MessagePage', 'AccountPrelevement',
'TransferPage']
'TransferPage', 'TransferConfirmPage']

View file

@ -20,6 +20,7 @@
from weboob.capabilities.bank import Recipient, AccountNotFound
from weboob.tools.browser import BasePage
from weboob.tools.mech import ClientForm
__all__ = ['TransferPage']
@ -69,3 +70,23 @@ class TransferPage(BasePage):
return False
except:
return False
def transfer(self, recipient, amount, reason):
self.browser.select_form("transfer_form")
self.browser.set_all_readonly(False)
for a in self.browser.controls[:]:
#for label in a.get_labels():
if "transfer_form:_link_hidden_" in str(a) or "transfer_form:j_idcl" in str(a):
self.browser.controls.remove(a)
self.browser.controls.append(ClientForm.TextControl('text', 'AJAXREQUEST', {'value': "transfer_form:transfer_region"}))
self.browser['transfer_form:transferMotive'] = reason
self.browser.controls.append(ClientForm.TextControl('text', 'transfer_form:valide', {'value': "transfer_form:valide"}))
self.browser['transfer_form:validateDoTransfer'] = "needed"
self.browser['transfer_form:transferAmount'] = str(amount)
self.browser['transfer_recipient_radio'] = [recipient]
self.browser.submit()
class TransferConfirmPage(BasePage):
def on_loaded(self):
pass