Exemple #1
0
        class item(ItemElement):
            klass = Transaction

            def obj_type(self):
                if Field('raw')(self) in self.page.browser.SUMMARY_CARD_LABEL:
                    return Transaction.TYPE_CARD_SUMMARY
                elif Field('amount')(self) > 0:
                    return Transaction.TYPE_ORDER
                else:
                    return Transaction.TYPE_DEFERRED_CARD

            obj_raw = CleanText(Dict('description', default=''))
            obj_date = Date(Dict('statement_end_date', default=None),
                            default=None)
            obj_rdate = Date(Dict('charge_date'))
            obj_vdate = Date(Dict('post_date', default=None),
                             default=NotAvailable)
            obj_amount = Eval(lambda x: -float_to_decimal(x), Dict('amount'))
            obj_original_currency = Dict(
                'foreign_details/iso_alpha_currency_code',
                default=NotAvailable)

            def obj_original_amount(self):
                # amount in the account's currency
                amount = Field("amount")(self)
                # amount in the transaction's currency
                original_amount = Dict('foreign_details/amount',
                                       default=NotAvailable)(self)
                if not original_amount:
                    return NotAvailable
                else:
                    original_amount = abs(parse_decimal(original_amount))
                if amount < 0:
                    return -original_amount
                else:
                    return original_amount

            #obj__ref = Dict('reference_id')
            obj__ref = Dict('identifier')
Exemple #2
0
    def get_account(self):
        json = self._auth()
        account = Account(id=Dict('id')(json))
        account.number = account.id
        # weboob.capabilities.bank.BaseAccount
        account.bank_name = 'Lunchr'

        account.type = Account.TYPE_CHECKING

        # Check if account have a card
        balance = Dict('meal_voucher_info/balance/value', default=None)(json)
        if empty(balance):
            return

        account.balance = CleanDecimal.SI(balance)(json)
        account.label = Format('%s %s', CleanText(Dict('first_name')), CleanText(Dict('last_name')))(json)
        account.currency = Currency(Dict('meal_voucher_info/balance/currency/iso_3'))(json)
        account.cardlimit = CleanDecimal.SI(Dict('meal_voucher_info/daily_balance/value'))(json)
        yield account
Exemple #3
0
        class item(ItemElement):
            klass = Document

            obj_id = Format("%s_%s", Env("subscription"),
                            Dict("referenceDocumentaire"))
            obj_format = "pdf"
            obj_date = Date(Dict("dtFin"))
            obj_label = Format(
                "Bulletin de salaire %s %s %s",
                Dict("salarieDTO/prenom"),
                Dict("salarieDTO/nom"),
                Dict("periode"),
            )
            obj_type = DocumentTypes.OTHER
            obj_url = BrowserURL(
                "payslip_download",
                employer=Env("employer"),
                ref_doc=Dict("referenceDocumentaire"),
            )
Exemple #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

            def obj_type(self):
                return self.page.TYPES.get(Dict('accountType', default=None)(self).lower(), Account.TYPE_UNKNOWN)
Exemple #5
0
        class item(ItemElement):
            klass = Account

            def condition(self):
                return CleanText(Dict('status'))(self) == 'active'

            obj_type = Account.TYPE_CARD
            obj_label = obj_id = obj_number = CleanText(Dict('card_ref'))
            # The amount has no `.` or `,` in it. In order to get the amount we have
            # to divide the amount we retrieve by 100 (like the website does).
            obj_balance = Eval(
                lambda x: x / 100,
                CleanDecimal(Dict('balances/0/remaining_amount')))
            obj_currency = Currency(Dict('balances/0/currency'))
            obj_cardlimit = Eval(
                lambda x: x / 100,
                CleanDecimal(Dict('balances/0/daily_remaining_amount')))
            obj__card_class = CleanText(Dict('class'))
            obj__account_ref = CleanText(Dict('account_ref'))
Exemple #6
0
        class item(ItemElement):
            klass = Place

            obj_id = Dict('idequipement')
            obj_name = Dict('name')
            obj_address = Dict('details/address')
            obj_postcode = Dict('details/zip_code')
            obj_city = Dict('details/city')
            obj_country = 'FR'
            obj_phone = Regexp(CleanText(Dict('details/phone'), replace=[(' ', '')]), r'^0(.*)$', r'+33\1', default=None)

            def obj_opening(self):
                if self.el['calendars'] == []:
                    # yes, sometimes it's a list
                    return NotAvailable

                if self.el['calendars'].get('everyday'):
                    rule = OpeningRule()
                    rule.dates = rrule.rrule(rrule.DAILY)
                    rule.times = [(time(0, 0), time(23, 59, 59))]
                    rule.is_open = True

                    res = OpeningHours()
                    res.rules = [rule]
                    return res

                rules = []
                for day, hours in self.el['calendars'].items():
                    rule = OpeningRule()
                    rule.is_open = True

                    day = parsedate(day)
                    rule.dates = rrule.rrule(rrule.DAILY, count=1, dtstart=day)
                    rule.times = [(parsetime(t[0]), parsetime(t[1])) for t in hours if t[0] != 'closed']
                    rule.is_open = True

                    if rule.times:
                        rules.append(rule)

                res = OpeningHours()
                res.rules = rules
                return res
Exemple #7
0
        class item(ItemElement):
            klass = Account

            obj__has_cards = Dict('encoursCB')

            def obj_id(self):
                return CleanText(Dict('numeroCompte'))(self)[2:]

            obj_balance = Eval(
                lambda x, y: x / 10**y,
                CleanDecimal(Dict('soldeComptable')),
                CleanDecimal(Dict('decSoldeComptable'))
            )
            obj_label = CleanText(Dict('libelleCompte'))
            obj_currency = CleanText(Dict('deviseTenue'))
            obj_iban = CleanText(Dict('numeroCompte', default=None), default=NotAvailable)

            def obj_type(self):
                return self.page.TYPES.get(Dict('libelleType')(self), Account.TYPE_UNKNOWN)

            def obj_coming(self):
                page = self.page.browser.open(
                    BrowserURL('account_coming', identifiant=Field('iban'))(self)
                ).page
                coming = Eval(
                    lambda x, y: x / 10**y,
                    CleanDecimal(Dict('infoOperationsAvenir/cumulTotal/montant', default='0')),
                    CleanDecimal(Dict('infoOperationsAvenir/cumulTotal/nb_dec', default='0'))
                )(page.doc)

                # this so that card coming transactions aren't accounted twice in the total incoming amount
                for el in Dict('infoOperationsAvenir/natures')(page.doc):
                    if Dict('nature/libelle')(el) == "Factures / Retraits cartes":
                        coming_carte = Eval(
                            lambda x, y: x / 10**y,
                            CleanDecimal(Dict('cumulNatureMere/montant', default='0')),
                            CleanDecimal(Dict('cumulNatureMere/nb_dec', default='0'))
                        )(el)
                        coming -= coming_carte
                        break

                return coming
Exemple #8
0
    def _parse_transaction(self, payment):
        transaction = Transaction()
        transaction_id = Dict('transaction_number', default=None)(payment)
        # Check if transaction_id is None which indicates failed transaction
        if transaction_id is None:
            return
        transaction.id = transaction_id
        transaction.date = DateTime(Dict('executed_at'))(payment)
        transaction.rdate = DateTime(Dict('created_at'))(payment)

        types = {
            'ORDER': Transaction.TYPE_CARD,  # order on lunchr website
            'LUNCHR_CARD_PAYMENT': Transaction.TYPE_CARD,  # pay in shop
            'MEAL_VOUCHER_CREDIT': Transaction.TYPE_DEPOSIT,
            # type can be null for refunds
        }
        transaction.type = types.get(Dict('type')(payment), Transaction.TYPE_UNKNOWN)
        transaction.label = Dict('name')(payment)
        transaction.amount = CleanDecimal(Dict('amount/value'))(payment)
        return transaction
Exemple #9
0
        class item(ItemElement):
            klass = Investment

            obj_label = Dict('SecurityName')
            obj_quantity = MyDecimal(Dict('Quantity'))
            obj_vdate = Env('vdate')
            obj_unitvalue = Env('unitvalue', default=NotAvailable)
            obj_unitprice = Env('unitprice', default=NotAvailable)
            obj_valuation = MyDecimal(Dict('ValueInEuro'))
            obj_diff = MyDecimal(Dict('ResultValueInEuro'))
            obj_diff_percent = Eval(lambda x: x / 100, MyDecimal(Dict('ResultPercentageInEuro')))
            obj_original_currency = Env('o_currency', default=NotAvailable)
            obj_original_unitvalue = Env('o_unitvalue', default=NotAvailable)
            obj_original_unitprice = Env('o_unitprice', default=NotAvailable)
            obj_original_valuation = Env('o_valuation', default=NotAvailable)
            obj_original_diff = Env('o_diff', default=NotAvailable)
            obj__security_id = Dict('SecurityId')

            def obj_code(self):
                if is_isin_valid(Dict('IsinCode')(self)):
                    return Dict('IsinCode')(self)
                elif "espèces" in Field('label')(self).lower():
                    return "XX-liquidity"
                return NotAvailable

            def obj_code_type(self):
                if is_isin_valid(Field('code')(self)):
                    return Investment.CODE_TYPE_ISIN
                return NotAvailable

            def parse(self, el):
                if self.env['currency'] != CleanText(Dict('CurrencyCode'))(self):
                    self.env['o_currency'] = CleanText(Dict('CurrencyCode'))(self)
                    self.env['o_unitvalue'] = MyDecimal(Dict('Quote'))(self)
                    self.env['o_unitprice'] = MyDecimal(Dict('HistoricQuote'))(self)
                    self.env['o_valuation'] = MyDecimal(Dict('ValueInSecurityCurrency'))(self)
                    self.env['o_diff'] = MyDecimal(Dict('ResultValueInSecurityCurrency'))(self)
                else:
                    self.env['unitvalue'] = MyDecimal(Dict('Quote'))(self)
                    self.env['unitprice'] = MyDecimal(Dict('HistoricQuote'))(self)
                self.env['vdate'] = Date(dayfirst=True).filter(Dict('PortfolioSummary/UpdatedAt')(self.page.doc))
Exemple #10
0
    class get_current(ItemElement):
        klass = Current

        def parse(self, el):
            self.env['pct'] = u'%'

        obj_id = Date(Dict('query/results/channel/item/condition/date'))
        obj_date = Date(Dict('query/results/channel/item/condition/date'))
        obj_text = Format('%s - wind: %s%s - humidity:%s%s',
                          Dict('query/results/channel/item/condition/text'),
                          Dict('query/results/channel/wind/speed'),
                          Dict('query/results/channel/units/speed'),
                          Dict('query/results/channel/atmosphere/humidity'),
                          Env('pct'))

        def obj_temp(self):
            temp = CleanDecimal(
                Dict('query/results/channel/item/condition/temp'))(self)
            unit = CleanText(
                Dict('query/results/channel/units/temperature'))(self)
            return Temperature(float(temp), unit)
Exemple #11
0
            def obj_coming(self):
                page = self.page.browser.open(
                    BrowserURL('account_coming', identifiant=Field('iban'))(self)
                ).page
                coming = Eval(
                    lambda x, y: x / 10**y,
                    CleanDecimal(Dict('infoOperationsAvenir/cumulTotal/montant', default='0')),
                    CleanDecimal(Dict('infoOperationsAvenir/cumulTotal/nb_dec', default='0'))
                )(page.doc)

                # this so that card coming transactions aren't accounted twice in the total incoming amount
                for el in Dict('infoOperationsAvenir/natures')(page.doc):
                    if Dict('nature/libelle')(el) == "Factures / Retraits cartes":
                        coming_carte = Eval(
                            lambda x, y: x / 10**y,
                            CleanDecimal(Dict('cumulNatureMere/montant', default='0')),
                            CleanDecimal(Dict('cumulNatureMere/nb_dec', default='0'))
                        )(el)
                        coming -= coming_carte
                        break

                return coming
Exemple #12
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)

            def obj_ownership(self):
                if Dict('accountListType')(self) == 'COMPTE_MANDATAIRE':
                    return AccountOwnership.ATTORNEY
                elif Dict('nomCotitulaire', default=None)(self):
                    return AccountOwnership.CO_OWNER
                return AccountOwnership.OWNER
Exemple #13
0
        class item(ItemElement):
            klass = Recipe

            obj_id = Dict('recipeID')
            obj_title = Dict('title')
            obj_short_description = Dict('description')
Exemple #14
0
        class item(ItemElement):
            klass = City

            obj_id = Dict('id')
            obj_name = Dict('name')
Exemple #15
0
 def next_page(self):
     return Dict('links/next/href', default=None)(self.page.doc)
Exemple #16
0
 def get_phone(self):
     if Dict('utils/status')(self.doc) == u'OK':
         return Dict('utils/phonenumber')(self.doc)
     return NotAvailable
Exemple #17
0
 def condition(self):
     return Dict('type')(self) == "VILLE_FRANCE"
Exemple #18
0
 def obj_nb_person(self):
     return [Dict('recipeYield')(self)]
Exemple #19
0
 def obj_nb_person(self):
     nb_pers = u'%s' % Dict('servings', default='')(self)
     return [nb_pers] if nb_pers else NotAvailable
Exemple #20
0
 def condition(self):
     return Dict('lct_parent_id')(self) != '0'
Exemple #21
0
 def is_logged(self):
     return "200" in Dict('errorCode')(self.doc)
Exemple #22
0
        class obj_picture(ItemElement):
            klass = BaseImage

            obj_url = Dict('photo/photoDetailUrl')
            obj_thumbnail = Eval(Thumbnail, obj_url)
Exemple #23
0
 def obj_instructions(self):
     ins = [Dict('displayValue')(el) for el in Dict('directions')(self)]
     return Join('\n * ', ins, addBefore=' * ', addAfter='\n')(self)
Exemple #24
0
        class item(ItemElement):
            klass = Advisor

            obj_name = Format('%s %s %s', Dict('data/civilite'),
                              Dict('data/prenom'), Dict('data/nom'))
            obj_email = Regexp(Dict('data/mail'), '(?=\w)(.*)')
            obj_phone = CleanText(Dict('data/telephone'), replace=[(' ', '')])
            obj_mobile = CleanText(Dict('data/mobile'), replace=[(' ', '')])
            obj_fax = CleanText(Dict('data/fax'), replace=[(' ', '')])
            obj_agency = Dict('data/agence')
            obj_address = Format('%s %s %s', Dict('data/adresseAgence'),
                                 Dict('data/codePostalAgence'),
                                 Dict('data/villeAgence'))
Exemple #25
0
 def parse(self, el):
     self.env['price'] = Decimal(Dict('billAmount')(self))
     self.env['numAcc'] = str(int(Env('subid')(self)))
Exemple #26
0
 def condition(self):
     return (Dict('value', default=None)(self)
             and Dict('name', default=None)(self) == "ci")
Exemple #27
0
 def get_token(self):
     return Dict('data')(self.doc)
Exemple #28
0
 def condition(self):
     return Dict('id', default=None)(self) and\
         Dict('localisationType')(self) == u'ville'
Exemple #29
0
 def check_error(self):
     return (not Dict('errors')(self.doc)) is False
Exemple #30
0
 def obj_instructions(self):
     str = Dict('recipeInstructions')(self)
     return re.sub(r'(\d+\.)', r'\n\1', str)