Commit 7b4c9781 authored by Etienne Lachere's avatar Etienne Lachere Committed by Vincent A

[axabanque] add account ownership

parent 241a12b5
......@@ -27,7 +27,9 @@ from weboob.browser import LoginBrowser, URL, need_login, StatesMixin
from weboob.browser.exceptions import ClientError, HTTPNotFound
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.bill import Subscription
from import Account, Transaction, AddRecipientStep, Recipient
from import (
Account, Transaction, AddRecipientStep, Recipient, AccountOwnership,
from weboob.exceptions import BrowserIncorrectPassword, ActionNeeded
from import Value
from import sorted_transactions
......@@ -175,6 +177,7 @@ class AXABanque(AXABrowser, StatesMixin):
if 'accs' not in self.cache.keys():
accounts = []
ids = set()
owner_name = self.get_profile().name.upper().split(' ', 1)[1]
# Get accounts
......@@ -220,6 +223,7 @@ class AXABanque(AXABrowser, StatesMixin):
# Need it to get accounts from tabs
a._tab, a._pargs, a._purl = tab, page_args, self.url
self.set_ownership(a, owner_name)
# Get investment accounts if there has
......@@ -233,6 +237,24 @@ class AXABanque(AXABrowser, StatesMixin):
return self.cache['accs']
def set_ownership(self, account, owner_name):
# Some accounts _owner attribute says 'MLLE PRENOM NOM1' or other
# only 'NOM' while is 'MME PRENOM NOM1 NOM2' or 'MME PRENOM NOM'
# It makes it pretty hard to determine precisely wether the owernship
# should be OWNER or ATTORNEY. So we prefer set it to NotAvailable:
# better no information than an inaccurate one.
if not account.ownership:
if account.parent and account.parent.ownership:
account.ownership = account.parent.ownership
elif'(m|mr|me|mme|mlle|mle|ml)\.? (.*)\bou (m|mr|me|mme|mlle|mle|ml)\b(.*)', account._owner, re.IGNORECASE):
account.ownership = AccountOwnership.CO_OWNER
elif all(n in account._owner for n in owner_name.split()):
account.ownership = AccountOwnership.OWNER
elif 'Mandat' in account.label:
account.ownership = AccountOwnership.ATTORNEY
account.ownership = NotAvailable
def go_account_pages(self, account, action):
# Default to "comptes"
......@@ -29,7 +29,7 @@ from weboob.browser.pages import HTMLPage, PDFPage, LoggedPage, AbstractPage
from weboob.browser.elements import ItemElement, TableElement, method
from weboob.browser.filters.standard import CleanText, CleanDecimal, Date, Regexp, Field, Env, Currency
from weboob.browser.filters.html import Attr, Link, TableCell
from import Account, Investment
from import Account, Investment, AccountOwnership
from import is_iban_valid
from weboob.capabilities.base import NotAvailable, empty
from weboob.capabilities.profile import Person
......@@ -135,6 +135,7 @@ class AccountsPage(LoggedPage, MyHTMLPage):
account.balance = loan_details.get_loan_balance()
account.currency = loan_details.get_loan_currency()
account.ownership = loan_details.get_loan_ownership()
# Skip loans without any balance (already fully reimbursed)
if empty(account.balance):
......@@ -237,6 +238,7 @@ class AccountsPage(LoggedPage, MyHTMLPage):
account._url = self.doc.xpath('//form[contains(@action, "panorama")]/@action')[0]
account._acctype = "bank"
account._owner = CleanText('./td[has-class("libelle")]')(box)
# get accounts currency
currency_title = table.xpath('./thead//th[@class="montant"]')[0].text.strip()
......@@ -319,6 +321,12 @@ class TransactionsPage(LoggedPage, MyHTMLPage):
def get_loan_currency(self):
return Currency('//*[@id="table-detail"]/tbody/tr/td[@class="capital"]', default=NotAvailable)(self.doc)
def get_loan_ownership(self):
co_owner = CleanText('//td[@class="coEmprunteur"]')(self.doc)
if co_owner:
return AccountOwnership.CO_OWNER
return AccountOwnership.OWNER
def open_market(self):
# only for netfinca PEA
......@@ -30,7 +30,7 @@ from weboob.browser.filters.standard import (
from weboob.browser.filters.json import Dict
from weboob.browser.filters.html import Attr, Link, TableCell
from import Account, Investment
from import Account, Investment, AccountOwnership
from weboob.capabilities.profile import Person
from weboob.capabilities.base import NotAvailable, NotLoaded, empty
from import FrenchTransaction
......@@ -68,6 +68,7 @@ class AccountsPage(LoggedPage, HTMLPage):
obj__acctype = "investment"
obj_type = MapIn(Lower(Field('label')), TYPES, Account.TYPE_UNKNOWN)
obj_url = Attr('.', 'data-module-open-link--link')
obj_ownership = AccountOwnership.OWNER
class InvestmentPage(LoggedPage, HTMLPage):
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