Return transfer id Prevent when the two accounts aren't on the same backend
Signed-off-by: Nicolas Duhamel <nicolas@jombi.fr> Signed-off-by: Romain Bignon <romain@peerfuse.org>
This commit is contained in:
parent
17f6df1e30
commit
935531c5ae
4 changed files with 28 additions and 13 deletions
|
|
@ -125,13 +125,20 @@ class Boobank(ReplApplication):
|
|||
"""
|
||||
id_from, id_to, amount = self.parseargs(line, 3, 3)
|
||||
|
||||
id_from, backend_name = self.parse_id(id_from)
|
||||
id_to, backend_name = self.parse_id(id_to)
|
||||
id_from, backend_name_from = self.parse_id(id_from)
|
||||
id_to, backend_name_to = self.parse_id(id_to)
|
||||
|
||||
if backend_name_from != backend_name_to:
|
||||
print "Transfer between different backend is not implemented"
|
||||
return
|
||||
else:
|
||||
backend_name = backend_name_from
|
||||
|
||||
names = (backend_name,) if backend_name is not None else None
|
||||
self.load_backends(ICapBank, names=names)
|
||||
|
||||
def do(backend):
|
||||
return backend.transfer(id_from, id_to, float(amount))
|
||||
|
||||
for backend, operation in self.do(do):
|
||||
pass
|
||||
for backend, id_transfer in self.do(do):
|
||||
self.format((('Transfer', str(id_transfer)),))
|
||||
|
|
|
|||
|
|
@ -57,4 +57,4 @@ class BPBackend(BaseBackend, ICapBank):
|
|||
to_account = self.get_account(id_to)
|
||||
|
||||
#TODO: retourner le numero du virement
|
||||
self.browser.make_transfer(from_account, to_account, amount)
|
||||
return self.browser.make_transfer(from_account, to_account, amount)
|
||||
|
|
|
|||
|
|
@ -197,4 +197,12 @@ class BPbrowser(object):
|
|||
|
||||
#Confirmation
|
||||
# TODO: verifier que tout c'est bien passe
|
||||
self.Browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/virementnational/4-virementNational.ea")
|
||||
rep = self.Browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/virementnational/4-virementNational.ea")
|
||||
html = rep.get_data()
|
||||
|
||||
pattern = "Votre virement N.+ ([0-9]+) "
|
||||
|
||||
regex = re.compile(pattern)
|
||||
match = regex.search(html)
|
||||
id_transfer = match.groups()[0]
|
||||
return id_transfer
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if sys.version_info[:2] <= (2, 5):
|
|||
from .base import IBaseCap, CapBaseObject
|
||||
|
||||
|
||||
__all__ = ['Account', 'AccountNotFound', 'ICapBank', 'Operation']
|
||||
__all__ = ['Account', 'AccountNotFound', 'NotEnoughMoney', 'ICapBank', 'Operation']
|
||||
|
||||
|
||||
class AccountNotFound(Exception):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue