Ejemplo n.º 1
0
    def iter_documents(self):
        table = self.doc.xpath('//table[@id="releveCompteMensuel"]')[0].xpath(
            './/tr')
        for tr in table:
            list_tds = tr.xpath('.//td')
            if len(list_tds) == 0:
                continue

            date_str = tr.xpath('.//td[@class="cAlignGauche"]')[0].text
            month_str = date_str.split()[0]
            date = datetime.strptime(
                re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1),
                       date_str), "%m %Y").date()
            amount = tr.xpath('.//td[@class="cAlignDroite"]')[0].text
            amount = re.sub('[^\d,-]+', '', amount)
            for format in ('CSV', 'PDF'):
                bil = Bill()
                bil.id = date.strftime("%Y%m") + format
                bil.date = date
                clean_amount = amount.strip().replace(',', '.')
                if clean_amount != '':
                    bil.price = Decimal('-' + clean_amount)
                else:
                    bil.price = 0
                bil.label = u'' + date.strftime("%Y%m%d")
                bil.format = u'' + format
                bil.type = DocumentTypes.BILL
                filedate = date.strftime("%m%Y")
                bil.url = u'/PortailPS/fichier.do'
                bil._data = {
                    'FICHIER.type': format.lower() + '.releveCompteMensuel',
                    'dateReleve': filedate,
                    'FICHIER.titre': 'Releve' + filedate
                }
                yield bil
Ejemplo n.º 2
0
    def iter_documents(self):
        table = self.doc.xpath('//table[@id="releveCompteMensuel"]')[0].xpath('.//tr')
        for tr in table:
            list_tds = tr.xpath('.//td')
            if len(list_tds) == 0:
                continue

            date_str = tr.xpath('.//td[@class="cAlignGauche"]')[0].text
            month_str = date_str.split()[0]
            date = datetime.strptime(re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1), date_str), "%m %Y").date()
            amount = tr.xpath('.//td[@class="cAlignDroite"]')[0].text
            amount = re.sub('[^\d,-]+', '', amount)
            for format in ('CSV', 'PDF'):
                bil = Bill()
                bil.id = date.strftime("%Y%m") + format
                bil.date = date
                clean_amount = amount.strip().replace(',','.')
                if clean_amount != '':
                    bil.price = Decimal('-'+clean_amount)
                else:
                    bil.price = 0
                bil.label = u''+date.strftime("%Y%m%d")
                bil.format = u''+format
                bil.type = u'bill'
                filedate = date.strftime("%m%Y")
                bil.url = u'/PortailPS/fichier.do'
                bil._data = {'FICHIER.type': format.lower()+'.releveCompteMensuel',
                            'dateReleve': filedate,
                            'FICHIER.titre': 'Releve' + filedate
                            }
                yield bil
Ejemplo n.º 3
0
 def _create_bill(self, date, price, link):
     bill = Bill()
     bill.id = date.__str__().replace('-', '')
     bill.date = date
     bill._price = price
     bill.url = unicode(link)
     bill.format = u'pdf'
     bill.type = u'bill'
     bill.label = unicode(price)
     return bill
Ejemplo n.º 4
0
 def _create_bill(self, date, price, link):
     bill = Bill()
     bill.id = date.__str__().replace('-', '')
     bill.date = date
     bill._price = price
     bill.url = unicode(link)
     bill.format = u'pdf'
     bill.type = u'bill'
     bill.label = unicode(price)
     return bill
Ejemplo n.º 5
0
 def date_bills(self, parentid):
     max = 1
     while len(self.document.xpath('//li[@id="liMois%s"]' % max)) > 0:
         li = self.document.xpath('//li[@id="liMois%s"]' % max)[0]
         max += 1
         link = li.xpath('a')[0]
         bill = Bill()
         bill.url = unicode(link.attrib['href'])
         bill.label = unicode(link.text)
         bill.format = u"pdf"
         bill.type = u"bill"
         bill.id = parentid + bill.label.replace(' ', '')
         yield bill
Ejemplo n.º 6
0
 def iter_documents(self, subscription):
     orders = self.iter_orders()
     for o in orders:
         b = Bill()
         b.url = unicode(o._bill['url'])
         b.id = '%s.%s' % (subscription.id, o.id)
         b.date = o.date
         b.price = o.total
         b.format = o._bill['format']
         b.type = u'bill'
         b.currency = b.get_currency(self.get_currency())
         b.label = '%s %s' % (subscription.label, o.date)
         b.vat = o.tax
         yield b
Ejemplo n.º 7
0
 def iter_documents(self, sub):
     elts = self.doc.xpath('//li[@class="rowdate"]')
     for elt in elts:
         try:
             elt.xpath('.//a[contains(@id,"lienPDFReleve")]')[0]
         except IndexError:
            continue
         date_str = elt.xpath('.//span[contains(@id,"moisEnCours")]')[0].text
         month_str = date_str.split()[0]
         date = datetime.strptime(re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1), date_str), "%m %Y").date()
         bil = Bill()
         bil.id = sub._id + "." + date.strftime("%Y%m")
         bil.date = date
         bil.format = u'pdf'
         bil.type = u'bill'
         bil.label = u'' + date.strftime("%Y%m%d")
         bil.url = urljoin(self.url, '/PortailAS/PDFServletReleveMensuel.dopdf?PDF.moisRecherche=%s' % date.strftime("%m%Y"))
         yield bil
Ejemplo n.º 8
0
 def iter_documents(self, sub):
     elts = self.doc.xpath('//li[@class="rowdate"]')
     for elt in elts:
         try:
             elt.xpath('.//a[contains(@id,"lienPDFReleve")]')[0]
         except IndexError:
             continue
         date_str = elt.xpath(
             './/span[contains(@id,"moisEnCours")]')[0].text
         month_str = date_str.split()[0]
         date = datetime.strptime(
             re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1),
                    date_str), "%m %Y").date()
         bil = Bill()
         bil.id = sub._id + "." + date.strftime("%Y%m")
         bil.date = date
         bil.format = 'pdf'
         bil.type = DocumentTypes.BILL
         bil.label = date.strftime("%Y%m%d")
         bil.url = '/PortailAS/PDFServletReleveMensuel.dopdf?PDF.moisRecherche=' + date.strftime(
             "%m%Y")
         yield bil