Commit daf6cbae authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[cragr] Include company name in accounts name

Currently, account labels have no informations on who the accounts
belongs to. For Organization connections with accounts belonging to
different organization this caused multiple accounts with the same label
but no way to identify which organization it belonged to.
parent c920d0f1
......@@ -272,7 +272,6 @@ class CragrAPI(LoginBrowser):
card._contract = contract
deferred_cards[card.id] = card
main_account.owner_type = self.page.get_owner_type()
main_account._contract = contract
else:
main_account = None
......@@ -281,7 +280,6 @@ class CragrAPI(LoginBrowser):
accounts_list = list(self.page.iter_accounts())
for account in accounts_list:
account._contract = contract
account.owner_type = self.page.get_owner_type()
''' Other accounts have no balance in the main JSON, so we must get all
the (_id_element_contrat, balance) pairs in the account_details JSON.
......
......@@ -264,7 +264,19 @@ class AccountsPage(LoggedPage, JsonPage):
obj_id = CleanText(Dict('comptePrincipal/numeroCompte'))
obj_number = CleanText(Dict('comptePrincipal/numeroCompte'))
obj_label = CleanText(Dict('comptePrincipal/libelleProduit'))
def obj_owner_type(self):
return self.page.get_owner_type()
def obj_label(self):
if Field('owner_type')(self) == AccountOwnerType.PRIVATE:
# All the accounts have the same owner if it is private,
# so adding the owner in the libelle is useless.
return CleanText(Dict('comptePrincipal/libelleProduit'))(self)
return Format('%s %s',
CleanText(Dict('comptePrincipal/libelleProduit')),
CleanText(Dict('comptePrincipal/libellePartenaireBam')),
)(self)
def obj_balance(self):
balance = Dict('comptePrincipal/solde', default=NotAvailable)(self)
......@@ -333,7 +345,6 @@ class AccountsPage(LoggedPage, JsonPage):
return CleanText(Dict('numeroCompte'))(self)
obj_number = CleanText(Dict('numeroCompte'))
obj_label = CleanText(Dict('libelleProduit'))
obj_currency = CleanCurrency(Dict('idDevise'))
obj__index = Dict('index')
obj__category = Coalesce(
......@@ -344,6 +355,19 @@ class AccountsPage(LoggedPage, JsonPage):
obj__fam_product_code = CleanText(Dict('codeFamilleProduitBam'))
obj__fam_contract_code = CleanText(Dict('codeFamilleContratBam'))
def obj_owner_type(self):
return self.page.get_owner_type()
def obj_label(self):
if Field('owner_type')(self) == AccountOwnerType.PRIVATE:
# All the accounts have the same owner if it is private,
# so adding the owner in the libelle is useless.
return CleanText(Dict('libelleProduit'))(self)
return Format('%s %s',
CleanText(Dict('libelleProduit')),
CleanText(Dict('libellePartenaireBam')),
)(self)
def obj_type(self):
if CleanText(Dict('libelleUsuelProduit'))(self) in ('HABITATION',):
# No need to log warning for "assurance" accounts
......
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