Package com.sun.ebank.ejb.account

Examples of com.sun.ebank.ejb.account.Account


        String fromAccountId, String toAccountId) throws 
        InvalidParameterException,
        AccountNotFoundException, InsufficientFundsException,
        InsufficientCreditException {

        Account fromAccount = checkAccountArgs(amount, description,
            fromAccountId);
        Account toAccount = checkAccountArgs(amount, description,
            toAccountId);

        String fromType = fromAccount.getType();
        BigDecimal fromBalance = fromAccount.getBalance();

        if (DomainUtil.isCreditAccount(fromType)) {
            BigDecimal fromNewBalance =  fromBalance.add(amount);
            if (fromNewBalance.compareTo(fromAccount.getCreditLine()) == 1)
                throw new InsufficientCreditException();
            executeTx(amount, description, fromAccountId,
                fromNewBalance, fromAccount);
        } else {
            BigDecimal fromNewBalance =  fromBalance.subtract(amount);
            if (fromNewBalance.compareTo(bigZero) == -1)
                throw new InsufficientFundsException();
            executeTx(amount.negate(), description, fromAccountId,
                fromNewBalance, fromAccount);
        }
           
        String toType = toAccount.getType();
        BigDecimal toBalance = toAccount.getBalance();
   
        if (DomainUtil.isCreditAccount(toType)) {
            BigDecimal toNewBalance = toBalance.subtract(amount);
            executeTx(amount.negate(), description, toAccountId,
                toNewBalance, toAccount);
View Full Code Here


    private Account checkAccountArgs(BigDecimal amount, String description,
        String accountId) throws InvalidParameterException,
        AccountNotFoundException {

        Account account = null;

        if (description == null)
            throw new InvalidParameterException("null description");

        if (accountId == null)
View Full Code Here

TOP

Related Classes of com.sun.ebank.ejb.account.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.