Commit 43107056 authored by thibault douge's avatar thibault douge Committed by Vincent A

[impotsgouvfrpar] add third party document

parent afffcee9
Pipeline #3191 passed with stages
in 17 minutes and 17 seconds
......@@ -22,7 +22,7 @@ from __future__ import unicode_literals
from weboob.browser import AbstractBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword
from .pages import LoginAccessPage, LoginAELPage, ProfilePage, DocumentsPage
from .pages import LoginAccessPage, LoginAELPage, ProfilePage, DocumentsPage, ThirdPartyDocPage
class ImpotsParBrowser(AbstractBrowser):
......@@ -31,6 +31,7 @@ class ImpotsParBrowser(AbstractBrowser):
login_access = URL(r'/LoginAccess', LoginAccessPage)
login_ael = URL(r'/LoginAEL', LoginAELPage)
third_party_doc_page = URL(r'/enp/ensu/dpr.do', ThirdPartyDocPage)
# affichageadresse.do is pretty similar to chargementprofil.do but display address
profile = URL(
......@@ -94,9 +95,14 @@ class ImpotsParBrowser(AbstractBrowser):
@need_login
def iter_documents(self, subscription):
# it's a document json which is used in the event of a declaration by a third party
self.third_party_doc_page.go()
yield self.page.get_third_party_doc()
# put ?n=0, else website return an error page
self.documents.go(params={'n': 0})
return self.page.iter_documents(subid=subscription.id)
for doc in self.page.iter_documents(subid=subscription.id):
yield doc
@need_login
def get_profile(self):
......
......@@ -52,7 +52,7 @@ class ImpotsGouvFrParModule(AbstractModule, CapDocument, CapProfile):
BROWSER = ImpotsParBrowser
accepted_document_types = (DocumentTypes.INCOME_TAX,)
accepted_document_types = (DocumentTypes.INCOME_TAX, DocumentTypes.OTHER)
def create_default_browser(self):
return self.create_browser(
......
......@@ -22,10 +22,11 @@ from __future__ import unicode_literals
import hashlib
import re
from weboob.browser.pages import HTMLPage, LoggedPage, pagination
from weboob.browser.pages import HTMLPage, LoggedPage, pagination, JsonPage
from weboob.browser.filters.standard import (
CleanText, Env, Field, Regexp, Format, Date,
)
from weboob.browser.filters.json import Dict
from weboob.browser.elements import ListElement, ItemElement, method
from weboob.browser.filters.html import Attr
from weboob.capabilities.address import PostalAddress
......@@ -58,6 +59,20 @@ class LoginAELPage(HTMLPage):
return Regexp(CleanText('//body/script'), r"postMessage\('ok,(.*)',")(self.doc)
class ThirdPartyDocPage(LoggedPage, JsonPage):
@method
class get_third_party_doc(ItemElement):
klass = Document
obj_id = Format('%s_%s', Dict('spiDec1'), Dict('dateNaisDec1'))
obj_format = 'json'
obj_label = 'Déclaration par un tiers'
obj_type = DocumentTypes.OTHER
def obj_url(self):
return self.page.url
class ProfilePage(LoggedPage, HTMLPage):
def get_documents_link(self):
return self.doc.xpath('//a[contains(@title, "déclarations")]/@href')[0]
......
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