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)]')(self.doc) or CleanText(u'.//tr[td[contains(text(), "Libellé")]]/td[not(@class)]')(self.doc) or CleanText(u'.//tr[th[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
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
def handle_response(self, account, recipient, amount, reason, exec_date): transfer = Transfer() transfer._account = account transfer.account_id = self.get_id_from_response('account') transfer.account_iban = account.iban transfer.account_label = account.label transfer.account_balance = account.balance assert account._transfer_id in CleanText( u'//div[div[@class="libelleChoix" and contains(text(), "Compte émetteur")]] \ //div[@class="infoCompte" and not(@title)]', replace=[(' ', '')] )(self.doc) transfer._recipient = recipient transfer.recipient_id = self.get_id_from_response('recipient') transfer.recipient_iban = recipient.iban transfer.recipient_label = recipient.label assert recipient._transfer_id in CleanText( u'//div[div[@class="libelleChoix" and contains(text(), "Compte destinataire")]] \ //div[@class="infoCompte" and not(@title)]', replace=[(' ', '')] )(self.doc) transfer.currency = FrenchTransaction.Currency('//div[@class="topBox"]/div[@class="montant"]')(self.doc) transfer.amount = CleanDecimal('//div[@class="topBox"]/div[@class="montant"]', replace_dots=True)(self.doc) transfer.exec_date = Date( Regexp(CleanText('//div[@class="topBox"]/div[@class="date"]'), r'(\d{2}\/\d{2}\/\d{4})'), dayfirst=True )(self.doc) transfer.label = reason assert reason in CleanText('//div[@class="motif"]')(self.doc) return transfer
def create_transfer(self, account, recipient, amount, reason): transfer = Transfer() transfer.currency = FrenchTransaction.Currency('//div[@class="topBox"]/div[@class="montant"]')(self.doc) transfer.amount = CleanDecimal('//div[@class="topBox"]/div[@class="montant"]', replace_dots=True)(self.doc) transfer.account_iban = account.iban transfer.recipient_iban = recipient.iban transfer.account_id = account.id transfer.recipient_id = recipient.id transfer.exec_date = date.today() transfer.label = reason transfer.account_label = account.label transfer.recipient_label = recipient.label transfer._account = account transfer._recipient = recipient transfer.account_balance = account.balance return transfer
def create_transfer(self, account, recipient, transfer): transfer = Transfer() transfer.currency = FrenchTransaction.Currency('.//td[@headers="virement montant"]')(self.doc) transfer.amount = CleanDecimal('.//td[@headers="virement montant"]', replace_dots=True)(self.doc) transfer.account_iban = CleanText('//td[@headers="emetteur IBAN"]', replace=[(' ', '')])(self.doc) transfer.recipient_iban = CleanText('//td[@headers="beneficiaire IBAN"]', replace=[(' ','')])(self.doc) transfer.account_id = account.id transfer.recipient_id = recipient.id transfer.exec_date = Date(CleanText('.//td[@headers="virement date"]'), dayfirst=True)(self.doc) transfer.label = CleanText('.//td[@headers="virement motif"]')(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
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
def create_transfer(self, account, recipient, transfer): transfer = Transfer() transfer.currency = FrenchTransaction.Currency( './/td[@headers="virement montant"]')(self.doc) transfer.amount = CleanDecimal('.//td[@headers="virement montant"]', replace_dots=True)(self.doc) transfer.account_iban = CleanText('//td[@headers="emetteur IBAN"]', replace=[(' ', '')])(self.doc) transfer.recipient_iban = CleanText( '//td[@headers="beneficiaire IBAN"]', replace=[(' ', '')])(self.doc) transfer.account_id = account.id transfer.recipient_id = recipient.id transfer.exec_date = Date(CleanText('.//td[@headers="virement date"]'), dayfirst=True)(self.doc) transfer.label = CleanText('.//td[@headers="virement motif"]')( 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