Пример #1
0
  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();
    }
  }
Пример #2
0
  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();
    }
  }