Package net.octal.supinbank.entity

Examples of net.octal.supinbank.entity.Account


    public List<Account> getAccountsByCustomer(Person customer) {
        return accountDao.getAccountsByCustomer(customer);
    }
   
    public Account withDrawAccount(Long accountId, Double amount) {
        Account account = accountDao.findAccountById(accountId);
        if (account != null) {
            Preconditions.checkArgument(account.getTotalAmount() >= amount);
            account.setTotalAmount(account.getTotalAmount() - amount);
        }
       
        return account;
    }
View Full Code Here


        }
       
        return account;
    }
    public Account creditAccount(Long accountId, Double amount) {
        Account account = accountDao.findAccountById(accountId);
        if (account != null) {
            account.setTotalAmount(account.getTotalAmount() + amount);
        }
       
        return account;
    }
View Full Code Here

            throws ServletException, IOException {
        final Person customer = (Person) request.getSession().getAttribute("customer");
        final List<Account> accounts = accountDao.getAccountsByCustomer(customer);
        request.setAttribute("accounts", accounts);
        if (!accounts.isEmpty()) {
            final Account firstAccount = accounts.get(0);
            final List<Operation> operations = operationDao.findOperationsByAccount(firstAccount);
            request.setAttribute("operations", operations);
            request.setAttribute("currentAccount", firstAccount);
        }
        request.getRequestDispatcher("../../listOperations.jsp").forward(request, response);
View Full Code Here

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        final Person customer = (Person) request.getSession().getAttribute("customer");
        final List<Account> accounts = accountDao.getAccountsByCustomer(customer);
        final Long accountId = Long.parseLong(request.getParameter("account"));
        final Account account = accountDao.findAccountById(accountId);
        final List<Operation> operations = operationDao.findOperationsByAccount(account);
       
        request.setAttribute("accounts", accounts);
        request.setAttribute("operations", operations);
        request.setAttribute("currentAccount", account);
View Full Code Here

        final String description = request.getParameter("description");
       
        /* Must perform an internal transfert */
        if (scope.equals("internal")) {
            final Long accountToId = Long.parseLong(request.getParameter("accountTo"));
            final Account accountFrom = accountService.findAccountById(accountFromId);
            final Account accountTo = accountService.findAccountById(accountToId);
            if (accountFrom != null && accountTo != null) {
               
                if (amount > accountFrom.getTotalAmount()) {
                    request.setAttribute("error", true);
                    request.setAttribute("errorString", "You can't perform this transfert with your account amount");
                }
                else if (accountFromId.equals(accountToId)) {
                    request.setAttribute("error", true);
                    request.setAttribute("errorString", "You can't transfert to the same account");
                }
                else
                {
                    transfertService.performInternalTransfert(accountFrom, accountTo, amount, description);
                    request.setAttribute("informationString", "Your transfert has succeeded");
                }
                doGet(request, response);
            }
        }
       
        else if (scope.equals("external")) {
            final Account accountFrom = accountService.findAccountById(accountFromId);
            final String bbanEstablishmentCode = request.getParameter("bbanEstablishmentCode");
            final String bbanBranchCode = request.getParameter("bbanBranchCode");
            final String bbanAccountNumber = request.getParameter("bbanAccountNumber");
            final String bbanKey = request.getParameter("bbanKey");
            final BasicBankAccountNumber bban = new BasicBankAccountNumber(bbanEstablishmentCode,
                        bbanBranchCode, bbanAccountNumber, bbanKey);
           
            if (amount > accountFrom.getTotalAmount()) {
                request.setAttribute("error", true);
                request.setAttribute("errorString", "You can't perform this transfert with your account amount");
            }
           
            /*
            if (!bban.isKeyValid()) {
                request.setAttribute("error", true);
                request.setAttribute("errorString", "The BBAN Key is invalid");
                doGet(request, response);
            }
            */

           
            else if (bbanEstablishmentCode.equals(ESTABLISHMENT_CODE)) {
               
                final Long accountToId = Long.parseLong(
                        BasicBankAccountNumber.normalizedAccountNumber(bbanAccountNumber));
                final Account accountTo = accountService.findAccountById(accountToId);
                if (accountTo != null) {
                    transfertService.performAnotherCustomerTransfert(accountFrom, accountTo, bban.toString(),
                                                                     amount, description);

                    request.setAttribute("informationString", "Your transfert has succeeded");
View Full Code Here

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        final String sAccountId = request.getParameter("accountId");
        final Long accountId = Long.parseLong(sAccountId);
        final Account account = accountService.findAccountById(accountId);
        request.setAttribute("account", account);
        request.getRequestDispatcher("../../addFundsAccount.jsp").forward(request, response);
    }
View Full Code Here

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        final String sAccountId = request.getParameter("accountId");
        final Long accountId = Long.parseLong(sAccountId);
        final Account account = accountService.findAccountById(accountId);
        final Double amount = Double.parseDouble(request.getParameter("amount"));
        final String wording = request.getParameter("wording");
        final Calendar cal = Calendar.getInstance();
       
        Operation operation = new Operation();
        operation.setDate(cal.getTime());
        operation.setAmount(amount);
        operation.setWording(wording);
        account.addOperation(operation);
       
        operationDao.addOperation(operation);
        accountService.creditAccount(accountId, amount);
       
        response.sendRedirect(getServletContext().getContextPath() +
                String.format("/auth/admin/customer?id=%d", account.getUser().getId()));
    }
View Full Code Here

       
        final String accountName = request.getParameter("accountName");
        final String interestPlan = request.getParameter("interestPlan");
        final String customerId = request.getParameter("customerId");
       
        Account account = new Account();
        account.setName(accountName);
        account.setTotalAmount(0.0);
        account.setType(AccountType.valueOf(interestPlan));
       
        /* The customerId is empty, which means we must create the Customer */
        if (customerId.isEmpty())
        {
            final Person customer = (Person) request.getSession().getAttribute("customer");
View Full Code Here

TOP

Related Classes of net.octal.supinbank.entity.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.