From 22f23a279eaa9f32c93c1b21f7e16da141b34f04 Mon Sep 17 00:00:00 2001 From: Maxime Pommier Date: Tue, 16 Apr 2019 15:11:28 +0200 Subject: [PATCH] =?UTF-8?q?[societegenerale]=C2=A0Add=20the=20account=20ow?= =?UTF-8?q?nership=20to=20the=20new=20soge=20website?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/societegenerale/browser.py | 1 + .../societegenerale/pages/accounts_list.py | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/societegenerale/browser.py b/modules/societegenerale/browser.py index e7bf32a0da..f856d6ce70 100644 --- a/modules/societegenerale/browser.py +++ b/modules/societegenerale/browser.py @@ -201,6 +201,7 @@ def get_accounts_list(self): for account in self.page.iter_accounts(): for card in self.iter_cards(account): card.parent = account + card.ownership = account.ownership yield card if account._prestation_id in account_ibans: diff --git a/modules/societegenerale/pages/accounts_list.py b/modules/societegenerale/pages/accounts_list.py index 6767d56397..5c900ef86d 100644 --- a/modules/societegenerale/pages/accounts_list.py +++ b/modules/societegenerale/pages/accounts_list.py @@ -24,7 +24,7 @@ import re from weboob.capabilities.base import NotAvailable -from weboob.capabilities.bank import Account, Investment, Loan +from weboob.capabilities.bank import Account, Investment, Loan, AccountOwnership from weboob.capabilities.contact import Advisor from weboob.capabilities.profile import Person, ProfileMissing from weboob.tools.capabilities.bank.transactions import FrenchTransaction @@ -32,7 +32,7 @@ from weboob.browser.elements import DictElement, ItemElement, TableElement, method, ListElement from weboob.browser.filters.json import Dict from weboob.browser.filters.standard import ( - CleanText, CleanDecimal, Regexp, Currency, Eval, Field, Format, Date, Env, + CleanText, CleanDecimal, Regexp, Currency, Eval, Field, Format, Date, Env, Map ) from weboob.browser.filters.html import Link, TableCell from weboob.browser.pages import HTMLPage, XMLPage, JsonPage, LoggedPage, pagination @@ -167,6 +167,13 @@ def condition(self): 'PERP_EPICEA': Account.TYPE_PERP, } + ACCOUNTS_OWNERSHIP = { + 'COTITULAIRE': AccountOwnership.CO_OWNER, + 'MANDATAIRE': AccountOwnership.ATTORNEY, + 'REPRESENTATION': AccountOwnership.ATTORNEY, # Credentials owner children + 'TITULAIRE': AccountOwnership.OWNER, + } + obj_id = obj_number = CleanText(Dict('numeroCompteFormate'), replace=[(' ', '')]) obj_label = Dict('labelToDisplay') obj_balance = CleanDecimal(Dict('soldes/soldeActuel')) @@ -177,6 +184,15 @@ def condition(self): def obj_type(self): return self.TYPES.get(Dict('produit')(self), Account.TYPE_UNKNOWN) + def obj_ownership(self): + # 'groupeRoleDTO' can contains 'TITULAIRE', 'MANDATAIRE' or 'REPRESENTATION' + # 'role' contains 'groupeRoleDTO' sub-categories. If the groupeRoleDTO is + # 'TUTULAIRE', we have to check the role to know if it's 'TITULAIRE' or 'COTITULAIRE' + ownership = Map(Dict('groupeRoleDTO'), self.ACCOUNTS_OWNERSHIP, NotAvailable)(self) + if ownership == AccountOwnership.OWNER: + ownership = Map(Dict('role'), self.ACCOUNTS_OWNERSHIP, NotAvailable)(self) + return ownership + # Useful for navigation obj__internal_id = Dict('idTechnique') obj__prestation_id = Dict('id') @@ -226,6 +242,7 @@ def get_loan_account(self, account): loan.id = loan.number = account.id loan.label = account.label loan.type = account.type + loan.ownership = account.ownership loan.currency = Currency(Dict('capitalRestantDu/devise'))(acc) loan.balance = Eval(lambda x: x / 100, CleanDecimal(Dict('capitalRestantDu/valeur')))(acc) @@ -247,6 +264,7 @@ def get_revolving_account(self, account): loan.id = loan.number = account.id loan.label = account.label loan.type = account.type + loan.ownership = account.ownership loan.currency = account.currency loan.balance = account.balance -- GitLab