/** * This method updates the account balance. * * @param accountId The id of the account which needs to be updated. * @param amount The amount by which the account needs to be updated. */ private void updateAccountTotal(Long accountId, Double amount) { if (amount != null && amount != 0) { Account account = accountRepository.findOne(accountId); account.setBalance(account.getBalance() + amount); accountRepository.save(account); } }
/** * This method gets the balance for the given account. * * @param accountId The required account id. * @return The balance of the given account. */ private Double getCurrentAccountBalance(Long accountId) { return accountRepository.findOne(accountId).getBalance(); }