Package com.bank.domain

Examples of com.bank.domain.Account


      throw new IllegalArgumentException(
          format("transfer amount must be at least $%.2f", minimumTransferAmount));

    TransferReceipt receipt = new TransferReceipt();

    Account srcAcct = accountRepository.findById(srcAcctId);
    Account dstAcct = accountRepository.findById(dstAcctId);

    receipt.setInitialSourceAccount(srcAcct);
    receipt.setInitialDestinationAccount(dstAcct);

    double fee = feePolicy.calculateFee(amount);
    if (fee > 0)
      srcAcct.debit(fee);

    receipt.setTransferAmount(amount);
    receipt.setFeeAmount(fee);

    srcAcct.debit(amount);
    dstAcct.credit(amount);

    accountRepository.updateBalance(srcAcct);
    accountRepository.updateBalance(dstAcct);

    receipt.setFinalSourceAccount(srcAcct);
View Full Code Here


  private static class AccountRowMapper implements RowMapper<Account> {

    @Override
    public Account mapRow(ResultSet rs, int rowNum) throws SQLException {
      return new Account(rs.getString("id"), rs.getDouble("balance"));
    }
View Full Code Here

      throw new IllegalArgumentException(
          format("transfer amount must be at least $%.2f", minimumTransferAmount));

    TransferReceipt receipt = new TransferReceipt();

    Account srcAcct = accountRepository.findById(srcAcctId);
    Account dstAcct = accountRepository.findById(dstAcctId);

    receipt.setInitialSourceAccount(srcAcct);
    receipt.setInitialDestinationAccount(dstAcct);

    double fee = feePolicy.calculateFee(amount);
    if (fee > 0)
      srcAcct.debit(fee);

    receipt.setTransferAmount(amount);
    receipt.setFeeAmount(fee);

    srcAcct.debit(amount);
    dstAcct.credit(amount);

    accountRepository.updateBalance(srcAcct);
    accountRepository.updateBalance(dstAcct);

    receipt.setFinalSourceAccount(srcAcct);
View Full Code Here

  private static class AccountRowMapper implements RowMapper<Account> {

    @Override
    public Account mapRow(ResultSet rs, int rowNum) throws SQLException {
      return new Account(rs.getString("id"), rs.getDouble("balance"));
    }
View Full Code Here

    return Account.copy(nullSafeAccountLookup(acctId));
  }

  @Override
  public void updateBalance(Account account) {
    Account actualAccount = nullSafeAccountLookup(account.getId());
    actualAccount.setBalance(account.getBalance());
  }
View Full Code Here

    Account actualAccount = nullSafeAccountLookup(account.getId());
    actualAccount.setBalance(account.getBalance());
  }

  private Account nullSafeAccountLookup(String acctId) {
    Account account = accountsById.get(acctId);
    if (account == null)
      throw new AccountNotFoundException(acctId);
    return account;
  }
View Full Code Here

      throw new IllegalArgumentException(
          format("transfer amount must be at least $%.2f", minimumTransferAmount));

    TransferReceipt receipt = new TransferReceipt();

    Account srcAcct = accountRepository.findById(srcAcctId);
    Account dstAcct = accountRepository.findById(dstAcctId);

    receipt.setInitialSourceAccount(srcAcct);
    receipt.setInitialDestinationAccount(dstAcct);

    double fee = feePolicy.calculateFee(amount);
    if (fee > 0)
      srcAcct.debit(fee);

    receipt.setTransferAmount(amount);
    receipt.setFeeAmount(fee);

    srcAcct.debit(amount);
    dstAcct.credit(amount);

    accountRepository.updateBalance(srcAcct);
    accountRepository.updateBalance(dstAcct);

    receipt.setFinalSourceAccount(srcAcct);
View Full Code Here

TOP

Related Classes of com.bank.domain.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.