Beispiel #1
0
 def create_transfer(self, account, recipient, transfer):
     transfer = Transfer()
     transfer.currency = FrenchTransaction.Currency(
         './/tr[td[contains(text(), "Montant")]]/td[not(@class)] | \
                                                     .//tr[th[contains(text(), "Montant")]]/td[not(@class)]'
     )(self.doc)
     transfer.amount = CleanDecimal(
         './/tr[td[contains(text(), "Montant")]]/td[not(@class)] | \
                                     .//tr[th[contains(text(), "Montant")]]/td[not(@class)]',
         replace_dots=True)(self.doc)
     transfer.account_iban = account.iban
     transfer.recipient_iban = Upper(Regexp(CleanText(u'.//tr[th[contains(text(), "Compte à créditer")]]/td[not(@class)]'), '(\w+)$'))(self.doc) \
                               if recipient.category == u'Externe' else recipient.iban
     transfer.account_id = unicode(account.id)
     transfer.recipient_id = unicode(recipient.id)
     transfer.exec_date = Date(CleanText(
         './/tr[th[contains(text(), "En date du")]]/td[not(@class)]'),
                               dayfirst=True)(self.doc)
     transfer.label = CleanText(
         u'.//tr[td[contains(text(), "Motif de l\'opération")]]/td[not(@class)] | \
                                  .//tr[td[contains(text(), "Libellé")]]/td[not(@class)]'
     )(self.doc)
     transfer.account_label = account.label
     transfer.recipient_label = recipient.label
     transfer._account = account
     transfer._recipient = recipient
     transfer.account_balance = account.balance
     return transfer
Beispiel #2
0
        class item(ItemElement):
            klass = Investment

            condition = lambda self: not CleanText(
                '//div[has-class("errorConteneur")]', default=None)(self.el)

            obj_label = Upper(TableCell('label'))
            obj_quantity = MyDecimal(TableCell('quantity'))
            obj_unitprice = MyDecimal(TableCell('unitprice'))
            obj_unitvalue = MyDecimal(TableCell('unitvalue'))
            obj_valuation = CleanDecimal(TableCell('valuation'),
                                         replace_dots=True)
            obj_vdate = Date(CleanText(TableCell('vdate')),
                             dayfirst=True,
                             default=NotAvailable)

            def obj_code(self):
                if Field('label')(self) == "LIQUIDITES":
                    return 'XX-liquidity'
                code = CleanText(TableCell('code'))(self)
                return code if is_isin_valid(code) else NotAvailable

            def obj_code_type(self):
                return Investment.CODE_TYPE_ISIN if is_isin_valid(
                    Field('code')(self)) else NotAvailable
Beispiel #3
0
        class item(ItemElement):
            klass = Account

            obj_label = Upper(Dict('libelleContrat'))
            obj_balance = CleanDecimal(Dict('solde', default="0"))
            obj_currency = u'EUR'
            obj_coming = CleanDecimal(Dict('AVenir', default=None),
                                      default=NotAvailable)
            obj__index = Dict('index')

            def obj_id(self):
                if Field('type')(self) == Account.TYPE_LIFE_INSURANCE:
                    return self.get_lifenumber()

                try:
                    return Env('numbers')(self)[Dict('index')(self)]
                except KeyError:
                    # index often changes, so we can't use it... and have to do something ugly
                    return Slugify(
                        Format('%s-%s', Dict('libelleContrat'),
                               Dict('nomTitulaire')))(self)

            def obj_type(self):
                for key in self.page.TYPES:
                    if key in Dict('libelleContrat')(self).lower():
                        return self.page.TYPES[key]
                return Account.TYPE_UNKNOWN

            def get_lifenumber(self):
                index = Dict('index')(self)
                url = json.loads(
                    self.page.browser.lifeinsurance.open(
                        accid=index).content)['url']
                page = self.page.browser.open(url).page
                return page.get_account_id()
Beispiel #4
0
        class item(ItemElement):
            klass = Account

            condition = lambda self: "LIVRET" not in Dict('accountType')(self.
                                                                         el)

            obj_id = Dict('numeroContratSouscrit')
            obj_label = Upper(Dict('lib'))
            obj_currency = Dict('deviseCompteCode')
            obj_coming = CleanDecimal(Dict('AVenir', default=None),
                                      default=NotAvailable)
            # Iban is available without last 5 numbers, or by sms
            obj_iban = NotAvailable
            obj__index = Dict('index')

            def obj_balance(self):
                balance = CleanDecimal(Dict('soldeEuro', default="0"))(self)
                return -abs(balance) if Field('type')(
                    self) == Account.TYPE_LOAN else balance

            # It can have revolving credit on this page
            def obj__total_amount(self):
                return CleanDecimal(Dict('grantedAmount', default=None),
                                    default=NotAvailable)(self)

            def obj_type(self):
                return self.page.TYPES.get(
                    Dict('accountType', default=None)(self).lower(),
                    Account.TYPE_UNKNOWN)
Beispiel #5
0
    def iter_pocket(self, inv):
        if inv._el_pocket:
            for i, row in enumerate(inv._el_pocket.xpath('.//tr[position()>1]')):
                pocket = Pocket()
                pocket.id = "%s%s%s" % (inv._account.label, inv.label, i)
                pocket.label = inv.label
                pocket.investment = inv
                pocket.amount = MyDecimal('./td[2]')(row)

                if 'DISPONIBLE' in Upper(CleanText('./td[1]'))(row):
                    pocket.condition = Pocket.CONDITION_AVAILABLE
                else:
                    pocket.condition = Pocket.CONDITION_DATE
                    pocket.availability_date = Date(Regexp(Upper(CleanText('./td[1]')), 'AU[\s]+(.*)'), dayfirst=True)(row)

                yield pocket
Beispiel #6
0
        class item(ItemElement):
            klass = Transaction

            obj_amount = CleanDecimal(Dict('amount'))
            obj_date = Date(Dict('effectiveDate'))
            obj_vdate = Date(Dict('operationDate'))
            obj_type = Map(Upper(Dict('type')), Transaction.TYPES, Transaction.TYPE_UNKNOWN)

            def obj_raw(self):
                return Transaction.Raw(Lower(Dict('label')))(self) or Format('%s %s', Field('date'), Field('amount'))(self)
Beispiel #7
0
        class item(ItemElement):
            klass = Account

            obj_id = Regexp(Upper(Field('label')),
                            '[\s]+([^\s]+)[\s]+([^\s]+).*:[\s]+([^\s]+)',
                            '\\1\\2\\3')
            obj_type = Account.TYPE_PEE
            obj_label = CleanText('//table[@class="fiche"]//td')
            obj_balance = MyDecimal(
                '//th[contains(text(), "Montant total")]/em')
Beispiel #8
0
        class item(ItemElement):
            klass = Transaction

            # Not sure that Dict('id') is unique and persist
            # wait for the full API migration
            obj__web_id = Eval(str, Dict('id'))
            obj_amount = CleanDecimal(Dict('amount'))
            obj_date = Date(Dict('effectiveDate'))
            obj_type = Map(Upper(Dict('type')), Transaction.TYPES, Transaction.TYPE_UNKNOWN)

            def obj_raw(self):
                return Transaction.Raw(Lower(Dict('detail')))(self) or Format('%s %s', Field('date'), Field('amount'))(self)
Beispiel #9
0
        class item(ItemElement):
            klass = Investment

            condition = lambda self: not CleanText('//div[has-class("errorConteneur")]', default=None)(self.el)

            obj_label = Upper(TableCell('label'))
            obj_code = CleanText(TableCell('code'))
            obj_quantity = CleanDecimal(TableCell('quantity'), default=NotAvailable)
            obj_unitprice = MyDecimal(TableCell('unitprice'))
            obj_unitvalue = MyDecimal(TableCell('unitvalue'))
            obj_valuation = CleanDecimal(TableCell('valuation'))
            obj_vdate = Date(CleanText(TableCell('vdate')), dayfirst=True, default=NotAvailable)
Beispiel #10
0
            class item(ItemElement):
                klass = Account

                obj_label = Upper(Dict('libelleContrat'))
                obj_balance = CleanDecimal(Dict('solde', default="0"))
                obj_currency = 'EUR'
                obj_coming = CleanDecimal(Dict('AVenir', default=None),
                                          default=NotAvailable)
                obj__index = Dict('index')
                obj__owner = Dict('nomTitulaire')

                def obj_id(self):
                    type = Field('type')(self)
                    if type == Account.TYPE_LIFE_INSURANCE:
                        number = self.get_lifenumber()
                        if number:
                            return number
                    elif type in (Account.TYPE_PEA, Account.TYPE_MARKET):
                        number = self.get_market_number()
                        if number:
                            return number

                    try:
                        return Env('numbers')(self)[Dict('index')(self)]
                    except KeyError:
                        # index often changes, so we can't use it... and have to do something ugly
                        return Slugify(
                            Format('%s-%s', Dict('libelleContrat'),
                                   Dict('nomTitulaire')))(self)

                def obj_type(self):
                    for key in self.page.TYPES:
                        if key in Env('type_label')(self).lower():
                            return self.page.TYPES[key]
                    return Account.TYPE_UNKNOWN

                def get_market_number(self):
                    label = Field('label')(self)
                    page = self.page.browser._go_market_history()
                    return page.get_account_id(label, Field('_owner')(self))

                def get_lifenumber(self):
                    index = Dict('index')(self)
                    data = json.loads(
                        self.page.browser.lifeinsurance.open(
                            accid=index).content)
                    if not data:
                        raise SkipItem('account seems unavailable')
                    url = data['url']
                    page = self.page.browser.open(url).page
                    return page.get_account_id()
Beispiel #11
0
        class item(ItemElement):
            klass = Account

            obj_id = Regexp(Upper(Field('raw')),
                            '[\s]+([^\s]+)[\s]+([^\s]+).*:[\s]+([^\s]+)',
                            '\\1\\2\\3')
            obj_type = Account.TYPE_PEE
            obj_raw = CleanText('//table[@class="fiche"]//td')
            obj_label = Regexp(Field('raw'), '[^:]\s*(.+)\s+Montant', '\\1')
            obj_balance = MyDecimal('//th[contains(., "Montant total")]//em')

            def obj_currency(self):
                currency = CleanText(
                    '//th[contains(text(), "Montant total")]/small')(self)
                if currency:
                    return Currency().filter(currency)
                return Currency().filter(
                    CleanText('//table[@class="fiche"]//td/small')(self))
Beispiel #12
0
 def create_transfer(self, account, recipient, transfer):
     transfer = Transfer()
     transfer.currency = FrenchTransaction.Currency(
         './/tr[td[contains(text(), "Montant")]]/td[not(@class)] | \
                                                     .//tr[th[contains(text(), "Montant")]]/td[not(@class)]'
     )(self.doc)
     transfer.amount = CleanDecimal(
         './/tr[td[contains(text(), "Montant")]]/td[not(@class)] | \
                                     .//tr[th[contains(text(), "Montant")]]/td[not(@class)]',
         replace_dots=True)(self.doc)
     transfer.account_iban = account.iban
     if recipient.category == u'Externe':
         for word in Upper(
                 CleanText(
                     u'.//tr[th[contains(text(), "Compte à créditer")]]/td[not(@class)]'
                 ))(self.doc).split():
             if is_iban_valid(word):
                 transfer.recipient_iban = word
                 break
         else:
             raise TransferError('Unable to find IBAN (original was %s)' %
                                 recipient.iban)
     else:
         transfer.recipient_iban = recipient.iban
     transfer.account_id = unicode(account.id)
     transfer.recipient_id = unicode(recipient.id)
     transfer.exec_date = Date(CleanText(
         './/tr[th[contains(text(), "En date du")]]/td[not(@class)]'),
                               dayfirst=True)(self.doc)
     transfer.label = CleanText(
         u'.//tr[td[contains(text(), "Motif de l\'opération")]]/td[not(@class)] | \
                                  .//tr[td[contains(text(), "Libellé")]]/td[not(@class)]'
     )(self.doc)
     transfer.account_label = account.label
     transfer.recipient_label = recipient.label
     transfer._account = account
     transfer._recipient = recipient
     transfer.account_balance = account.balance
     return transfer
Beispiel #13
0
 def obj_type(self):
     return MapIn(Upper(Field('label')), self.page.TYPES, Account.TYPE_UNKNOWN)(self)