class fill_balances(ItemElement): # coming is what should be refunded at a future deadline obj_coming = CleanDecimal.US(Dict('0/total_debits_balance_amount'), sign=lambda x: -1) # balance is what is currently due obj_balance = CleanDecimal.US( Dict('0/remaining_statement_balance_amount'), sign=lambda x: -1)
class fill_investment(ItemElement): obj_unitprice = CleanDecimal.US( '//span[contains(@data-module-target, "BuyValue")]') obj_description = CleanText( '//td[contains(text(), "Nature")]/following-sibling::td') obj_diff_ratio = Eval( lambda x: x / 100 if x else NotAvailable, CleanDecimal.US( '//span[contains(@data-module-target, "trhrthrth")]', default=NotAvailable))
def get_revolving_attributes(self, account): loan = Loan() loan.id = account.id loan.label = '%s - %s' %(account.label, account.id) loan.currency = account.currency loan.url = account.url loan.used_amount = CleanDecimal.US('//tr[td[contains(text(), "Montant Utilisé") or contains(text(), "Montant utilisé")]]/td[2]')(self.doc) loan.available_amount = CleanDecimal.US(Regexp(CleanText('//tr[td[contains(text(), "Montant Disponible") or contains(text(), "Montant disponible")]]/td[2]'), r'(.*) au'))(self.doc) loan.balance = -loan.used_amount loan._has_cards = False loan.type = Account.TYPE_REVOLVING_CREDIT return loan
def obj_balance(self): # The page can be randomly in french or english and # the valuations can be "€12,345.67" or "12 345,67 €" try: return CleanDecimal.French('./td[6]')(self) except NumberFormatError: return CleanDecimal.US('./td[6]')(self)
def obj_balance(self): # This wonderful website randomly displays separators as '.' or ',' # For example, numbers can look like "€12,345.67" or "12 345,67 €" try: return CleanDecimal.French('./td[6]')(self) except NumberFormatError: return CleanDecimal.US('./td[6]')(self)
class get_loan(ItemElement): klass = Account obj_type = Account.TYPE_LOAN obj__site = 'other' obj_label = CleanText('//div[@class="conteneur"]/h1') obj_number = obj_id = CleanText('//td[contains(text(), "Mon numéro de compte")]/following-sibling::td', replace=[(' ', '')]) obj_coming = CleanDecimal.US('//td[strong[contains(text(), "Montant de la")]]/following-sibling::td/strong')
def obj_performance_history(self): # Fetching the performance history (1 year, 3 years & 5 years) perfs = {} for item in Dict('sharePerf')(self): if item['name'] in ('1Y', '3Y', '5Y'): duration = int(item['name'][0]) value = item['value'] perfs[duration] = Eval(lambda x: x / 100, CleanDecimal.US(value))(self) return perfs
def parse(self, obj): # This wonderful website randomly displays separators as '.' or ',' # For example, numbers can look like "€12,345.67" or "12 345,67 €" if '.' in CleanText('./td[4]')(self): # American format self.env['quantity'] = CleanDecimal.US( './td[2]', default=NotAvailable)(self) self.env['unitvalue'] = CleanDecimal.US( './td[3]', default=NotAvailable)(self) self.env['valuation'] = CleanDecimal.US('./td[4]')(self) else: # French format self.env['quantity'] = CleanDecimal.French( './td[2]', default=NotAvailable)(self) self.env['unitvalue'] = CleanDecimal.French( './td[3]', default=NotAvailable)(self) self.env['valuation'] = CleanDecimal.French('./td[4]')( self)
def obj_amount(self): # This wonderful website randomly displays separators as '.' or ',' # For example, numbers can look like "€12,345.67" or "12 345,67 €" try: return CleanDecimal.French( './div[contains(@class, "accordion_header")]/div[position()=last()]' )(self) except NumberFormatError: return CleanDecimal.US( './div[contains(@class, "accordion_header")]/div[position()=last()]' )(self)
def get_loan_balance(self): return CleanDecimal.US('//*[@id="table-detail"]/tbody/tr/td[@class="capital"]', default=NotAvailable)(self.doc)
class fill_balances(ItemElement): obj_coming = CleanDecimal.US(Dict('0/total/debits_total_amount'), sign=lambda x: -1) obj_balance = CleanDecimal.US( Dict('0/total/payments_credits_total_amount'), sign=lambda x: -1)
def obj_amount(self): assert not (Dict('Débit')(self) and Dict('Credit')(self)), "cannot have both debit and credit" if Dict('Credit')(self): return CleanDecimal.US(Dict('Credit'))(self) return -CleanDecimal.US(Dict('Débit'))(self)