Package com.excilys.ebi.bank.model.entity

Examples of com.excilys.ebi.bank.model.entity.Account


  private void exportAccount(ModelMap model, Map<String, ?> pathVariables) {

    String accountNumber = getModelOrPathAttribute("accountNumber", model, pathVariables);
    Assert.notNull(accountNumber, "accountNumber required");

    Account account = bankService.findAccountByNumberFetchCards(accountNumber);
    model.addAttribute("account", account);
  }
View Full Code Here


  private OperationTypeRefDao operationTypeDao;

  @Override
  @Cacheable(cacheName = IConstants.Cache.ENTITY_CACHE, keyGenerator = @KeyGenerator(name = IConstants.Cache.KEY_GENERATOR))
  public Integer findAccountIdByNumber(String accountNumber) {
    Account account = accountDao.findByNumber(accountNumber);
    notNull(account, "account with number {} not found", accountNumber);
    return account.getId();
  }
View Full Code Here

  @Override
  @PostAuthorize("hasPermission(returnObject, 'read')")
  public Account findAccountByNumberFetchCards(String accountNumber) {

    Account account = accountDao.findByNumber(accountNumber);
    notNull(account, "account with number {} not found", accountNumber);
    initialize(account.getCards());
    return account;
  }
View Full Code Here

  @Transactional(readOnly = false)
  public void performTransfer(Integer debitedAccountId, Integer creditedAccountId, @Min(10) BigDecimal amount) throws UnsufficientBalanceException {

    isTrue(!debitedAccountId.equals(creditedAccountId), "accounts must be different");

    Account debitedAccount = accountDao.findOne(debitedAccountId);
    notNull(debitedAccount, "account with number {} not found", debitedAccount);

    if (debitedAccount.getBalance().compareTo(amount) < 0) {
      throw new UnsufficientBalanceException();
    }

    Account creditedAccount = accountDao.findOne(creditedAccountId);
    notNull(creditedAccount, "account with number {} not found", creditedAccount);

    debitedAccount.setBalance(debitedAccount.getBalance().subtract(amount));
    creditedAccount.setBalance(creditedAccount.getBalance().add(amount));

    DateTime now = now();
    OperationStatusRef status = operationStatusDao.findOne(OperationStatus.RESOLVED);
    OperationTypeRef type = operationTypeDao.findOne(OperationType.TRANSFER);
View Full Code Here

TOP

Related Classes of com.excilys.ebi.bank.model.entity.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.