Commit 61dfc90b authored by Sylvie Ye's avatar Sylvie Ye Committed by Romain Bignon

[bnp] avoid recipient with same iban

recipient id can change,
avoid to retrieve duplicate recipient to not search recipient by id in transfer
and search by iban
parent 1bca3c79
......@@ -30,7 +30,7 @@ from weboob.capabilities.bank import (
from weboob.capabilities.messages import CapMessages, Thread
from weboob.capabilities.contact import CapContact
from weboob.capabilities.profile import CapProfile
from weboob.capabilities.base import find_object
from weboob.capabilities.base import find_object, strict_find_object
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value, ValueBool
......@@ -119,7 +119,9 @@ class BNPorcModule(Module, CapBankWealth, CapBankTransferAddRecipient, CapMessag
else:
account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound)
recipient = find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound)
recipient = strict_find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban)
if not recipient:
recipient = strict_find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound)
assert account.id.isdigit()
# quantize to show 2 decimals.
......
......@@ -327,11 +327,18 @@ class BNPParibasBrowser(JsonBrowserMixin, LoginBrowser):
except TransferError:
return
# avoid recipient with same iban
seen = set()
for recipient in self.page.transferable_on(origin_account_ibancrypte=origin_account_id):
yield recipient
if recipient.iban not in seen:
seen.add(recipient.iban)
yield recipient
if self.page.can_transfer_to_recipients(origin_account_id):
for recipient in self.recipients.go(data=JSON({'type': 'TOUS'})).iter_recipients():
yield recipient
if recipient.iban not in seen:
seen.add(recipient.iban)
yield recipient
@need_login
def new_recipient(self, recipient, **params):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment