def iter_bills(self, sub): #pdb.set_trace() years = [None] + self.document.xpath('//ul[@class="years"]/li/a') for year in years: #pdb.set_trace() if year is not None and year.attrib['href']: self.browser.location(year.attrib['href']) tables = self.browser.page.document.xpath('//table[contains(@summary, "factures")]') for table in tables: for tr in table.xpath('.//tr'): list_tds = tr.xpath('.//td') if len(list_tds) == 0: continue url = re.sub('[\r\n\t]', '', list_tds[0].xpath('.//a')[0].attrib['href']) date_search = re.search('dateFactureQE=(\d+/\d+/\d+)', url) if not date_search: continue date = datetime.strptime(date_search.group(1), "%d/%m/%Y").date() amount = self.parser.tocleanstring(list_tds[2]) if amount is None: continue bill = Bill() bill.id = sub._id + "." + date.strftime("%Y%m%d") bill.price = Decimal(FrenchTransaction.clean_amount(amount)) bill.currency = bill.get_currency(amount) bill.date = date bill.label = self.parser.tocleanstring(list_tds[0]) bill.format = u'pdf' bill._url = url yield bill
def iter_bills(self, subscription): orders = self.iter_orders() for o in orders: b = Bill() b._url = 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.currency = b.get_currency(self.get_currency()) b.vat = o.tax yield b
def iter_documents(self, subscription): orders = self.iter_orders() for o in orders: b = Bill() b._url = 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.vat = o.tax yield b
def iter_documents(self, sub): #pdb.set_trace() years = [None] + self.document.xpath('//ul[@class="years"]/li/a') for year in years: #pdb.set_trace() if year is not None and year.attrib['href']: self.browser.location(year.attrib['href']) tables = self.browser.page.document.xpath('//table[contains(@summary, "factures")]') for table in tables: for tr in table.xpath('.//tr'): list_tds = tr.xpath('.//td') if len(list_tds) == 0: continue url = re.sub('[\r\n\t]', '', list_tds[0].xpath('.//a')[0].attrib['href']) date_search = re.search('dateFactureQE=(\d+/\d+/\d+)', url) if not date_search: continue date = datetime.strptime(date_search.group(1), "%d/%m/%Y").date() amount = self.parser.tocleanstring(list_tds[2]) if amount is None: continue bill = Bill() bill.id = sub._id + "." + date.strftime("%Y%m%d") bill.price = Decimal(FrenchTransaction.clean_amount(amount)) bill.currency = bill.get_currency(amount) bill.date = date bill.label = self.parser.tocleanstring(list_tds[0]) bill.format = u'pdf' bill.type = u'bill' bill._url = url yield bill
def obj_currency(self): return Bill.get_currency( CleanText('span[@class="montant"]')(self))