double currentBalance = 0.0;
int userId = externalUserTransaction.getUserId();
ExternalAccount externalAccount = externalAccountBO.findUserByid(userId);
if(externalAccount != null)
{
currentBalance = externalAccount.getCurrentBalance();
}
// Check the current Balance if not return error
if(currentBalance<amount)
{
return "redirect:/Merchant/MerchantLessFunds";
}
//else process the transaction.
else
{
//Update the current Balance
amount=amount*-1;
currentBalance = currentBalance + amount;
externalAccount.setCurrentBalance(currentBalance);
externalAccountBO.update(externalAccount);
// Create New Transaction
externalUserTransaction.setAmountInvolved(amount);