def init_transfer(self, transfer, **params): if self.config['website'].get() != 'par': raise NotImplementedError() self.logger.info('Going to do a new transfer') account = strict_find_object(self.iter_accounts(), iban=transfer.account_iban) if not account: account = strict_find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients( account.id), iban=transfer.recipient_iban) if not recipient: recipient = strict_find_object(self.iter_transfer_recipients( account.id), id=transfer.recipient_id, error=RecipientNotFound) amount = Decimal(transfer.amount).quantize(Decimal(10)**-2) # format label like label sent by firefox or chromium browser transfer.label = transfer.label.encode( 'latin-1', errors="xmlcharrefreplace").decode('latin-1') return self.browser.init_transfer(account, recipient, amount, transfer)
def init_transfer(self, transfer, **params): if self.config['website'].get() not in ('par', 'pro'): raise NotImplementedError() transfer.label = ' '.join( w for w in re.sub('[^0-9a-zA-Z ]+', '', transfer.label).split()) self.logger.info('Going to do a new transfer') account = strict_find_object(self.iter_accounts(), iban=transfer.account_iban) if not account: account = strict_find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients( account.id), id=transfer.recipient_id) if not recipient: recipient = strict_find_object(self.iter_transfer_recipients( account.id), iban=transfer.recipient_iban, error=RecipientNotFound) transfer.amount = transfer.amount.quantize(Decimal('.01')) return self.browser.init_transfer(account, recipient, transfer)
def init_transfer(self, transfer, **params): if self.config['website'].get() != 'pp': raise NotImplementedError() if transfer.label is None: raise TransferInvalidLabel() self.logger.info('Going to do a new transfer') if transfer.account_iban: account = find_object(self.iter_accounts(), iban=transfer.account_iban, error=AccountNotFound) else: account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients( account.id), iban=transfer.recipient_iban) if not recipient: recipient = strict_find_object(self.iter_transfer_recipients( account.id), id=transfer.recipient_id, error=RecipientNotFound) assert account.id.isdigit() # quantize to show 2 decimals. amount = Decimal(transfer.amount).quantize(Decimal(10)**-2) return self.browser.init_transfer(account, recipient, amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): # There is a check on the website, transfer can't be done with too long reason. if transfer.label: transfer.label = transfer.label[:30] self.logger.info('Going to do a new transfer') acc_list = list(self.iter_accounts()) account = strict_find_object(acc_list, iban=transfer.account_iban) if not account: account = strict_find_object(acc_list, id=transfer.account_id, error=AccountNotFound) rcpt_list = list(self.iter_transfer_recipients(account.id)) recipient = strict_find_object(rcpt_list, iban=transfer.recipient_iban) if not recipient: recipient = strict_find_object(rcpt_list, id=transfer.recipient_id, error=RecipientNotFound) try: # quantize to show 2 decimals. amount = Decimal(transfer.amount).quantize(Decimal(10)**-2) except (AssertionError, ValueError): raise TransferError('something went wrong') return self.browser.init_transfer(account, recipient, amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): self.logger.info('Going to do a new transfer') account = strict_find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients(account), id=transfer.recipient_id, error=RecipientNotFound) transfer.amount = Decimal(transfer.amount).quantize(Decimal('.01')) return self.browser.init_transfer(account, recipient, transfer)
def init_transfer(self, transfer, **params): if self.config['website'].get() not in ('par', 'pro'): raise NotImplementedError() transfer.label = ' '.join(w for w in re.sub('[^0-9a-zA-Z ]+', '', transfer.label).split()) self.logger.info('Going to do a new transfer') account = strict_find_object(self.iter_accounts(), iban=transfer.account_iban) if not account: account = strict_find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id) if not recipient: recipient = strict_find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban, error=RecipientNotFound) transfer.amount = transfer.amount.quantize(Decimal('.01')) return self.browser.init_transfer(account, recipient, transfer)
def init_transfer(self, transfer, **params): if self.config['website'].get() != "par": raise NotImplementedError() self.logger.info('Going to do a new transfer') account = strict_find_object(self.iter_accounts(), error=AccountNotFound, iban=transfer.account_iban, id=transfer.account_id) recipient = strict_find_object(self.iter_transfer_recipients( account.id), error=RecipientNotFound, iban=transfer.recipient_iban, id=transfer.recipient_id) return self.browser.init_transfer(account, recipient, transfer.amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): if self.config['website'].get() != 'par': raise NotImplementedError() self.logger.info('Going to do a new transfer') account = strict_find_object(self.iter_accounts(), iban=transfer.account_iban) if not account: account = strict_find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban) if not recipient: recipient = strict_find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound) amount = Decimal(transfer.amount).quantize(Decimal(10) ** -2) # format label like label sent by firefox or chromium browser transfer.label = transfer.label.encode('latin-1', errors="xmlcharrefreplace").decode('latin-1') return self.browser.init_transfer(account, recipient, amount, transfer)
def init_transfer(self, transfer, **params): if self.config['website'].get() != "par": raise NotImplementedError() self.logger.info('Going to do a new transfer') account = strict_find_object( self.iter_accounts(), error=AccountNotFound, iban=transfer.account_iban, id=transfer.account_id ) recipient = strict_find_object( self.iter_transfer_recipients(account.id), error=RecipientNotFound, iban=transfer.recipient_iban, id=transfer.recipient_id ) return self.browser.init_transfer(account, recipient, transfer.amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): if self.config['website'].get() != 'pp': raise NotImplementedError() if transfer.label is None: raise TransferInvalidLabel() self.logger.info('Going to do a new transfer') if transfer.account_iban: account = find_object(self.iter_accounts(), iban=transfer.account_iban, error=AccountNotFound) else: account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) recipient = strict_find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban) if not recipient: recipient = strict_find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound) assert account.id.isdigit() # quantize to show 2 decimals. amount = Decimal(transfer.amount).quantize(Decimal(10) ** -2) return self.browser.init_transfer(account, recipient, amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): # There is a check on the website, transfer can't be done with too long reason. if transfer.label: transfer.label = transfer.label[:30] self.logger.info('Going to do a new transfer') acc_list = list(self.iter_accounts()) account = strict_find_object(acc_list, iban=transfer.account_iban) if not account: account = strict_find_object(acc_list, id=transfer.account_id, error=AccountNotFound) rcpt_list = list(self.iter_transfer_recipients(account.id)) recipient = strict_find_object(rcpt_list, iban=transfer.recipient_iban) if not recipient: recipient = strict_find_object(rcpt_list, id=transfer.recipient_id, error=RecipientNotFound) try: # quantize to show 2 decimals. amount = Decimal(transfer.amount).quantize(Decimal(10) ** -2) except (AssertionError, ValueError): raise TransferError('something went wrong') return self.browser.init_transfer(account, recipient, amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): # first, get _account on account list to get recipient _account = strict_find_object(self.get_accounts_list(), id=transfer.account_id, error=AccountNotFound) # get information to go on transfer page space, operation, referer, connection_id = self.get_account_transfer_space_info(account=_account) recipient = strict_find_object( self.iter_transfer_recipients(_account, transfer_space_info=(space, operation, referer)), id=transfer.recipient_id, error=RecipientNotFound ) # Then, get account on transfer account list to get index and other information account = strict_find_object(self.iter_debit_accounts(), id=_account.id, error=AccountNotFound) # get token and transfer token to init transfer token = self.token_page.go().get_token() transfer_token = self.transfer_token.go(space=space, op=operation, headers={'Referer': referer}).get_token() data = { 'connexionId': connection_id, 'cr': self.session.cookies['caisse-regionale'], 'creditAccountIban': recipient.iban, 'creditAccountIndex': recipient._index, 'debitAccountIndex': account._index, 'debitAccountNumber': account.number, 'externalAccount': recipient.category == 'Externe', 'recipientName': recipient.label, 'transferAmount': transfer.amount, 'transferComplementaryInformation1': transfer.label, 'transferComplementaryInformation2': '', 'transferComplementaryInformation3': '', 'transferComplementaryInformation4': '', 'transferCurrencyCode': account.currency, 'transferDate': transfer.exec_date.strftime('%d/%m/%Y'), 'transferFrequency': 'U', 'transferRef': transfer.label, 'transferType': 'UNIQUE', 'typeCompte': account.label, } # update transfer data according to recipient category if recipient.category == 'Interne': data['creditAccountNumber'] = recipient.id data['recipientName'] = recipient._owner_name # init transfer request self.transfer.go( space=space, op=operation, headers={'Referer': referer, 'CSRF-Token': token, 'NPC-Generated-Token': transfer_token}, json=data ) assert self.page.check_transfer() # get recap because it's not returned by init transfer request self.transfer_recap.go( space=space, op=operation, headers={'Referer': self.absurl('/%s/operations/%s/virement.postredirect.html' % (space, operation))} ) # information needed to exec transfer transfer._space = space transfer._operation = operation transfer._token = token transfer._connection_id = connection_id return self.page.handle_response(transfer)
def init_transfer(self, transfer, **params): # first, get _account on account list to get recipient _account = strict_find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) # get information to go on transfer page space, operation, referer, connection_id = self.get_account_transfer_space_info( account=_account) recipient = strict_find_object(self.iter_transfer_recipients( _account, transfer_space_info=(space, operation, referer)), id=transfer.recipient_id, error=RecipientNotFound) # Then, get account on transfer account list to get index and other information account = strict_find_object(self.iter_debit_accounts(), id=_account.id, error=AccountNotFound) # get token and transfer token to init transfer token = self.token_page.go().get_token() transfer_token = self.transfer_token.go(space=space, op=operation, headers={ 'Referer': referer }).get_token() data = { 'connexionId': connection_id, 'cr': self.session.cookies['caisse-regionale'], 'creditAccountIban': recipient.iban, 'creditAccountIndex': recipient._index, 'debitAccountIndex': account._index, 'debitAccountNumber': account.number, 'externalAccount': recipient.category == 'Externe', 'recipientName': recipient.label, 'transferAmount': transfer.amount, 'transferComplementaryInformation1': transfer.label, 'transferComplementaryInformation2': '', 'transferComplementaryInformation3': '', 'transferComplementaryInformation4': '', 'transferCurrencyCode': account.currency, 'transferDate': transfer.exec_date.strftime('%d/%m/%Y'), 'transferFrequency': 'U', 'transferRef': transfer.label, 'transferType': 'UNIQUE', 'typeCompte': account.label, } # update transfer data according to recipient category if recipient.category == 'Interne': data['creditAccountNumber'] = recipient.id data['recipientName'] = recipient._owner_name # init transfer request self.transfer.go(space=space, op=operation, headers={ 'Referer': referer, 'CSRF-Token': token, 'NPC-Generated-Token': transfer_token }, json=data) assert self.page.check_transfer() # get recap because it's not returned by init transfer request self.transfer_recap.go( space=space, op=operation, headers={ 'Referer': self.absurl('/%s/operations/%s/virement.postredirect.html' % (space, operation)) }) # information needed to exec transfer transfer._space = space transfer._operation = operation transfer._token = token transfer._connection_id = connection_id return self.page.handle_response(transfer)