Commit f8afc178 authored by Sylvie Ye's avatar Sylvie Ye Committed by Romain Bignon

[cragr] fix iter recipient

* Some user can have 2 internal accounts with same iban, skip it
* Avoid iter recipient for some account types
parent a198639c
......@@ -563,6 +563,10 @@ class CragrAPI(LoginBrowser):
def iter_transfer_recipients(self, account, transfer_space_info=None):
if account.type in (account.TYPE_CARD, account.TYPE_LOAN, account.TYPE_LIFE_INSURANCE,
# avoid to call `get_account_transfer_space_info()` several time
if transfer_space_info:
space, operation, referer = transfer_space_info
......@@ -574,12 +578,16 @@ class CragrAPI(LoginBrowser):
if not
for index, internal_rcpt in enumerate(
internal_rcpt._index = index
yield internal_rcpt
# can't use 'ignore_duplicate' in DictElement because we need the 'index' to do transfer
seen = set()
for index, internal_rcpt in enumerate(
internal_rcpt._index = index
if internal_rcpt._is_recipient and (internal_rcpt.iban not in seen):
yield internal_rcpt
for index, external_rcpt in enumerate(
external_rcpt._index = index
if external_rcpt.iban not in seen:
......@@ -27,7 +27,7 @@ from import (
Account, Recipient, Transfer, TransferBankError,
from weboob.browser.filters.standard import (
CleanDecimal, Env, Date, CleanText,
CleanDecimal, Date, CleanText,
from weboob.browser.filters.json import Dict
......@@ -59,10 +59,12 @@ class RecipientsPage(LoggedPage, JsonPage):
class iter_internal_recipient(DictElement):
def store(self, obj):
return obj
class item(ItemElement):
def condition(self):
return Dict('recipientOfTransfert', default=None)(self) and \
Env('account_id')(self) != Dict('accountNumber', default=None)(self)
return Dict('accountNumber', default=None)(self)
klass = Recipient
......@@ -71,6 +73,7 @@ class RecipientsPage(LoggedPage, JsonPage):
obj_iban = Dict('ibanCode')
obj_category = 'Interne'
obj_enabled_at =
obj__is_recipient = Dict('recipientOfTransfert', default=False)
class iter_external_recipient(DictElement):
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