コード例 #1
0
ファイル: pages.py プロジェクト: P4ncake/weboob
    def iter_investment(self):
        item = self.doc.xpath(u'//table[@summary="Liste des échéances"]/tfoot/tr/td[@class="tot _c1 d _c1"]')[0]
        total = CleanDecimal(Regexp(CleanText('.'), '(.*) .*'),
                             default=1, replace_dots=True)(item)

        item_xpath = u'((//table[@summary="Liste des échéances"])[1]/tbody/tr)[position() < last() and not(contains(./td[1]/@class, "tittot"))]'

        obj = None
        for tr in self.doc.xpath(item_xpath):
            tds = tr.xpath('./td')
            if len(tds) > 3:
                if obj is not None:
                    obj.portfolio_share = (obj.valuation / total).quantize(Decimal('.0001'))
                    yield obj

                obj = Investment()
                obj.label = CleanText('.')(tds[0])
                obj.vdate = date.today()  # * En réalité derniere date de valorisation connue
                obj.unitvalue = CleanDecimal('.', replace_dots=True)(tds[2])
                obj.valuation = CleanDecimal('.', replace_dots=True)(tds[5])
                obj.quantity = CleanDecimal('.', replace_dots=True)(tds[4])

            elif obj is not None:
                obj.quantity += CleanDecimal('.', replace_dots=True)(tds[1])
                obj.valuation += CleanDecimal('.', replace_dots=True)(tds[2])

        if obj is not None:
            obj.portfolio_share = (obj.valuation / total).quantize(Decimal('.0001'))
            yield obj
コード例 #2
0
ファイル: pages.py プロジェクト: antibios/weboob
    def iter_investment(self):
        item = self.doc.xpath(
            u'//table[@summary="Liste des échéances"]/tfoot/tr/td[@class="tot _c1 d _c1"]'
        )[0]
        total = CleanDecimal(Regexp(CleanText('.'), '(.*) .*'),
                             default=1,
                             replace_dots=True)(item)

        item_xpath = u'((//table[@summary="Liste des échéances"])[1]/tbody/tr)[position() < last() and not(contains(./td[1]/@class, "tittot"))]'

        obj = None
        for tr in self.doc.xpath(item_xpath):
            tds = tr.xpath('./td')
            if len(tds) > 3:
                if obj is not None:
                    obj.portfolio_share = (obj.valuation / total).quantize(
                        Decimal('.0001'))
                    yield obj

                obj = Investment()
                obj.label = CleanText('.')(tds[0])
                obj.vdate = date.today(
                )  # * En réalité derniere date de valorisation connue
                obj.unitvalue = CleanDecimal('.', replace_dots=True)(tds[2])
                obj.valuation = CleanDecimal('.', replace_dots=True)(tds[5])
                obj.quantity = CleanDecimal('.', replace_dots=True)(tds[4])

            elif obj is not None:
                obj.quantity += CleanDecimal('.', replace_dots=True)(tds[1])
                obj.valuation += CleanDecimal('.', replace_dots=True)(tds[2])

        if obj is not None:
            obj.portfolio_share = (obj.valuation / total).quantize(
                Decimal('.0001'))
            yield obj
コード例 #3
0
    def iter_investment(self):
        cleaner = CleanText().filter

        for line in self.doc.xpath(
                '//div[@class="supportTable"]//table/tbody/tr'):
            tds = line.findall('td')
            if len(tds) < 4:
                continue
            inv = Investment()

            if self.doc.xpath(
                    '//div[@id="table-evolution-contrat"]//table/tbody/tr[1]/td[1]'
            ):
                inv.vdate = Date(dayfirst=True).filter(CleanText().filter(
                    self.doc.xpath(
                        '//div[@id="table-evolution-contrat"]//table/tbody/tr[1]/td[1]'
                    )))
            else:
                inv.vdate = NotAvailable
            inv.label = cleaner(tds[self.COL_LABEL])
            inv.code = cleaner(tds[self.COL_CODE])
            inv.valuation = Decimal(
                FrenchTransaction.clean_amount(cleaner(
                    tds[self.COL_VALUATION])))
            inv.portfolio_share = Decimal(
                FrenchTransaction.clean_amount(
                    cleaner(tds[self.COL_PORTFOLIO_SHARE]))) / 100
            yield inv
コード例 #4
0
ファイル: pages.py プロジェクト: guix77/weboob
    def iter_investment(self, account):
        for row, elem_repartition, elem_pocket, elem_diff in self.iter_invest_rows(account=account):
            inv = Investment()
            inv._account = account
            inv._el_pocket = elem_pocket
            inv.label = CleanText('.//td[1]')(row)
            inv.valuation = MyDecimal('.//td[2]')(row)

            # On all Cmes children the row shows percentages and the popup shows absolute values in currency.
            # On Cmes it is mirrored, the popup contains the percentage.
            is_mirrored = '%' in row.text_content()

            if not is_mirrored:
                inv.diff = MyDecimal('.//td[3]')(row)
                if elem_diff is not None:
                    inv.diff_ratio = Eval(lambda x: x / 100,
                                          MyDecimal(Regexp(CleanText('.'), r'([+-]?[\d\s]+[\d,]+)\s*%')))(elem_diff)
            else:
                inv.diff = MyDecimal('.')(elem_diff)
                if elem_diff is not None:
                    inv.diff_ratio = Eval(lambda x: x / 100,
                                          MyDecimal(Regexp(CleanText('.//td[3]'), r'([+-]?[\d\s]+[\d,]+)\s*%')))(row)

            if account.balance != 0:
                inv.portfolio_share = inv.valuation / account.balance
            yield inv
コード例 #5
0
    def iter_investment(self, account):
        self.account.go(id=account.id)
        key = self.page.get_invest_key()

        self.invests.go()
        data = self.page.get_invest(*key)
        for item in data:
            inv = Investment()
            inv.code = item['isin']
            inv.label = item['name']
            inv.portfolio_share = item['share']
            inv.valuation = account.balance * inv.portfolio_share
            yield inv
コード例 #6
0
            def obj_investments(self):
                investments = []

                for elem in self.xpath('./following-sibling::div[1]//ul'):
                    inv = Investment()
                    inv.label = CleanText('./li[1]/p')(elem)
                    inv.portfolio_share = CleanDecimal(
                        './li[2]/p', replace_dots=True,
                        default=NotAvailable)(elem)
                    inv.quantity = CleanDecimal('./li[3]/p',
                                                replace_dots=True,
                                                default=NotAvailable)(elem)
                    inv.valuation = CleanDecimal('./li[4]/p',
                                                 replace_dots=True)(elem)
                    investments.append(inv)

                return investments
コード例 #7
0
ファイル: pages.py プロジェクト: laurentb/weboob
    def iter_investment(self):
        cleaner = CleanText().filter

        for line in self.doc.xpath('//div[@class="supportTable"]//table/tbody/tr'):
            tds = line.findall('td')
            if len(tds) < 4:
                continue
            inv = Investment()

            if self.doc.xpath('//div[@id="table-evolution-contrat"]//table/tbody/tr[1]/td[1]'):
                inv.vdate = Date(dayfirst=True).filter(CleanText().filter(
                        self.doc.xpath('//div[@id="table-evolution-contrat"]//table/tbody/tr[1]/td[1]')))
            else:
                inv.vdate = NotAvailable
            inv.label = cleaner(tds[self.COL_LABEL])
            inv.code = cleaner(tds[self.COL_CODE])
            inv.valuation = Decimal(FrenchTransaction.clean_amount(
                            cleaner(tds[self.COL_VALUATION])))
            inv.portfolio_share = Decimal(FrenchTransaction.clean_amount(
                                  cleaner(tds[self.COL_PORTFOLIO_SHARE]))) / 100
            yield inv