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

[cmso] check if account can do transfer or not

parent bdceb999
......@@ -166,6 +166,8 @@ class CmsoParBrowser(LoginBrowser, StatesMixin):
self.transfer_info.go(json={"beneficiaryType":"INTERNATIONAL"})
numbers = self.page.get_numbers()
# to know if account can do transfer
accounts_eligibilite_debit = self.page.get_eligibilite_debit()
# First get all checking accounts...
data = dict(self.infos.stay_or_go().get_typelist())
......@@ -173,6 +175,8 @@ class CmsoParBrowser(LoginBrowser, StatesMixin):
self.page.check_response()
for key in self.page.get_keys():
for a in self.page.iter_accounts(key=key):
if a.id in accounts_eligibilite_debit:
a._eligible_debit = accounts_eligibilite_debit[a.id]
# Can have duplicate account, avoid them
if a._index not in seen:
self.accounts_list.append(a)
......@@ -183,6 +187,8 @@ class CmsoParBrowser(LoginBrowser, StatesMixin):
page = self.accounts.go(data=json.dumps({}), type='epargne', headers=self.json_headers)
for key in page.get_keys():
for a in page.iter_savings(key=key, numbers=numbers):
if a.id in accounts_eligibilite_debit:
a._eligible_debit = accounts_eligibilite_debit[a.id]
if a._index in seen:
acc = seen[a._index]
self.accounts_list.remove(acc)
......
......@@ -135,8 +135,6 @@ class AccountsPage(LoggedPage, JsonPage):
# Iban is available without last 5 numbers, or by sms
obj_iban = NotAvailable
obj__index = Dict('index')
# to know if we can do transfer on account
obj__eligible_debit = Dict('eligibiliteDebit', default=False)
def obj_balance(self):
balance = CleanDecimal(Dict('soldeEuro', default="0"))(self)
......@@ -196,8 +194,6 @@ class AccountsPage(LoggedPage, JsonPage):
obj_coming = CleanDecimal(Dict('AVenir', default=None), default=NotAvailable)
obj__index = Dict('index')
obj__owner = Dict('nomTitulaire')
# to know if we can do transfer on account
obj__eligible_debit = Dict('eligibiliteDebit', default=False)
def obj_id(self):
type = Field('type')(self)
......
......@@ -55,7 +55,7 @@ class RecipientsListPage(LoggedPage, JsonPage):
class TransferInfoPage(LoggedPage, JsonPage):
def get_numbers(self):
def get_transfer_info(self, info):
# If account information is not available when asking for the
# recipients (server error for ex.), return an empty dictionary
# that will be filled later after being returned the json of the
......@@ -63,25 +63,36 @@ class TransferInfoPage(LoggedPage, JsonPage):
if 'listCompteTitulaireCotitulaire' not in self.doc and 'exception' in self.doc:
return {}
ret = {}
information = {
'numbers': ('index', 'numeroContratSouscrit'),
'eligibilite_debit': ('numeroContratSouscrit', 'eligibiliteDebit'),
}
key = information[info][0]
value = information[info][1]
ret = {}
ret.update({
d['index']: d['numeroContratSouscrit']
d[key]: d[value]
for d in self.doc['listCompteTitulaireCotitulaire']
})
ret.update({
d['index']: d['numeroContratSouscrit']
d[key]: d[value]
for p in self.doc['listCompteMandataire'].values()
for d in p
})
ret.update({
d['index']: d['numeroContratSouscrit']
d[key]: d[value]
for p in self.doc['listCompteLegalRep'].values()
for d in p
})
return ret
def get_numbers(self):
return self.get_transfer_info('numbers')
def get_eligibilite_debit(self):
return self.get_transfer_info('eligibilite_debit')
@method
class iter_titu_accounts(DictElement):
item_xpath = 'listCompteTitulaireCotitulaire'
......
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