Ejemplo n.º 1
0
 def iter_payment_details(self, sub):
     if sub._id.isdigit():
         idx = 0
     else:
         idx = sub._id.replace('AFFILIE', '')
     if len(self.document.xpath('//div[@class="centrepage"]/h2')) > idx or self.document.xpath('//table[@id="DetailPaiement3"]') > idx:
         id_str = self.document.xpath('//div[@class="centrepage"]/h2')[idx].text.strip()
         m = re.match('.*le (.*) pour un montant de.*', id_str)
         if m:
             id_str = m.group(1)
             id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
             id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
             table = self.document.xpath('//table[@class="tableau"]')[idx].xpath('.//tr')
             line = 1
             last_date = None
             for tr in table:
                 tds = tr.xpath('.//td')
                 if len(tds) == 0:
                     continue
                 date_str = tds[0].text
                 det = Detail()
                 det.id = id + "." + str(line)
                 det.label = unicode(tds[1].text.strip())
                 if date_str is None or date_str == '':
                     det.infos = u''
                     det.datetime = last_date
                 else:
                     det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', tds[2].text)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', tds[3].text)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', tds[4].text)) + '%'
                     det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
                     last_date = det.datetime
                 det.price = Decimal(re.sub('[^\d,-]+', '', tds[5].text).replace(',', '.'))
                 line = line + 1
                 yield det
Ejemplo n.º 2
0
 def iter_history(self):
     tables = self.doc.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')
     if len(tables) > 0:
         lines = tables[0].xpath('.//tr')
         sno = 0
         for tr in lines:
             list_a = tr.xpath('.//a')
             if len(list_a) == 0:
                 continue
             date = tr.xpath('.//td')[0].text.strip()
             lot = list_a[0].text.replace('(*)', '').strip()
             if lot == 'SNL':
                 sno = sno + 1
                 lot = lot + str(sno)
             factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
             factures_lbl = ''
             for a in factures:
                 factures_lbl = factures_lbl + a.text.replace('(**)', '').strip() + ' '
             montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip()
             det = Detail()
             det.id = u''+lot
             det.label = u''+lot
             det.infos = u''+factures_lbl
             det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
             det.price = Decimal(montant.replace(',', '.'))
             yield det
Ejemplo n.º 3
0
    def get_calls(self):
        table = self.document.xpath('//table/tbody')[0]
        for tr in table.xpath('tr'):
            tds = tr.xpath('td')

            rawdate = tds[0].text_content()
            splitdate = rawdate.split('-')
            month_no = self.months.index(splitdate[1]) + 1
            mydate = date(int(splitdate[2]), month_no, int(splitdate[0]))

            rawtime = tds[1].text_content()
            mytime = time(*[int(x) for x in rawtime.split(":")])

            price = re.sub(u'[^\d\-\.]', '', tds[6].text)
            detail = Detail()
            detail.datetime = datetime.combine(mydate, mytime)
            detail.label = u"%s from %s to %s - %s" % (
                tds[2].text, tds[3].text, tds[4].text, tds[5].text)
            try:
                detail.price = Decimal(price)
            except InvalidOperation:
                detail.price = Decimal(0)  # free calls
            detail.currency = Currency.CUR_EUR

            yield detail
Ejemplo n.º 4
0
 def iter_history(self):
     tables = self.doc.xpath(
         '//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')
     if len(tables) > 0:
         lines = tables[0].xpath('.//tr')
         sno = 0
         for tr in lines:
             list_a = tr.xpath('.//a')
             if len(list_a) == 0:
                 continue
             date = tr.xpath('.//td')[0].text.strip()
             lot = list_a[0].text.replace('(*)', '').strip()
             if lot == 'SNL':
                 sno = sno + 1
                 lot = lot + str(sno)
             factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
             factures_lbl = ''
             for a in factures:
                 factures_lbl = factures_lbl + a.text.replace(
                     '(**)', '').strip() + ' '
             montant = tr.xpath(
                 './/div[@class="cAlignDroite"]')[0].text.strip()
             det = Detail()
             det.id = u'' + lot
             det.label = u'' + lot
             det.infos = u'' + factures_lbl
             det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
             det.price = Decimal(montant.replace(',', '.'))
             yield det
Ejemplo n.º 5
0
    def on_loaded(self):
        self.calls = []
        for tr in self.document.xpath('//tr'):
            try:
                attrib = tr.attrib["class"]
            except:
                continue
            if attrib == "even" or attrib == "odd":
                label = u''
                tddate = tr.find('td[@class="middle nowrap"]')
                for td in tr.xpath('td[@class="long"]'):
                    label += unicode(td.text.strip()) + u' '
                tdprice = tr.xpath('td[@class="price"]')
                label += u'(' + unicode(tdprice[0].text.strip()) + u')'
                price = Decimal(tdprice[1].text.strip().replace(',', '.'))
                detail = Detail()
                mydate = date(*reversed([
                    int(x)
                    for x in tddate.text.strip().split(' ')[0].split(".")
                ]))
                mytime = time(*[
                    int(x)
                    for x in tddate.text.strip().split(' ')[1].split(":")
                ])
                detail.datetime = datetime.combine(mydate, mytime)
                detail.label = label
                detail.price = price

                self.calls.append(detail)
Ejemplo n.º 6
0
    def get_calls(self):
        txt = self._parse_pdf()
        pages = txt.split("DEBIT")
        pages.pop(0)  # remove headers
        details = []
        for page in pages:
            page = page.split("RÉGLO MOBILE")[0].split("N.B. Prévoir")[0]  # remove footers
            lines = page.split("\n")
            lines = [x for x in lines if len(x) > 0]  # Remove empty lines
            numitems = (len(lines) + 1) / 4  # Each line has five columns
            lines.pop(0)  # remove the extra € symbol
            modif = 0
            i = 0
            while i < numitems:
                if modif != 0:
                    numitems = (len(lines) + 1 + modif) / 4
                base = i * 4 - modif
                dateop = base
                corres = base + 1
                duree = base + 2
                price = base + 3
                if "Changement vers le Forfait" in lines[base]:
                    modif += 1
                    i += 1
                    continue
                # Special case with 5 columns, the operation date is not in the first one
                if len(re.split("(\d+\/\d+\/\d+)", lines[dateop])) < 2:
                    lines[base + 1] = lines[base] + " " + lines[base + 1]
                    dateop = base + 1
                    corres = base + 2
                    duree = base + 3
                    price = base + 4
                    modif -= 1
                detail = Detail()
                splits = re.split("(\d+\/\d+\/\d+)", lines[dateop])
                mydate = date(*reversed([int(x) for x in splits[1].split("/")]))
                mytime = time(*[int(x) for x in splits[2].split(":")])
                detail.datetime = datetime.combine(mydate, mytime)
                if lines[corres] == "-":
                    lines[corres] = ""
                if lines[duree] == "-":
                    lines[duree] = ""
                detail.label = (
                    unicode(splits[0], encoding="utf-8", errors="replace") + u" " + lines[corres] + u" " + lines[duree]
                )
                # Special case with only 3 columns, we insert a price
                if "Activation de votre ligne" in detail.label:
                    lines.insert(price, "0")
                try:
                    detail.price = Decimal(lines[price].replace(",", "."))
                except:
                    # In some special cases, there are no price column. Try to detect it
                    if "Inclus" not in lines[price]:
                        modif += 1
                    detail.price = Decimal(0)

                details.append(detail)
                i += 1
        return sorted(details, key=_get_date, reverse=True)
Ejemplo n.º 7
0
 def iter_payment_details(self, sub):
     if sub._id.isdigit():
         idx = 0
     else:
         idx = sub._id.replace('AFFILIE', '')
     if len(
             self.document.xpath('//div[@class="centrepage"]/h3')
     ) > idx or self.document.xpath('//table[@id="DetailPaiement3"]') > idx:
         id_str = self.document.xpath(
             '//div[@class="centrepage"]/h3')[idx].text.strip()
         m = re.match('.*le (.*) pour un montant de.*', id_str)
         if m:
             id_str = m.group(1)
             id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
             id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
             table = self.document.xpath(
                 '//table[@id="DetailPaiement3"]')[idx].xpath('.//tr')
             line = 1
             last_date = None
             for tr in table:
                 tds = tr.xpath('.//td')
                 if len(tds) == 0:
                     continue
                 date_str = tds[0].text
                 det = Detail()
                 det.id = id + "." + str(line)
                 det.label = unicode(tds[1].text.strip())
                 if date_str is None or date_str == '':
                     det.infos = u''
                     det.datetime = last_date
                 else:
                     det.infos = u'Payé ' + unicode(
                         re.sub('[^\d,-]+', '',
                                tds[2].text)) + u'€ / Base ' + unicode(
                                    re.sub('[^\d,-]+', '', tds[3].text)
                                ) + u'€ / Taux ' + unicode(
                                    re.sub('[^\d,-]+', '',
                                           tds[4].text)) + '%'
                     det.datetime = datetime.strptime(date_str,
                                                      '%d/%m/%Y').date()
                     last_date = det.datetime
                 det.price = Decimal(
                     re.sub('[^\d,-]+', '', tds[5].text).replace(',', '.'))
                 line = line + 1
                 yield det
Ejemplo n.º 8
0
    def get_calls(self):
        txt = self._parse_pdf()
        pages = txt.split("DEBIT")
        pages.pop(0)  # remove headers
        details = []
        for page in pages:
            page = page.split('RÉGLO MOBILE')[0].split('N.B. Prévoir')[0]  # remove footers
            lines = page.split('\n')
            lines = [x for x in lines if len(x) > 0]  # Remove empty lines
            numitems = (len(lines) + 1) / 4  # Each line has five columns
            lines.pop(0)  # remove the extra € symbol
            modif = 0
            i = 0
            while i < numitems:
                if modif != 0:
                    numitems = ((len(lines) + 1 + modif) / 4)
                base = i * 4 - modif
                dateop = base
                corres = base + 1
                duree = base + 2
                price = base + 3
                if "Changement vers le Forfait" in lines[base]:
                    modif += 1
                    i += 1
                    continue
                # Special case with 5 columns, the operation date is not in the first one
                if len(re.split("(\d+\/\d+\/\d+)", lines[dateop])) < 2:
                    lines[base + 1] = lines[base] + " " + lines[base + 1]
                    dateop = base + 1
                    corres = base + 2
                    duree = base + 3
                    price = base + 4
                    modif -= 1
                detail = Detail()
                splits = re.split("(\d+\/\d+\/\d+)", lines[dateop])
                mydate = date(*reversed([int(x) for x in splits[1].split("/")]))
                mytime = time(*[int(x) for x in splits[2].split(":")])
                detail.datetime = datetime.combine(mydate, mytime)
                if lines[corres] == '-':
                    lines[corres] = ""
                if lines[duree] == '-':
                    lines[duree] = ''
                detail.label = unicode(splits[0], encoding='utf-8', errors='replace') + u" " + lines[corres] + u" " + lines[duree]
                # Special case with only 3 columns, we insert a price
                if "Activation de votre ligne" in detail.label or u"Résiliation" in detail.label:
                    lines.insert(price, '0')
                try:
                    detail.price = Decimal(lines[price].replace(',', '.'))
                except:
                    # In some special cases, there are no price column. Try to detect it
                    if "Inclus" not in lines[price]:
                        modif += 1
                    detail.price = Decimal(0)

                details.append(detail)
                i += 1
        return sorted(details, key=_get_date, reverse=True)
Ejemplo n.º 9
0
 def iter_payment_details(self, sub):
     if sub._id.isdigit():
         idx = 0
     else:
         idx = sub._id.replace("AFFILIE", "")
     if (
         len(self.document.xpath('//div[@class="centrepage"]/h3')) > idx
         or self.document.xpath('//table[@id="DetailPaiement3"]') > idx
     ):
         id_str = self.document.xpath('//div[@class="centrepage"]/h3')[idx].text.strip()
         m = re.match(".*le (.*) pour un montant de.*", id_str)
         if m:
             id_str = m.group(1)
             id_date = datetime.strptime(id_str, "%d/%m/%Y").date()
             id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
             table = self.document.xpath('//table[@id="DetailPaiement3"]')[idx].xpath(".//tr")
             line = 1
             last_date = None
             for tr in table:
                 tds = tr.xpath(".//td")
                 if len(tds) == 0:
                     continue
                 date_str = tds[0].text
                 det = Detail()
                 det.id = id + "." + str(line)
                 det.label = unicode(tds[1].text.strip())
                 if date_str is None or date_str == "":
                     det.infos = u""
                     det.datetime = last_date
                 else:
                     det.infos = (
                         u"Payé "
                         + unicode(re.sub("[^\d,-]+", "", tds[2].text))
                         + u"€ / Base "
                         + unicode(re.sub("[^\d,-]+", "", tds[3].text))
                         + u"€ / Taux "
                         + unicode(re.sub("[^\d,-]+", "", tds[4].text))
                         + "%"
                     )
                     det.datetime = datetime.strptime(date_str, "%d/%m/%Y").date()
                     last_date = det.datetime
                 det.price = Decimal(re.sub("[^\d,-]+", "", tds[5].text).replace(",", "."))
                 line = line + 1
                 yield det
Ejemplo n.º 10
0
    def get_calls(self):
        txt = self._parse_pdf()
        pages = txt.split("DEBIT")
        pages.pop(0)  # remove headers
        details = []
        for page in pages:
            page = page.split('RÉGLO MOBILE')[0].split('N.B. Prévoir')[0]  # remove footers
            lines = page.split('\n')
            lines = [x for x in lines if len(x) > 0]  # Remove empty lines
            numitems = (len(lines) + 1) / 4  # Each line has five columns
            lines.pop(0)
            modif = 0
            i = 0
            while i < numitems:
                if modif != 0:
                    numitems = ((len(lines) + 1 + modif) / 4)
                nature = i * 4 - modif
                dateop = nature
                corres = nature + 1
                duree = corres + 1
                price = duree + 1
                if "Changement vers le Forfait" in lines[nature]:
                    modif += 1
                    i += 1
                    continue
                if len(re.split("(\d+\/\d+\/\d+)", lines[dateop])) < 2:
                    lines[nature + 1] = lines[nature] + " " + lines[nature + 1]
                    dateop = nature + 1
                    corres = dateop + 1
                    duree = corres + 1
                    price = duree + 1
                    modif -= 1
                if not lines[corres][0:3].isdigit() and not lines[corres][0:3] == "-":
                    modif += 1
                detail = Detail()
                splits = re.split("(\d+\/\d+\/\d+)", lines[dateop])
                mydate = date(*reversed([int(x) for x in splits[1].split("/")]))
                mytime = time(*[int(x) for x in splits[2].split(":")])
                detail.datetime = datetime.combine(mydate, mytime)
                if lines[corres] == '-':
                    lines[corres] = ""
                if lines[duree] == '-':
                    lines[duree] = ''
                detail.label = unicode(splits[0], encoding='utf-8', errors='replace') + u" " + lines[corres] + u" " + lines[duree]
                # Special case with only 3 columns, we insert a price
                if "Activation de votre ligne" in detail.label:
                    lines.insert(price, '0')
                try:
                    detail.price = Decimal(lines[price].replace(',', '.'))
                except:
                    detail.price = Decimal(0)

                details.append(detail)
                i += 1
        return sorted(details, key=_get_date, reverse=True)
Ejemplo n.º 11
0
    def iter_payments(self, sub):

        table = self.browser.page.document.xpath('//table[contains(@summary, "Informations sur mon")]')[0]
        for tr in table.xpath('.//tr'):
            list_tds = tr.xpath('.//td')
            if len(list_tds) == 0:
                continue
            date = datetime.strptime(self.parser.tocleanstring(list_tds[0]), "%d/%m/%Y").date()
            amount = self.parser.tocleanstring(list_tds[1])
            if amount is None:
                continue
            det = Detail()
            det.id = sub._id + "." + date.strftime("%Y%m%d")
            det.price = Decimal(re.sub('[^\d,-]+', '', amount).replace(',', '.'))
            det.datetime = date
            det.label = unicode(self.parser.tocleanstring(list_tds[2]))
            yield det
Ejemplo n.º 12
0
    def iter_payments(self, sub):

        table = self.browser.page.document.xpath('//table[contains(@summary, "Informations sur mon")]')[0]
        for tr in table.xpath('.//tr'):
            list_tds = tr.xpath('.//td')
            if len(list_tds) == 0:
                continue
            date = datetime.strptime(self.parser.tocleanstring(list_tds[0]), "%d/%m/%Y").date()
            amount = self.parser.tocleanstring(list_tds[1])
            if amount is None:
                continue
            det = Detail()
            det.id = sub._id + "." + date.strftime("%Y%m%d")
            det.price = Decimal(re.sub('[^\d,-]+', '', amount).replace(',', '.'))
            det.datetime = date
            det.label = unicode(self.parser.tocleanstring(list_tds[2]))
            yield det
Ejemplo n.º 13
0
    def on_loaded(self):
        self.calls = []
        for tr in self.document.xpath('//tr'):
            tds = tr.xpath('td')
            if tds[0].text is None or tds[0].text == "Date":
                pass
            else:
                detail = Detail()
                mydate = date(*reversed([int(x) for x in tds[0].text.split(' ')[0].split("/")]))
                mytime = time(*[int(x) for x in tds[0].text.split(' ')[2].split(":")])
                detail.datetime = datetime.combine(mydate, mytime)
                detail.label = u' '.join([unicode(td.text.strip()) for td in tds[1:4] if td.text is not None])
                try:
                    detail.price = Decimal(tds[4].text[0:4].replace(',', '.'))
                except:
                    detail.price = Decimal(0)

                self.calls.append(detail)
Ejemplo n.º 14
0
 def iter_history(self):
     table = self.document.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')[0].xpath('.//tr')
     for tr in table:
         list_a = tr.xpath('.//a')
         if len(list_a) == 0:
             continue
         date = tr.xpath('.//td')[0].text.strip()
         lot = list_a[0].text
         factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
         factures_lbl = ''
         for a in factures:
             factures_lbl = factures_lbl + a.text + ' '
         montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip()
         det = Detail()
         det.id = lot
         det.label = lot
         det.infos = factures_lbl
         det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
         det.price = Decimal(montant.replace(',', '.'))
         yield det
Ejemplo n.º 15
0
 def iter_history(self):
     table = self.document.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')[0].xpath('.//tr')
     for tr in table:
         list_a = tr.xpath('.//a')
         if len(list_a) == 0:
             continue
         date = tr.xpath('.//td')[0].text.strip()
         lot = list_a[0].text
         factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
         factures_lbl = ''
         for a in factures:
             factures_lbl = factures_lbl + a.text + ' '
         montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip()
         det = Detail()
         det.id = lot
         det.label = lot
         det.infos = factures_lbl
         det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
         det.price = Decimal(montant.replace(',', '.'))
         yield det
Ejemplo n.º 16
0
    def on_loaded(self):
        self.calls = []
        for tr in self.document.xpath('//tr'):
            try:
                attrib = tr.attrib["class"]
            except:
                continue
            if attrib == "even" or attrib == "odd":
                label = u''
                tddate = tr.find('td[@class="middle nowrap"]')
                for td in tr.xpath('td[@class="long"]'):
                    label += unicode(td.text.strip()) + u' '
                tdprice = tr.xpath('td[@class="price"]')
                label += u'(' + unicode(tdprice[0].text.strip()) + u')'
                price = Decimal(tdprice[1].text.strip().replace(',', '.'))
                detail = Detail()
                mydate = date(*reversed([int(x) for x in tddate.text.strip().split(' ')[0].split(".")]))
                mytime = time(*[int(x) for x in tddate.text.strip().split(' ')[1].split(":")])
                detail.datetime = datetime.combine(mydate, mytime)
                detail.label = label
                detail.price = price

                self.calls.append(detail)
Ejemplo n.º 17
0
    def on_loaded(self):
        self.calls = []
        for tr in self.document.xpath('//tr'):
            tds = tr.xpath('td')
            if tds[0].text is None or tds[0].text == "Date":
                pass
            else:
                detail = Detail()
                mydate = date(*reversed(
                    [int(x) for x in tds[0].text.split(' ')[0].split("/")]))
                mytime = time(
                    *[int(x) for x in tds[0].text.split(' ')[2].split(":")])
                detail.datetime = datetime.combine(mydate, mytime)
                detail.label = u' '.join([
                    unicode(td.text.strip()) for td in tds[1:4]
                    if td.text is not None
                ])
                try:
                    detail.price = Decimal(tds[4].text[0:4].replace(',', '.'))
                except:
                    detail.price = Decimal(0)

                self.calls.append(detail)
Ejemplo n.º 18
0
    def get_calls(self):
        table = self.document.xpath('//table/tbody')[0]
        for tr in table.xpath('tr'):
            tds = tr.xpath('td')

            rawdate = tds[0].text_content()
            splitdate = rawdate.split('-')
            month_no = self.months.index(splitdate[1]) + 1
            mydate = date(int(splitdate[2]), month_no, int(splitdate[0]))

            rawtime = tds[1].text_content()
            mytime = time(*[int(x) for x in rawtime.split(":")])

            price = re.sub(u'[^\d\-\.]', '', tds[6].text)
            detail = Detail()
            detail.datetime = datetime.combine(mydate, mytime)
            detail.label = u"%s from %s to %s - %s" % (tds[2].text, tds[3].text, tds[4].text, tds[5].text)
            try:
                detail.price = Decimal(price)
            except InvalidOperation:
                detail.price = Decimal(0)  # free calls
            detail.currency = 'EUR'

            yield detail
Ejemplo n.º 19
0
    def iter_payment_details(self, sub):
        id_str = self.doc.xpath('//div[@class="entete container"]/h2')[0].text.strip()
        m = re.match('.*le (.*) pour un montant de.*', id_str)
        if m:
            blocs_benes = self.doc.xpath('//span[contains(@id,"nomBeneficiaire")]')
            blocs_prestas = self.doc.xpath('//table[@id="tableauPrestation"]')
            i = 0
            last_bloc = len(blocs_benes)
            for i in range(0, last_bloc):
                bene = blocs_benes[i].text;
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = blocs_prestas[i].xpath('.//tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    # TO TEST : Indemnités journalières : Pas pu tester de cas de figure similaire dans la nouvelle mouture du site
                    if len(tds) == 4:
                        date_str = Regexp(pattern=r'.*<br/>(\d+/\d+/\d+)\).*').filter(tds[0].text)
                        det.id = id + "." + str(line)
                        det.label = tds[0].xpath('.//span')[0].text.strip()

                        jours = tds[1].text
                        if jours is None:
                            jours = '0'

                        montant = tds[2].text
                        if montant is None:
                            montant = '0'

                        price = tds[3].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = '%s (%sj) * %s€' % (date_str, re.sub(r'[^\d,-]+', '', jours), re.sub(r'[^\d,-]+', '', montant))
                            det.datetime = datetime.strptime(date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 5:
                        date_str = Regexp(pattern=r'\w*(\d{2})/(\d{2})/(\d{4}).*', template='\\1/\\2/\\3', default="").filter("".join(tds[0].itertext()))
                        det.id = id + "." + str(line)
                        det.label = '%s - %s' % (bene, tds[0].xpath('.//span')[0].text.strip())

                        paye = tds[1].text
                        if paye is None:
                            paye = '0'

                        base = tds[2].text
                        if base is None:
                            base = '0'

                        tdtaux = tds[3].xpath('.//span')[0].text
                        if tdtaux is None:
                            taux = '0'
                        else:
                            taux = tdtaux.strip()

                        tdprice = tds[4].xpath('.//span')[0].text
                        if tdprice is None:
                            price = '0'
                        else:
                            price = tdprice.strip()

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u' Payé %s€ / Base %s€ / Taux %s%%' % (re.sub(r'[^\d,-]+', '', paye), re.sub(r'[^\d,-]+', '', base), re.sub('[^\d,-]+', '', taux))
                            det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det
Ejemplo n.º 20
0
    def iter_payment_details(self, sub):
        if CleanText('//div[@class="infoPrestationsAssure"]/span')(self.doc).startswith('Pour %s' % sub.subscriber):
            id_str = self.doc.xpath('//div[@class="centrepage"]/h2')[0].text.strip()
            m = re.match('.*le (.*) pour un montant de.*', id_str)
            if m:
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = self.doc.xpath('//div[@class="infoPrestationsAssure"]//table')[0].xpath('.//tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    if len(tds) == 5:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        jours = tds[2].text
                        if jours is None:
                            jours = '0'

                        montant = tds[3].text
                        if montant is None:
                            montant = '0'

                        price = tds[4].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = date_str + u' (' + unicode(re.sub('[^\d,-]+', '', jours)) + u'j) * ' + unicode(re.sub('[^\d,-]+', '', montant)) + u'€'
                            det.datetime = datetime.strptime(date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 6:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        paye = tds[2].text
                        if paye is None:
                            paye = '0'

                        base = tds[3].text
                        if base is None:
                            base = '0'

                        taux = tds[4].text
                        if taux is None:
                            taux = '0'

                        price = tds[5].text
                        if price is None:
                            price = '0'


                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', paye)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', base)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', taux)) + '%'
                            det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det
Ejemplo n.º 21
0
    def iter_payment_details(self, sub):
        id_str = self.doc.xpath(
            '//div[@class="entete container"]/h2')[0].text.strip()
        m = re.match('.*le (.*) pour un montant de.*', id_str)
        if m:
            blocs_benes = self.doc.xpath(
                '//span[contains(@id,"nomBeneficiaire")]')
            blocs_prestas = self.doc.xpath('//table[@id="tableauPrestation"]')
            i = 0
            last_bloc = len(blocs_benes)
            for i in range(0, last_bloc):
                bene = blocs_benes[i].text
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = blocs_prestas[i].xpath('.//tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    # TO TEST : Indemnités journalières : Pas pu tester de cas de figure similaire dans la nouvelle mouture du site
                    if len(tds) == 4:
                        date_str = Regexp(r'.*<br/>(\d+/\d+/\d+)\).*',
                                          '\\1')(tds[0].text)
                        det.id = id + "." + str(line)
                        det.label = unicode(
                            tds[0].xpath('.//span')[0].text.strip())

                        jours = tds[1].text
                        if jours is None:
                            jours = '0'

                        montant = tds[2].text
                        if montant is None:
                            montant = '0'

                        price = tds[3].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = date_str + u' (' + unicode(
                                re.sub('[^\d,-]+', '',
                                       jours)) + u'j) * ' + unicode(
                                           re.sub('[^\d,-]+', '',
                                                  montant)) + u'€'
                            det.datetime = datetime.strptime(
                                date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 5:
                        date_str = Regexp(
                            pattern=r'\w*(\d{2})/(\d{2})/(\d{4}).*',
                            template='\\1/\\2/\\3',
                            default="").filter("".join(tds[0].itertext()))
                        det.id = id + "." + str(line)
                        det.label = bene + u' - ' + unicode(
                            tds[0].xpath('.//span')[0].text.strip())

                        paye = tds[1].text
                        if paye is None:
                            paye = '0'

                        base = tds[2].text
                        if base is None:
                            base = '0'

                        tdtaux = tds[3].xpath('.//span')[0].text
                        if tdtaux is None:
                            taux = '0'
                        else:
                            taux = tdtaux.strip()

                        tdprice = tds[4].xpath('.//span')[0].text
                        if tdprice is None:
                            price = '0'
                        else:
                            price = tdprice.strip()

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u' Payé ' + unicode(
                                re.sub('[^\d,-]+', '',
                                       paye)) + u'€ / Base ' + unicode(
                                           re.sub('[^\d,-]+', '', base)
                                       ) + u'€ / Taux ' + unicode(
                                           re.sub('[^\d,-]+', '', taux)) + '%'
                            det.datetime = datetime.strptime(
                                date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det
Ejemplo n.º 22
0
    def iter_payment_details(self, sub):
        if CleanText('//div[@class="infoPrestationsAssure"]/span')(
                self.doc).startswith('Pour %s' % sub.subscriber):
            id_str = self.doc.xpath(
                '//div[@class="centrepage"]/h2')[0].text.strip()
            m = re.match('.*le (.*) pour un montant de.*', id_str)
            if m:
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = self.doc.xpath(
                    '//div[@class="infoPrestationsAssure"]//table')[0].xpath(
                        './/tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    if len(tds) == 5:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        jours = tds[2].text
                        if jours is None:
                            jours = '0'

                        montant = tds[3].text
                        if montant is None:
                            montant = '0'

                        price = tds[4].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = date_str + u' (' + unicode(
                                re.sub('[^\d,-]+', '',
                                       jours)) + u'j) * ' + unicode(
                                           re.sub('[^\d,-]+', '',
                                                  montant)) + u'€'
                            det.datetime = datetime.strptime(
                                date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 6:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        paye = tds[2].text
                        if paye is None:
                            paye = '0'

                        base = tds[3].text
                        if base is None:
                            base = '0'

                        taux = tds[4].text
                        if taux is None:
                            taux = '0'

                        price = tds[5].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u'Payé ' + unicode(
                                re.sub('[^\d,-]+', '',
                                       paye)) + u'€ / Base ' + unicode(
                                           re.sub('[^\d,-]+', '', base)
                                       ) + u'€ / Taux ' + unicode(
                                           re.sub('[^\d,-]+', '', taux)) + '%'
                            det.datetime = datetime.strptime(
                                date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det