RemoteException, IllegalArgumentException,
AccountNotFoundException, InsufficientFundsException,
InsufficientCreditException {
Account fromAccount = checkAccountArgs(amount, description,
fromAccountId);
Account toAccount = checkAccountArgs(amount, description,
toAccountId);
String fromType = fromAccount.getType();
double fromBalance = fromAccount.getBalance();
if (DomainUtil.isCreditAccount(fromType)) {
double fromNewBalance = fromBalance + amount;
if (fromNewBalance > fromAccount.getCreditLine())
throw new InsufficientCreditException();
executeTx(amount, description, fromAccountId,
fromNewBalance, fromAccount);
} else {
double fromNewBalance = fromBalance - amount;
if (fromNewBalance < 0.0)
throw new InsufficientFundsException();
executeTx(-1 * amount, description, fromAccountId,
fromNewBalance, fromAccount);
}
String toType = toAccount.getType();
double toBalance = toAccount.getBalance();
if (DomainUtil.isCreditAccount(toType)) {
double toNewBalance = toBalance - amount;
executeTx(-1 * amount, description, toAccountId,
toNewBalance, toAccount);