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) if transfer.recipient_iban: recipient = find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban, error=RecipientNotFound) else: recipient = 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)
def check_basic_transfer(self, transfer): if transfer.amount <= 0: raise TransferInvalidAmount('transfer amount must be positive') if transfer.recipient_id == transfer.account_id: raise TransferInvalidRecipient('recipient must be different from emitter') if not transfer.label: raise TransferInvalidLabel('transfer label cannot be empty')
def init_transfer(self, transfer, **params): if not transfer.label: raise TransferInvalidLabel() self.logger.info('Going to do a new transfer') # origin account iban can be NotAvailable account = find_object(self.iter_accounts(), iban=transfer.account_iban) if not account: account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) if transfer.recipient_iban: recipient = find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban, error=RecipientNotFound) else: recipient = find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound) assert account.id.isdigit() # Only 11 first character are required to do transfer account.id = account.id[:11] return self.browser.init_transfer(account, recipient, transfer.amount, transfer.label, transfer.exec_date)
def init_transfer(self, transfer, **params): if not transfer.label: raise TransferInvalidLabel() self.logger.info('Going to do a new transfer') account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound) if transfer.recipient_iban: recipient = find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban, error=RecipientNotFound) else: recipient = find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound) return self.browser.init_transfer(account, recipient, transfer.amount, transfer.label, transfer.exec_date)