Search in sources :

Example 1 with SavingsTransactionHistoryDto

use of org.mifos.dto.screen.SavingsTransactionHistoryDto in project head by mifos.

the class SavingsAccountController method showSavingsAccountTransactionHistory.

@RequestMapping(value = "/viewSavingsAccountTransactionHistory", method = RequestMethod.GET)
public ModelAndView showSavingsAccountTransactionHistory(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountTransactionHistory", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
    modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
    List<SavingsTransactionHistoryDto> savingsTransactionHistoryViewList = this.savingsServiceFacade.retrieveTransactionHistory(globalAccountNum);
    request.setAttribute("trxnHistoryList", savingsTransactionHistoryViewList);
    savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) SavingsTransactionHistoryDto(org.mifos.dto.screen.SavingsTransactionHistoryDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SavingsTransactionHistoryDto

use of org.mifos.dto.screen.SavingsTransactionHistoryDto in project head by mifos.

the class SavingsActionStrutsTest method ignore_testSuccessfulGetStatusHistory.

/**
     * ignoring as test fails due to lazy init which doesnt happen in application
     */
public void ignore_testSuccessfulGetStatusHistory() throws Exception {
    SavingsTestHelper helper = new SavingsTestHelper();
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("asfddsf", "213a");
    savings = helper.createSavingsAccount("000100000000017", savingsOffering, group, AccountStates.SAVINGS_ACC_PARTIALAPPLICATION, userContext);
    Hibernate.initialize(savings);
    savingsOffering = null;
    AccountStateMachines.getInstance().initialize(AccountTypes.SAVINGS_ACCOUNT, null);
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_PENDING_APPROVAL, null, "notes", loggedInUser);
    Assert.assertEquals(AccountStates.SAVINGS_ACC_PENDINGAPPROVAL, savings.getAccountState().getId().shortValue());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
    SessionUtils.setAttribute(Constants.USER_CONTEXT_KEY, TestUtils.makeUser(), request.getSession());
    setRequestPathInfo("/savingsAction.do");
    addRequestParameter("method", "getStatusHistory");
    addRequestParameter("globalAccountNum", savings.getGlobalAccountNum());
    actionPerform();
    verifyForward("getStatusHistory_success");
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertEquals(2, ((List<SavingsTransactionHistoryDto>) SessionUtils.getAttribute(SavingsConstants.STATUS_CHANGE_HISTORY_LIST, request)).size());
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsTransactionHistoryDto(org.mifos.dto.screen.SavingsTransactionHistoryDto) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper)

Example 3 with SavingsTransactionHistoryDto

use of org.mifos.dto.screen.SavingsTransactionHistoryDto in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveTransactionHistory.

@Override
public List<SavingsTransactionHistoryDto> retrieveTransactionHistory(String globalAccountNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    SavingsBO savingsAccount = this.savingsDao.findBySystemId(globalAccountNum);
    CustomerBO customerBO = savingsAccount.getCustomer();
    savingsAccount.updateDetails(userContext);
    try {
        personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    List<SavingsTransactionHistoryDto> savingsTransactionHistoryViewList = new ArrayList<SavingsTransactionHistoryDto>();
    // Check for order-by clause in AccountBO.hbm.xml,
    // AccountPayment.hbm.xml and AccountTrxnEntity.hbm.xml for
    // accountPaymentSet ,
    // accountTrxnSet and financialBoSet. They all should be set for their
    // primay key column desc in both. If stated is not there, the code
    // below will behave abnormally.
    List<AccountPaymentEntity> accountPaymentSet = savingsAccount.getAccountPayments();
    for (AccountPaymentEntity accountPaymentEntity : accountPaymentSet) {
        Set<AccountTrxnEntity> accountTrxnEntitySet = accountPaymentEntity.getAccountTrxns();
        for (AccountTrxnEntity accountTrxnEntity : accountTrxnEntitySet) {
            Set<FinancialTransactionBO> financialTransactionBOSet = accountTrxnEntity.getFinancialTransactions();
            for (FinancialTransactionBO financialTransactionBO : financialTransactionBOSet) {
                SavingsTransactionHistoryDto savingsTransactionHistoryDto = new SavingsTransactionHistoryDto();
                savingsTransactionHistoryDto.setTransactionDate(financialTransactionBO.getActionDate());
                String preferredTransactionDate = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), financialTransactionBO.getActionDate().toString());
                savingsTransactionHistoryDto.setUserPrefferedTransactionDate(preferredTransactionDate);
                savingsTransactionHistoryDto.setPaymentId(accountTrxnEntity.getAccountPayment().getPaymentId());
                savingsTransactionHistoryDto.setAccountTrxnId(accountTrxnEntity.getAccountTrxnId());
                savingsTransactionHistoryDto.setType(financialTransactionBO.getFinancialAction().getName());
                savingsTransactionHistoryDto.setGlcode(financialTransactionBO.getGlcode().getGlcode());
                savingsTransactionHistoryDto.setGlname(financialTransactionBO.getGlcode().getAssociatedCOA().getAccountName());
                if (financialTransactionBO.isDebitEntry()) {
                    savingsTransactionHistoryDto.setDebit(String.valueOf(removeSign(financialTransactionBO.getPostedAmount())));
                } else if (financialTransactionBO.isCreditEntry()) {
                    savingsTransactionHistoryDto.setCredit(String.valueOf(removeSign(financialTransactionBO.getPostedAmount())));
                }
                savingsTransactionHistoryDto.setBalance(String.valueOf(removeSign(((SavingsTrxnDetailEntity) accountTrxnEntity).getBalance())));
                savingsTransactionHistoryDto.setClientName(accountTrxnEntity.getCustomer().getDisplayName());
                savingsTransactionHistoryDto.setPostedDate(financialTransactionBO.getPostedDate());
                String preferredDate = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), financialTransactionBO.getPostedDate().toString());
                savingsTransactionHistoryDto.setUserPrefferedPostedDate(preferredDate);
                if (accountTrxnEntity.getPersonnel() != null) {
                    savingsTransactionHistoryDto.setPostedBy(accountTrxnEntity.getPersonnel().getDisplayName());
                }
                if (financialTransactionBO.getNotes() != null && !financialTransactionBO.getNotes().equals("")) {
                    savingsTransactionHistoryDto.setNotes(financialTransactionBO.getNotes());
                }
                savingsTransactionHistoryViewList.add(savingsTransactionHistoryDto);
            }
        }
    }
    return savingsTransactionHistoryViewList;
}
Also used : FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTransactionHistoryDto(org.mifos.dto.screen.SavingsTransactionHistoryDto) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountException(org.mifos.accounts.exceptions.AccountException) CustomerBO(org.mifos.customers.business.CustomerBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

SavingsTransactionHistoryDto (org.mifos.dto.screen.SavingsTransactionHistoryDto)3 IncludePage (freemarker.ext.servlet.IncludePage)1 ArrayList (java.util.ArrayList)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 FinancialTransactionBO (org.mifos.accounts.financial.business.FinancialTransactionBO)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 SavingsTestHelper (org.mifos.accounts.savings.util.helpers.SavingsTestHelper)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1