def get_revolving_account(self, account): loan = Loan() loan.id = loan.number = account.id loan.label = account.label loan.type = account.type loan.currency = account.currency loan.balance = account.balance loan.coming = account.coming loan._internal_id = account._internal_id loan._prestation_id = account._prestation_id loan._loan_type = account._loan_type loan._is_json_histo = account._is_json_histo if Dict('donnees/tabIdAllPrestations')(self.doc): for acc in Dict('donnees/tabPrestations')(self.doc): if CleanText(Dict('idPrestation'))(acc) == account._prestation_id: # coming if Dict('encoursFinMois', default=NotAvailable)(acc): loan.coming = eval_decimal_amount('encoursFinMois/valeur', 'encoursFinMois/posDecimale')(acc) # total amount if Dict('reserveAutorisee', default=NotAvailable)(acc): loan.total_amount = eval_decimal_amount('reserveAutorisee/valeur', 'reserveAutorisee/posDecimale')(acc) elif Dict('montantAutorise', default=NotAvailable)(acc): loan.total_amount = eval_decimal_amount('montantAutorise/valeur', 'montantAutorise/posDecimale')(acc) else: loan.total_amount = eval_decimal_amount('reserveMaximum/valeur', 'reserveMaximum/posDecimale')(acc) # available amount if Dict('montantDisponible', default=NotAvailable)(acc): loan.available_amount = eval_decimal_amount('montantDisponible/valeur', 'montantDisponible/posDecimale')(acc) else: loan.available_amount = eval_decimal_amount('reserveDispo/valeur', 'reserveDispo/posDecimale')(acc) # used amount if Dict('reserveUtilisee', default=NotAvailable)(acc): loan.used_amount = eval_decimal_amount('reserveUtilisee/valeur', 'reserveUtilisee/posDecimale')(acc) elif Dict('montantUtilise', default=NotAvailable)(acc): loan.available_amount = eval_decimal_amount('montantUtilise/valeur', 'montantUtilise/posDecimale')(acc) # next payment amount if Dict('prochaineEcheance', default=NotAvailable)(acc): loan.next_payment_amount = eval_decimal_amount('prochaineEcheance/valeur', 'prochaineEcheance/posDecimale')(acc) elif Dict('montantMensualite', default=NotAvailable)(acc): loan.next_payment_amount = eval_decimal_amount('montantMensualite/valeur', 'montantMensualite/posDecimale')(acc) loan.last_payment_amount = loan.next_payment_amount loan.duration = Dict('dureeNbMois')(acc) return loan return loan
def get_loan_attributes(self, account): loan = Loan() loan.total_amount = CleanDecimal('//div/span[contains(text(), "Capital initial")]/following-sibling::*[1]', replace_dots=True)(self.doc) owner_name = CleanText('//a[@class="lien-entete login"]/span')(self.doc) loan.name = ' '.join(owner_name.split()[1:]) loan.subscription_date = Date(Regexp(CleanText('//h4[span[contains(text(), "Date de départ du prêt")]]'), r'(\d{2}\/\d{2}\/\d{4})'), dayfirst=True)(self.doc) loan.maturity_date = Date(Regexp(CleanText('//h4[span[contains(text(), "Date de fin du prêt")]]'), r'(\d{2}\/\d{2}\/\d{4})'), dayfirst=True)(self.doc) loan.rate = Eval(lambda x: x / 100, CleanDecimal('//div/span[contains(text(), "Taux fixe")]/following-sibling::*[1]', replace_dots=True))(self.doc) loan.last_payment_amount = CleanDecimal('//div[@class="txt-detail " and not (@style)]//span[contains(text(), "Echéance du")]/following-sibling::span[1]')(self.doc) loan.last_payment_date = Date(Regexp(CleanText('//div[@class="txt-detail " and not (@style)]//span[contains(text(), "Echéance du")]'), r'(\d{2}\/\d{2}\/\d{4})'), dayfirst=True)(self.doc) loan.id = account.id loan.currency = account.currency loan.label = account.label loan.balance = account.balance loan.coming = account.coming loan.type = account.type loan._uncleaned_id = account._uncleaned_id loan._multiple_type = account._multiple_type return loan
def get_revolving_attributes(self, account): loan = Loan() loan.available_amount = CleanDecimal('//div/span[contains(text(), "Montant disponible")]/following-sibling::*[1]', replace_dots=True)(self.doc) loan.used_amount = CleanDecimal('//div/span[contains(text(), "Montant Utilisé")]/following-sibling::*[1]', replace_dots=True)(self.doc) loan.total_amount = CleanDecimal('//div/span[contains(text(), "Réserve accordée")]/following-sibling::*[1]', replace_dots=True)(self.doc) loan.last_payment_amount = CleanDecimal('//div/span[contains(text(), "Echéance Précédente")]/following-sibling::*[1]', replace_dots=True)(self.doc) loan.last_payment_date = Date(Regexp(CleanText('//div/span[contains(text(), "Echéance Précédente")]/following-sibling::*[2]'), r'(\d{2}\/\d{2}\/\d{4})'), dayfirst=True)(self.doc) owner_name = CleanText('//a[@class="lien-entete login"]/span')(self.doc) loan.name = ' '.join(owner_name.split()[1:]) loan.id = account.id loan.currency = account.currency loan.label = account.label loan.balance = account.balance loan.coming = account.coming loan.type = account.type loan._uncleaned_id = account._uncleaned_id loan._multiple_type = account._multiple_type return loan
def get_revolving_account(self, account): loan = Loan() loan.id = loan.number = account.id loan.label = account.label loan.type = account.type loan.ownership = account.ownership loan.currency = account.currency loan.balance = account.balance loan.coming = account.coming loan._internal_id = account._internal_id loan._prestation_id = account._prestation_id loan._loan_type = account._loan_type loan._is_json_histo = account._is_json_histo loan._parent_id = None if Dict('donnees/tabIdAllPrestations')(self.doc): for acc in Dict('donnees/tabPrestations')(self.doc): if CleanText(Dict('idPrestation'))(acc) == account._prestation_id: # coming if Dict('encoursFinMois', default=NotAvailable)(acc): loan.coming = eval_decimal_amount('encoursFinMois/valeur', 'encoursFinMois/posDecimale')(acc) # total amount if Dict('reserveAutorisee', default=NotAvailable)(acc): loan.total_amount = eval_decimal_amount('reserveAutorisee/valeur', 'reserveAutorisee/posDecimale')(acc) elif Dict('montantAutorise', default=NotAvailable)(acc): loan.total_amount = eval_decimal_amount('montantAutorise/valeur', 'montantAutorise/posDecimale')(acc) else: loan.total_amount = eval_decimal_amount('reserveMaximum/valeur', 'reserveMaximum/posDecimale')(acc) # available amount if Dict('montantDisponible', default=NotAvailable)(acc): loan.available_amount = eval_decimal_amount('montantDisponible/valeur', 'montantDisponible/posDecimale')(acc) else: loan.available_amount = eval_decimal_amount('reserveDispo/valeur', 'reserveDispo/posDecimale')(acc) # used amount if Dict('reserveUtilisee', default=NotAvailable)(acc): loan.used_amount = eval_decimal_amount('reserveUtilisee/valeur', 'reserveUtilisee/posDecimale')(acc) elif Dict('montantUtilise', default=NotAvailable)(acc): loan.available_amount = eval_decimal_amount('montantUtilise/valeur', 'montantUtilise/posDecimale')(acc) # next payment amount if Dict('prochaineEcheance', default=NotAvailable)(acc): loan.next_payment_amount = eval_decimal_amount('prochaineEcheance/valeur', 'prochaineEcheance/posDecimale')(acc) elif Dict('montantMensualite', default=NotAvailable)(acc): loan.next_payment_amount = eval_decimal_amount('montantMensualite/valeur', 'montantMensualite/posDecimale')(acc) loan.last_payment_amount = loan.next_payment_amount loan.duration = Dict('dureeNbMois')(acc) if Dict('dateMensualite', default=NotAvailable)(acc): loan.next_payment_date = datetime.datetime.strptime(Dict('dateMensualite')(acc), '%Y%m%d') self.set_parent_account_id(loan, acc) return loan return loan