Commit e175d515 authored by Martin Sicot's avatar Martin Sicot Committed by Romain Bignon

[groupama] New AV page handled

AV page was't in our links, hence we did not handle it.
parent bbef05ce
Pipeline #1796 failed with stages
in 2 minutes and 34 seconds
...@@ -17,13 +17,14 @@ ...@@ -17,13 +17,14 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
import re
from weboob.browser import LoginBrowser, URL, need_login from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword from weboob.exceptions import BrowserIncorrectPassword
from weboob.capabilities.bank import Account from weboob.capabilities.bank import Account
from weboob.capabilities.base import empty 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'] __all__ = ['GroupamaBrowser']
...@@ -39,8 +40,10 @@ class GroupamaBrowser(LoginBrowser): ...@@ -39,8 +40,10 @@ class GroupamaBrowser(LoginBrowser):
accounts = URL('/wps/myportal/TableauDeBord', AccountsPage) accounts = URL('/wps/myportal/TableauDeBord', AccountsPage)
transactions = URL('/wps/myportal/!ut', TransactionsPage) transactions = URL('/wps/myportal/!ut', TransactionsPage)
av_account_form = URL('/wps/myportal/assurancevie/', FormPage) 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_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): def __init__(self, *args, **kwargs):
super(GroupamaBrowser, self).__init__(*args, **kwargs) super(GroupamaBrowser, self).__init__(*args, **kwargs)
...@@ -68,6 +71,13 @@ class GroupamaBrowser(LoginBrowser): ...@@ -68,6 +71,13 @@ class GroupamaBrowser(LoginBrowser):
if self.av_account_form.is_here(): if self.av_account_form.is_here():
self.page.av_account_form() self.page.av_account_form()
account.balance, account.currency = self.page.get_av_balance() 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() self.accounts.stay_or_go()
if account.balance or not balance: if account.balance or not balance:
if account.type != Account.TYPE_LIFE_INSURANCE and need_iban: if account.type != Account.TYPE_LIFE_INSURANCE and need_iban:
......
...@@ -25,7 +25,7 @@ import ast ...@@ -25,7 +25,7 @@ import ast
from decimal import Decimal 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.elements import method, TableElement, ItemElement
from weboob.browser.filters.standard import Env, CleanDecimal, CleanText, Date, Regexp, Eval from weboob.browser.filters.standard import Env, CleanDecimal, CleanText, Date, Regexp, Eval
from weboob.browser.filters.html import Attr, Link, TableCell from weboob.browser.filters.html import Attr, Link, TableCell
...@@ -33,6 +33,7 @@ from weboob.browser.filters.javascript import JSVar ...@@ -33,6 +33,7 @@ from weboob.browser.filters.javascript import JSVar
from weboob.capabilities.bank import Account, Investment from weboob.capabilities.bank import Account, Investment
from weboob.capabilities.base import NotAvailable from weboob.capabilities.base import NotAvailable
from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.browser.filters.json import Dict
class LoginPage(HTMLPage): class LoginPage(HTMLPage):
...@@ -217,6 +218,13 @@ class AVAccountPage(LoggedPage, HTMLPage): ...@@ -217,6 +218,13 @@ class AVAccountPage(LoggedPage, HTMLPage):
obj_code_type = Investment.CODE_TYPE_ISIN 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): class AVHistoryPage(LoggedPage, HTMLPage):
@method @method
class get_av_history(TableElement): class get_av_history(TableElement):
......
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