Commit 0fd21302 authored by Florian Duguet's avatar Florian Duguet Committed by Romain Bignon

[amazon] fix download_document

remove download_document_pdf since document are already in pdf
return documents list ordered from more recent to older one
parent 9a061ea3
......@@ -181,11 +181,12 @@ class AmazonBrowser(LoginBrowser, StatesMixin):
@need_login
def iter_documents(self, subscription):
documents = []
for y in range(date.today().year - 2, date.today().year + 1):
self.documents.go(year=y)
year = date.today().year
old_year = year - 2
while year >= old_year:
self.documents.go(year=year)
request_id = self.page.response.headers['x-amz-rid']
for doc in self.page.iter_documents(subid=subscription.id, currency=self.CURRENCY, request_id=request_id):
documents.append(doc)
return documents
yield doc
year -= 1
......@@ -24,7 +24,6 @@ from weboob.capabilities.bill import DocumentTypes, CapDocument, Subscription, D
from weboob.capabilities.base import find_object, NotAvailable
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value
from weboob.tools.pdf import html_to_pdf
from .browser import AmazonBrowser
from .en.browser import AmazonEnBrowser
......@@ -94,11 +93,3 @@ class AmazonModule(Module, CapDocument):
return
return self.browser.open(document.url).content
def download_document_pdf(self, document):
if not isinstance(document, Document):
document = self.get_document(document)
if document.url is NotAvailable:
return
return html_to_pdf(self.browser, url=self.browser.BASEURL + document.url)
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