Get recipient for livret A
And add missing file...
This commit is contained in:
parent
06392b4a6f
commit
10c336fca9
2 changed files with 82 additions and 3 deletions
|
|
@ -19,6 +19,7 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
|
from weboob.capabilities.bank import Account
|
||||||
from .pages import AccountsList, LoginPage, LoginPage2, \
|
from .pages import AccountsList, LoginPage, LoginPage2, \
|
||||||
AccountHistory, TransferPage
|
AccountHistory, TransferPage
|
||||||
|
|
||||||
|
|
@ -90,8 +91,9 @@ class Ing(BaseBrowser):
|
||||||
# are always on a HTML document.
|
# are always on a HTML document.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_history(self, id):
|
def get_history(self, account):
|
||||||
account = self.get_account(id)
|
if not isinstance(account, Account):
|
||||||
|
account = self.get_account(account)
|
||||||
# The first and the second letter of the label are the account type
|
# The first and the second letter of the label are the account type
|
||||||
if account.label[0:2] == "CC":
|
if account.label[0:2] == "CC":
|
||||||
self.location('https://secure.ingdirect.fr/protected/pages/cc/accountDetail.jsf')
|
self.location('https://secure.ingdirect.fr/protected/pages/cc/accountDetail.jsf')
|
||||||
|
|
@ -118,4 +120,10 @@ class Ing(BaseBrowser):
|
||||||
def get_recipients(self, account):
|
def get_recipients(self, account):
|
||||||
if not self.is_on_page(TransferPage):
|
if not self.is_on_page(TransferPage):
|
||||||
self.location('https://secure.ingdirect.fr/protected/pages/cc/transfer/transferManagement.jsf')
|
self.location('https://secure.ingdirect.fr/protected/pages/cc/transfer/transferManagement.jsf')
|
||||||
|
if self.page.ischecked(account):
|
||||||
|
return self.page.get_recipients()
|
||||||
|
else:
|
||||||
|
# It is hard to check the box and to get the real list. We try an alternative way like normal users
|
||||||
|
self.get_history(account.id).next()
|
||||||
|
self.location('https://secure.ingdirect.fr/general?command=DisplayDoTransferCommand')
|
||||||
return self.page.get_recipients()
|
return self.page.get_recipients()
|
||||||
|
|
|
||||||
71
modules/ing/pages/transfer.py
Normal file
71
modules/ing/pages/transfer.py
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright(C) 2009-2011 Romain Bignon, Florent Fourcot
|
||||||
|
#
|
||||||
|
# This file is part of weboob.
|
||||||
|
#
|
||||||
|
# weboob is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# weboob is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from weboob.capabilities.bank import Recipient, AccountNotFound
|
||||||
|
from weboob.tools.browser import BasePage
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ['TransferPage']
|
||||||
|
|
||||||
|
|
||||||
|
class TransferPage(BasePage):
|
||||||
|
def on_loaded(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_recipients(self):
|
||||||
|
# First, internals recipients
|
||||||
|
table = self.document.xpath('//table[@id="transfer_form:receiptAccount"]')
|
||||||
|
for tr in table[0].xpath('tbody/tr'):
|
||||||
|
tds = tr.xpath('td')
|
||||||
|
id = tds[0].xpath('input')[0].attrib['value']
|
||||||
|
name = tds[0].xpath('label')[0].text
|
||||||
|
name += u" " + tds[1].xpath('span')[0].text
|
||||||
|
recipient = Recipient()
|
||||||
|
recipient.id = id
|
||||||
|
recipient.label = name
|
||||||
|
yield recipient
|
||||||
|
|
||||||
|
# Second, externals recipients
|
||||||
|
select = self.document.xpath('//select[@id="transfer_form:externalAccounts"]')
|
||||||
|
recipients = select[0].xpath('option')
|
||||||
|
recipients.pop(0)
|
||||||
|
for option in recipients:
|
||||||
|
recipient = Recipient()
|
||||||
|
recipient.id = option.attrib['value']
|
||||||
|
recipient.label = option.text
|
||||||
|
yield recipient
|
||||||
|
|
||||||
|
def ischecked(self, account):
|
||||||
|
id = account.id
|
||||||
|
# remove prefix (CC-, LA-, ...)
|
||||||
|
id = id[3:]
|
||||||
|
search = '//input[@value="%s"]' % id
|
||||||
|
option = self.document.xpath('//input[@value="%s"]' % id)
|
||||||
|
if len(option) < 0:
|
||||||
|
raise AccountNotFound()
|
||||||
|
else:
|
||||||
|
option = option[0]
|
||||||
|
try:
|
||||||
|
if option.attrib["checked"] == "checked":
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
return False
|
||||||
Loading…
Add table
Add a link
Reference in a new issue