Commit bac3b4ca authored by Vincent Ardisson's avatar Vincent Ardisson Committed by Romain Bignon

modules: use DocumentTypes wherever possible

parent 20a629c0
......@@ -26,7 +26,7 @@ from weboob.browser.filters.standard import (
CleanText, CleanDecimal, Env, Regexp, Format,
Field, Currency, RegexpError, Date, Async, AsyncLoad
)
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.capabilities.base import NotAvailable
from weboob.tools.date import parse_french_date
......@@ -131,7 +131,7 @@ class DocumentsPage(LoggedPage, HTMLPage):
obj_url = Async('details') & Link('//a[contains(@href, "download")]|//a[contains(@href, "generated_invoices")]')
obj_format = 'pdf'
obj_label = Format('Facture %s', Field('_simple_id'))
obj_type = 'bill'
obj_type = DocumentTypes.BILL
def obj_date(self):
date = Date(CleanText('.//div[has-class("a-span4") and not(has-class("recipient"))]/div[2]'),
......
......@@ -25,7 +25,7 @@ from decimal import Decimal
from weboob.browser.filters.html import Attr, XPathNotFound
from weboob.browser.pages import HTMLPage, RawPage, LoggedPage
from weboob.capabilities.bill import Subscription, Detail, Bill
from weboob.capabilities.bill import DocumentTypes, Subscription, Detail, Bill
from weboob.browser.filters.standard import CleanText, Regexp
from weboob.exceptions import BrowserUnavailable
......@@ -132,7 +132,7 @@ class LastPaymentsPage(LoggedPage, AmeliBasePage):
bil.id = sub._id + "." + date.strftime("%Y%m")
bil.date = date
bil.format = 'pdf'
bil.type = 'bill'
bil.type = DocumentTypes.BILL
bil.label = date.strftime("%Y%m%d")
bil.url = '/PortailAS/PDFServletReleveMensuel.dopdf?PDF.moisRecherche=' + date.strftime("%m%Y")
yield bil
......
......@@ -22,7 +22,7 @@ from datetime import datetime
import re
from decimal import Decimal
from weboob.browser.pages import HTMLPage
from weboob.capabilities.bill import Subscription, Detail, Bill
from weboob.capabilities.bill import DocumentTypes, Subscription, Detail, Bill
# Ugly array to avoid the use of french locale
......@@ -111,7 +111,7 @@ class BillsPage(HTMLPage):
bil.price = 0
bil.label = u''+date.strftime("%Y%m%d")
bil.format = u''+format
bil.type = u'bill'
bil.type = DocumentTypes.BILL
filedate = date.strftime("%m%Y")
bil.url = u'/PortailPS/fichier.do'
bil._data = {'FICHIER.type': format.lower()+'.releveCompteMensuel',
......
......@@ -22,7 +22,7 @@ from __future__ import unicode_literals
from datetime import timedelta, datetime
from weboob.browser import LoginBrowser, need_login, URL
from weboob.capabilities.bill import Document
from weboob.capabilities.bill import DocumentTypes, Document
from weboob.tools.capabilities.bank.investments import create_french_liquidity
from .pages import (
......@@ -97,6 +97,6 @@ class BoldenBrowser(LoginBrowser):
doc.id = inv.id
doc.url = inv._docurl
doc.label = 'Contrat %s' % inv.label
doc.type = 'other'
doc.type = DocumentTypes.OTHER
doc.format = 'pdf'
yield doc
......@@ -21,7 +21,7 @@ from __future__ import unicode_literals
import re
from weboob.capabilities.bill import Subscription, Document
from weboob.capabilities.bill import DocumentTypes, Subscription, Document
from weboob.browser.pages import LoggedPage, HTMLPage
from weboob.browser.filters.standard import CleanText, Regexp, Env, Date, Format, Field
from weboob.browser.filters.html import Link, Attr, TableCell
......@@ -62,7 +62,7 @@ class SubscriptionPage(LoggedPage, HTMLPage):
obj_label = Format('%s - %s', CleanText('.//span[contains(@class, "lib")]'), CleanText('.//span[contains(@class, "date")]'))
obj_url = Format('/voscomptes/canalXHTML/relevePdf/relevePdf_historique/%s', Link('./a'))
obj_format = 'pdf'
obj_type = 'other'
obj_type = DocumentTypes.OTHER
def obj_date(self):
date = CleanText('.//span[contains(@class, "date")]')(self)
......@@ -141,7 +141,7 @@ class ProSubscriptionPage(LoggedPage, HTMLPage):
# on the page of the year XXX for the subscription YYYY
obj_url = Link('.//a')
obj_format = 'pdf'
obj_type = 'other'
obj_type = DocumentTypes.OTHER
def submit_form(self, sub_number, year):
form = self.get_form(name='formRechHisto')
......
......@@ -29,7 +29,7 @@ from weboob.capabilities import NotAvailable
from weboob.capabilities.bank import Account, Transaction
from weboob.capabilities.contact import Advisor
from weboob.capabilities.profile import Profile
from weboob.capabilities.bill import Subscription, Document
from weboob.capabilities.bill import DocumentTypes, Subscription, Document
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.exceptions import BrowserUnavailable
......@@ -278,7 +278,7 @@ class SubscriptionPage(LoggedPage, CenetJsonPage):
obj_id = Format('%s_%s_%s', Env('sub_id'), Dict('Numero'), CleanText(Env('french_date'), symbols='/'))
obj_format = 'pdf'
obj_type = 'other'
obj_type = DocumentTypes.OTHER
obj__numero = CleanText(Dict('Numero'))
obj__sub_id = Env('sub_id')
obj__sub_label = Env('sub_label')
......
......@@ -37,7 +37,7 @@ from weboob.capabilities.bank import (
Account, Investment, Recipient, TransferError, TransferBankError, Transfer,
AddRecipientBankError, Loan,
)
from weboob.capabilities.bill import Subscription, Document
from weboob.capabilities.bill import DocumentTypes, Subscription, Document
from weboob.tools.capabilities.bank.investments import is_isin_valid
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.tools.capabilities.bank.iban import is_rib_valid, rib2iban, is_iban_valid
......@@ -1388,7 +1388,7 @@ class SubscriptionPage(LoggedPage, HTMLPage):
obj_label = Format('%s %s', CleanText('./preceding::h3[1]'), CleanText('./span'))
obj_date = Date(CleanText('./span'), dayfirst=True)
obj_type = 'other'
obj_type = DocumentTypes.OTHER
obj_format = 'pdf'
obj_url = Regexp(Link('.'), r'WebForm_PostBackOptions\("(\S*)"')
obj_id = Format('%s_%s_%s', Env('sub_id'), CleanText('./span', symbols='/'), Regexp(Field('url'), r'ctl(.*)'))
......
......@@ -24,7 +24,7 @@ from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.browser.elements import ItemElement, TableElement, method
from weboob.browser.filters.standard import CleanText, CleanDecimal, Env, Regexp, Format, Date, Async, AsyncLoad
from weboob.browser.filters.html import Link
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.capabilities.base import NotAvailable
class LoginPage(HTMLPage):
......@@ -68,7 +68,7 @@ class DocumentsPage(LoggedPage, HTMLPage):
obj_date = Async('details') & Date(Regexp(CleanText('.//h3'), r'(\d{2}\/\d{2}\/\d{4})'), dayfirst=True)
obj_format = 'html'
obj_label = Async('details') & CleanText('.//h3')
obj_type = 'bill'
obj_type = DocumentTypes.BILL
obj_price = Async('details') & CleanDecimal('.//td[.="Total"]/following-sibling::td')
obj_vat = Async('details') & CleanDecimal('.//td[contains(text(), "TVA")]/following-sibling::td')
obj_currency = u'EUR'
......@@ -48,7 +48,7 @@ from weboob.capabilities.contact import Advisor
from weboob.capabilities.profile import Profile
from weboob.tools.capabilities.bank.iban import is_iban_valid
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.capabilities.bill import Subscription, Document
from weboob.capabilities.bill import DocumentTypes, Subscription, Document
from weboob.tools.compat import urlparse, parse_qs, urljoin, range, unicode
from weboob.tools.date import parse_french_date
from weboob.tools.value import Value
......@@ -1826,7 +1826,7 @@ class SubscriptionPage(LoggedPage, HTMLPage):
obj_label = Format('%s %s', CleanText(TableCell('url')), CleanText(TableCell('date')))
obj_date = Date(CleanText(TableCell('date')), dayfirst=True)
obj_format = 'pdf'
obj_type = 'other'
obj_type = DocumentTypes.OTHER
def obj_url(self):
return urljoin(self.page.url, '/fr/banque/%s' % Link('./a')(TableCell('url')(self)[0]))
......
......@@ -27,7 +27,7 @@ from weboob.browser.pages import LoggedPage, JsonPage, HTMLPage, RawPage
from weboob.browser.filters.standard import Env, Format, Date, Eval
from weboob.browser.elements import ItemElement, DictElement, method
from weboob.browser.filters.json import Dict
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.profile import Profile
......@@ -96,7 +96,7 @@ class DocumentsPage(LoggedPage, JsonPage):
.strftime('%Y-%m-%d'), Dict('creationDate')))
obj_format = 'pdf'
obj_label = Format('Facture %s', Dict('documentNumber'))
obj_type = 'bill'
obj_type = DocumentTypes.BILL
obj_price = Env('price')
obj_currency = 'EUR'
obj_vat = NotAvailable
......
......@@ -26,7 +26,7 @@ from weboob.browser.elements import DictElement, ItemElement, method
from weboob.browser.filters.standard import CleanDecimal, CleanText
from weboob.browser.filters.html import CleanHTML
from weboob.browser.filters.json import Dict
from weboob.capabilities.bill import Subscription, Bill
from weboob.capabilities.bill import DocumentTypes, Subscription, Bill
from weboob.exceptions import ActionNeeded
from weboob.capabilities.profile import Profile
......@@ -98,7 +98,7 @@ class DocumentsPage(LoggedPage, JsonPage):
doc.date = date.fromtimestamp(int(document['dateEmission'] / 1000))
doc.format = 'PDF'
doc.label = 'Facture %s' % document['numFactureLabel']
doc.type = 'bill'
doc.type = DocumentTypes.BILL
doc.price = CleanDecimal().filter(document['montantTTC'])
doc.currency = '€'
doc._account_billing = document['compteFacturation']
......
......@@ -30,7 +30,7 @@ from weboob.browser.filters.standard import (
)
from weboob.browser.filters.html import AbsoluteLink, Attr, Link, XPath
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.bill import Subscription, Bill, Document
from weboob.capabilities.bill import DocumentTypes, Subscription, Bill, Document
class LoginPage(HTMLPage):
......@@ -95,7 +95,7 @@ class BillsPage(EkwateurPage):
CleanText(TableCell('amount')),
CleanText(TableCell('date'))
)
obj_type = 'bill'
obj_type = DocumentTypes.BILL
obj_price = CleanDecimal(TableCell('amount'), replace_dots=True)
obj_currency = Currency(TableCell('amount'))
obj_duedate = Date(
......
......@@ -27,7 +27,7 @@ from weboob.browser.elements import ItemElement, ListElement, method
from weboob.browser.filters.standard import Date, CleanText, Filter,\
CleanDecimal, Currency, Regexp, Field, DateTime, Format, Env
from weboob.browser.filters.html import AbsoluteLink, Attr
from weboob.capabilities.bill import Detail, Bill
from weboob.capabilities.bill import DocumentTypes, Detail, Bill
from weboob.capabilities.base import NotAvailable
from weboob.exceptions import ParseError
from weboob.tools.compat import unicode
......@@ -128,7 +128,7 @@ class DetailsPage(LoggedPage, BadUTF8Page):
obj_id = Format('%s.%s', Env('subid'), Field('_localid'))
obj_date = FormatDate(Field('label'))
obj_format = u"pdf"
obj_type = u"bill"
obj_type = DocumentTypes.BILL
obj_price = CleanDecimal('div[@class="montant"]', default=Decimal(0), replace_dots=False)
obj_currency = Currency('div[@class="montant"]')
......
......@@ -27,7 +27,7 @@ from weboob.browser.filters.standard import (
CleanDecimal, Env, Regexp, Format, Currency, Field, Eval,
)
from weboob.browser.filters.json import Dict
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.tools.compat import urljoin
......@@ -65,5 +65,5 @@ class DocumentsPage(LoggedPage, JsonPage):
obj_label = Format('Facture %s', _num)
obj_price = CleanDecimal(Dict('fMontant'))
obj_currency = Currency(Dict('sMontant'))
obj_type = 'bill'
obj_type = DocumentTypes.BILL
obj_format = 'pdf'
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.browser.pages import HTMLPage, LoggedPage, pagination
from weboob.browser.filters.standard import Filter, CleanText, Format, Field, Env, Date
from weboob.browser.filters.html import Attr
......@@ -87,5 +87,5 @@ class BillsPage(LoggedPage, HTMLPage):
# Force first day of month as label is in form "janvier 2016"
obj_date = Format("1 %s", Field('label')) & Date(parse_func=parse_french_date)
obj_format = u"pdf"
obj_type = u"bill"
obj_type = DocumentTypes.BILL
obj__localid = Attr('a[2]', 'onclick')
......@@ -25,7 +25,7 @@ from weboob.browser.pages import HTMLPage, LoggedPage, PartialHTMLPage
from weboob.browser.filters.standard import CleanText, CleanDecimal, Env, Format, Date, Async, Filter, Regexp, Field
from weboob.browser.elements import ListElement, ItemElement, method
from weboob.browser.filters.html import Attr, Link
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.capabilities.base import NotAvailable
from weboob.exceptions import BrowserIncorrectPassword
......@@ -94,7 +94,7 @@ class DocumentsPage(LoggedPage, PartialHTMLPage):
obj_date = Date(CleanText('./div[contains(@class, "date")]'), dayfirst=True)
obj_format = 'pdf'
obj_label = Regexp(CleanText('./div[contains(@class, "ref")]'), r' (.*)')
obj_type = 'bill'
obj_type = DocumentTypes.BILL
obj_price = CleanDecimal(CleanText('./div[contains(@class, "price")]'), replace_dots=(' ', '€'))
obj_currency = 'EUR'
......
......@@ -24,7 +24,7 @@ from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.browser.filters.standard import CleanText, CleanDecimal, Env, Format, Date
from weboob.browser.filters.html import Attr, TableCell
from weboob.browser.elements import ListElement, ItemElement, TableElement, method
from weboob.capabilities.bill import Bill, Document, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Document, Subscription
from weboob.capabilities.base import NotAvailable
......@@ -68,7 +68,7 @@ class DocumentsPage(LoggedPage, HTMLPage):
obj_date = Date(CleanText(TableCell('date')))
obj_format = u"pdf"
obj_label = Format('Facture %s', CleanDecimal(TableCell('id')))
obj_type = u"bill"
obj_type = DocumentTypes.BILL
obj_price = CleanDecimal(TableCell('price'))
obj_currency = u'EUR'
......@@ -90,7 +90,7 @@ class DocumentsPage(LoggedPage, HTMLPage):
obj__url = Attr('.', 'href')
obj_format = u"pdf"
obj_label = CleanText('.')
obj_type = u"other"
obj_type = DocumentTypes.OTHER
def parse(self, el):
self.env['username'] = self.page.browser.username
......
......@@ -33,7 +33,7 @@ from weboob.browser.filters.html import Link, TableCell
from weboob.browser.filters.javascript import JSValue
from weboob.browser.filters.json import Dict
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.bill import Bill
from weboob.capabilities.bill import DocumentTypes, Bill
from weboob.tools.date import parse_french_date
from weboob.tools.compat import urlencode
......@@ -82,7 +82,7 @@ class BillsPage(LoggedPage, HTMLPage):
class item(ItemElement):
klass = Bill
obj_type = u"bill"
obj_type = DocumentTypes.BILL
obj_format = u"pdf"
# TableCell('date') can have other info like: 'duplicata'
......
......@@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
from weboob.browser.pages import HTMLPage, LoggedPage, JsonPage
from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Date
from weboob.browser.filters.html import Attr
......@@ -87,7 +87,7 @@ class BillsPage(LoggedPage, JsonPage):
obj_id = Format('%s.%s', Env('subid'), Dict('orderId'))
obj_date = Date(Dict('billingDate'))
obj_format = u"pdf"
obj_type = u"bill"
obj_type = DocumentTypes.BILL
obj_price = CleanDecimal(Dict('priceWithTax/value'))
obj_url = Dict('pdfUrl')
obj_label = Format('Facture %s', Dict('orderId'))
......@@ -25,7 +25,7 @@ from weboob.browser.browsers import APIBrowser
from weboob.exceptions import BrowserIncorrectPassword
from weboob.browser.filters.standard import CleanDecimal, Date
from weboob.browser.exceptions import ClientError
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.bill import DocumentTypes, Bill, Subscription
class TrainlineBrowser(APIBrowser):
......@@ -79,7 +79,7 @@ class TrainlineBrowser(APIBrowser):
b.date = Date().filter(proof['created_at'])
b.format = u"pdf"
b.label = u'Trajet du %s' % Date().filter(trip['departure_date'])
b.type = u"bill"
b.type = DocumentTypes.BILL
b.vat = CleanDecimal().filter('0')
if pnr['cents']:
b.price = CleanDecimal().filter(format(pnr['cents']/float(100), '.2f'))
......
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