diff --git a/modules/cragr/api/browser.py b/modules/cragr/api/browser.py index c8a1e38c4fe80544d7900f5f65ff7967e948bd93..3d7f475099422364f339a58171ca878355f66e71 100644 --- a/modules/cragr/api/browser.py +++ b/modules/cragr/api/browser.py @@ -272,7 +272,6 @@ def iter_accounts(self): 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 @@ def iter_accounts(self): 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. diff --git a/modules/cragr/api/pages.py b/modules/cragr/api/pages.py index c647597e94426c7db9ccc0085a0ac14687baf03f..61a23764d49b058949654f14c350647a8987f4f8 100644 --- a/modules/cragr/api/pages.py +++ b/modules/cragr/api/pages.py @@ -264,7 +264,19 @@ class get_main_account(ItemElement): 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 @@ def obj_id(self): 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 @@ def obj_id(self): 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