@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);