Martin Sicot
Committed by Romain Bignon
Builds for 1 pipeline failed in 2 minutes 34 seconds

[groupama] New AV page handled

AV page was't in our links, hence we did not handle it.
......@@ -17,13 +17,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
import re
from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword
from weboob.capabilities.bank import Account
from weboob.capabilities.base import empty
from .pages import LoginPage, AccountsPage, TransactionsPage, AVAccountPage, AVHistoryPage, FormPage, IbanPage
from .pages import LoginPage, AccountsPage, TransactionsPage, AVAccountPage, AVHistoryPage, FormPage, IbanPage, AvJPage
__all__ = ['GroupamaBrowser']
......@@ -39,8 +40,10 @@ class GroupamaBrowser(LoginBrowser):
accounts = URL('/wps/myportal/TableauDeBord', AccountsPage)
transactions = URL('/wps/myportal/!ut', TransactionsPage)
av_account_form = URL('/wps/myportal/assurancevie/', FormPage)
av_account = URL('https://secure-rivage.(ganassurances|ganpatrimoine|groupama).fr/contratVie.rivage.syntheseContratEparUc.gsi', AVAccountPage)
av_account = URL('https://secure-rivage.(ganassurances|ganpatrimoine|groupama).fr/contratVie.rivage.syntheseContratEparUc.gsi',
'/front/vie/epargne/contrat/(.*)', AVAccountPage)
av_history = URL('https://secure-rivage.(?P<website>.*).fr/contratVie.rivage.mesOperations.gsi', AVHistoryPage)
av_secondary = URL('/api/ecli/vie/contrats/(?P<id_contrat>.*)', AvJPage)
def __init__(self, *args, **kwargs):
super(GroupamaBrowser, self).__init__(*args, **kwargs)
......@@ -68,6 +71,13 @@ class GroupamaBrowser(LoginBrowser):
if self.av_account_form.is_here():
self.page.av_account_form()
account.balance, account.currency = self.page.get_av_balance()
# New page where some AV are stored
elif "front/vie/" in account._link:
link = re.search('contrat\/(.+)-Groupama', account._link)
if link:
self.av_secondary.go(id_contrat=link.group(1))
account.balance, account.currency = self.page.get_av_balance()
self.accounts.stay_or_go()
if account.balance or not balance:
if account.type != Account.TYPE_LIFE_INSURANCE and need_iban:
......
......@@ -25,7 +25,7 @@ import ast
from decimal import Decimal
from weboob.browser.pages import HTMLPage, pagination, LoggedPage, FormNotFound
from weboob.browser.pages import HTMLPage, pagination, LoggedPage, FormNotFound, JsonPage
from weboob.browser.elements import method, TableElement, ItemElement
from weboob.browser.filters.standard import Env, CleanDecimal, CleanText, Date, Regexp, Eval
from weboob.browser.filters.html import Attr, Link, TableCell
......@@ -33,6 +33,7 @@ from weboob.browser.filters.javascript import JSVar
from weboob.capabilities.bank import Account, Investment
from weboob.capabilities.base import NotAvailable
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.browser.filters.json import Dict
class LoginPage(HTMLPage):
......@@ -217,6 +218,13 @@ class AVAccountPage(LoggedPage, HTMLPage):
obj_code_type = Investment.CODE_TYPE_ISIN
class AvJPage(LoggedPage, JsonPage):
def get_av_balance(self):
balance = CleanDecimal(Dict('montant'))(self.doc)
currency = "EUR"
return balance, currency
class AVHistoryPage(LoggedPage, HTMLPage):
@method
class get_av_history(TableElement):
......