public void doDebit(String number, double amount) throws BankTransactionException { account = associateAccount(number); try { account.debit(amount); repository.persist(); } catch (NegativeAmountException | InsufficientFundsException | IOException e) { throw new BankTransactionException(e); } try { log.userOperationCredDeb("Debit", number, amount); } catch (IOException e) { e.printStackTrace(); } }
public void doTransfer(String fromNumber, String toNumber, double amount) throws BankTransactionException { AbstractAccount fromAccount; fromAccount = associateAccount(fromNumber); AbstractAccount toAccount; toAccount = associateAccount(toNumber); ; try { fromAccount.debit(amount); toAccount.credit(amount); repository.persist(); } catch (InsufficientFundsException | NegativeAmountException | IOException e) { throw new BankTransactionException(e); } try { log.userOperationTransf(fromNumber, toNumber, amount); } catch (IOException e) { e.printStackTrace(); } }