class item(ItemElement): klass = Bill obj__id = CleanText(Dict('identiteFacture/identifiant')) obj_id = Format('%s_%s', Env('subid'), Field('_id')) obj_price = CleanDecimal.SI(Dict('montantFacture/montantTTC')) obj_vat = CleanDecimal.SI(Dict('taxesFacture/montantTVA')) obj_date = Date(Dict('caracteristiquesFacture/dateLegaleFacture')) obj_duedate = Date( Dict('caracteristiquesFacture/dateEcheanceFacture')) obj_format = 'pdf' def obj_label(self): return 'Facture du %s' % Field('date')(self).strftime( '%d/%m/%Y') def obj__message(self): # message is needed to download file message = { 'actions': [{ 'id': '864;a', 'descriptor': 'apex://CNICE_VFC160_ListeFactures/ACTION$getFacturePdfLink', 'callingDescriptor': 'markup://c:CNICE_LC232_ListeFactures2', 'params': { 'factureId': Field('_id')(self) } }] } return message
def obj_diff_ratio(self): if not Env('sign')(self): return NotAvailable # obj_diff_ratio key can have several names: if Dict('plvPourcentage', default=None)(self): return CleanDecimal.SI(Dict('plvPourcentage'))(self) / 100 elif Dict('pourcentagePlv', default=None)(self): return CleanDecimal.SI(Dict('pourcentagePlv'))(self) / 100
class item(ItemElement): klass = Transaction obj_type = Transaction.TYPE_BANK obj_raw = Dict('Projet') obj_date = Date(Dict('Date'), dayfirst=True) obj_gross_amount = CleanDecimal.SI(Dict('Capital rembourse')) obj_amount = CleanDecimal.SI(Dict('Montant brut')) obj_commission = CleanDecimal.SI(Dict('Interets')) obj__amount_left = CleanDecimal.SI(Dict('Capital restant du'))
class item(ItemElement): klass = Investment obj_label = CleanText(TableCell('label')) # text is "0000000000000100 100,00 €", wtf obj_valuation = CleanDecimal.SI( Regexp(CleanText(TableCell('valuation')), r'^000(\d+)\b') ) obj_diff_ratio = CleanDecimal.SI( Regexp(CleanText(TableCell('diff_ratio')), r'^000(\d+)\b') )
def obj_portfolio_share(self): portfolio_share_percent = CleanDecimal.SI(Dict( 'pourcentageSupport', default=None), default=None)(self) if portfolio_share_percent is None: return NotAvailable return portfolio_share_percent / 100
def obj_diff(self): diff = CleanDecimal.SI(Dict('mtPMV', default=None), default=NotAvailable)(self) # Some invests have no diff value but the website fills the json field with the valuation. if diff == Field('valuation')(self): return NotAvailable return diff
def obj_coming(self): # There might be multiple coming values (if the transactions are differed # for more than 1 month). So we take the sum of all the coming values available # in the table. return sum(map( CleanDecimal.SI().filter, self.page.doc.xpath('//tbody[@role="rowgroup"]/tr/td[contains(@class, "montant")]') ))
class item(ItemElement): klass = Transaction obj_date = Date(CleanText('//div[div[contains(text(), "Date de prélèvement")]]/following-sibling::div/div'), dayfirst=True) obj_rdate = Date(CleanText(TableCell('rdate')), dayfirst=True) obj_label = CleanText(TableCell('label')) obj_amount = CleanDecimal.SI(TableCell('amount')) obj_type = Transaction.TYPE_CARD
class item(ItemElement): klass = Investment obj_label = CleanText(TableCell('label')) obj_valuation = CleanDecimal.SI( Regexp(CleanText(TableCell('bought')), r'^000(\d+)\b') )
def parse_decimal(self, string, replace_dots): string = CleanText(None).filter(string) if string in ('-', '*'): return NotAvailable # Decimal separators can be ',' or '.' depending on the column if replace_dots: return CleanDecimal.French().filter(string) return CleanDecimal.SI().filter(string)
class item(ItemElement): klass = Transaction obj_label = CleanText(TableCell('label')) obj_amount = CleanDecimal.SI(TableCell('amount')) obj_date = Env('date') obj_rdate = Date(CleanText(TableCell('date')), dayfirst=True) obj_type = Transaction.TYPE_CARD
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
class item(ItemElement): klass = Pocket obj_condition = Env('condition') obj_availability_date = Env('availability_date') obj_amount = CleanDecimal.SI(Dict('mtBrut')) obj_quantity = CleanDecimal.SI(Dict('nbParts')) def parse(self, obj): availability_date = datetime.strptime( obj['dtEcheance'].split('T')[0], '%Y-%m-%d') if availability_date <= datetime.today(): # In the past, already available self.env['availability_date'] = availability_date self.env['condition'] = Pocket.CONDITION_AVAILABLE else: # In the future, but we have no information on condition self.env['availability_date'] = availability_date self.env['condition'] = Pocket.CONDITION_UNKNOWN
def get_transactions_amount_sum(self): return sum( map(CleanDecimal.SI().filter, self.doc.xpath('//tbody[@role="rowgroup"]/tr/td[last()]')))