Commit fb79f0dd authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Romain Bignon

[axabanque] Correct scraping of loan balance/currency

The xpath was not working for all accounts (especially when loans where
already fully reimbursed). Now the loans without any balance will be
parent 0ac723f8
......@@ -29,7 +29,7 @@ from weboob.browser.filters.standard import CleanText, CleanDecimal, Date, Regex
from weboob.browser.filters.html import Attr, Link, TableCell
from import Account, Investment
from import is_iban_valid
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.base import NotAvailable, empty
from weboob.capabilities.profile import Person
from import FrenchTransaction
from import unicode
......@@ -126,11 +126,14 @@ class AccountsPage(LoggedPage, MyHTMLPage):
account._args = args
account.label = CleanText().filter(tds[0].xpath('./ancestor::table[has-class("tableaux-pret-personnel")]/caption')) = account.label.split()[-1] + args['paramNumContrat']
loan_details ="/webapp/axabanque/jsp/panorama.faces",data=args)
loan_details ='/webapp/axabanque/jsp/panorama.faces', data=args).page
# Need to go back on home page after open
account.balance = -CleanDecimal().filter('//*[@id="table-detail"]/tbody/tr/td[7]/text()'))
account.currency = Currency().filter('//*[@id="table-detail"]/tbody/tr/td[7]/text()'))
account.balance = loan_details.get_loan_balance()
account.currency = loan_details.get_loan_currency()
# Skip loans without any balance (already fully reimbursed)
if empty(account.balance):
account.type = Account.TYPE_LOAN
account._acctype = "bank"
account._hasinv = False
......@@ -298,6 +301,12 @@ class TransactionsPage(LoggedPage, MyHTMLPage):
error = CleanText(default="").filter(self.doc.xpath('//p[@class="question"]'))
return error if u"a expiré" in error else None
def get_loan_balance(self):
return CleanDecimal.US('//*[@id="table-detail"]/tbody/tr/td[@class="capital"]', default=NotAvailable)(self.doc)
def get_loan_currency(self):
return Currency('//*[@id="table-detail"]/tbody/tr/td[@class="capital"]', default=NotAvailable)(self.doc)
def open_market(self):
# only for netfinca PEA
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