Search in sources :

Example 1 with LoanActivityDto

use of org.mifos.dto.domain.LoanActivityDto in project head by mifos.

the class LoanAccountAction method getGroupLoanAccountDetails.

@TransactionDemarcate(saveToken = true)
public ActionForward getGroupLoanAccountDetails(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanAccountActionForm loanAccountActionForm = (LoanAccountActionForm) form;
    loanAccountActionForm.clearDetailsForLoan();
    String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
    UserContext userContext = getUserContext(request);
    LoanInformationDto loanInformationDto;
    List<LoanInformationDto> memberloanInformationDtos = new ArrayList<LoanInformationDto>();
    try {
        loanInformationDto = this.loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
        for (LoanBO member : loanDao.findByGlobalAccountNum(globalAccountNum).getMemberAccounts()) {
            memberloanInformationDtos.add(this.loanAccountServiceFacade.retrieveLoanInformation(member.getGlobalAccountNum()));
            request.getSession().setAttribute("guarantyInformation", loanAccountServiceFacade.handleGuaranties(this.loanAccountServiceFacade.retrieveLoanInformation(member.getGlobalAccountNum())));
        }
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    final String accountStateNameLocalised = ApplicationContextProvider.getBean(MessageLookup.class).lookup(loanInformationDto.getAccountStateName());
    SessionUtils.removeThenSetAttribute("accountStateNameLocalised", accountStateNameLocalised, request);
    final String gracePeriodTypeNameLocalised = ApplicationContextProvider.getBean(MessageLookup.class).lookup(loanInformationDto.getGracePeriodTypeName());
    SessionUtils.removeThenSetAttribute("gracePeriodTypeNameLocalised", gracePeriodTypeNameLocalised, request);
    final String interestTypeNameLocalised = ApplicationContextProvider.getBean(MessageLookup.class).lookup(loanInformationDto.getInterestTypeName());
    SessionUtils.removeThenSetAttribute("interestTypeNameLocalised", interestTypeNameLocalised, request);
    final Set<String> accountFlagStateEntityNamesLocalised = new HashSet<String>();
    for (String name : loanInformationDto.getAccountFlagNames()) {
        accountFlagStateEntityNamesLocalised.add(ApplicationContextProvider.getBean(MessageLookup.class).lookup(name));
    }
    SessionUtils.setCollectionAttribute("accountFlagNamesLocalised", accountFlagStateEntityNamesLocalised, request);
    SessionUtils.removeAttribute(BUSINESS_KEY, request);
    Integer loanIndividualMonitoringIsEnabled = configurationPersistence.getConfigurationValueInteger(LOAN_INDIVIDUAL_MONITORING_IS_ENABLED);
    if (null != loanIndividualMonitoringIsEnabled && loanIndividualMonitoringIsEnabled.intValue() != 0) {
        SessionUtils.setAttribute(LOAN_INDIVIDUAL_MONITORING_IS_ENABLED, loanIndividualMonitoringIsEnabled.intValue(), request);
    }
    Boolean GroupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
    if (null != GroupLoanWithMembers && GroupLoanWithMembers != false) {
        SessionUtils.setAttribute("GroupLoanWithMembers", GroupLoanWithMembers.booleanValue(), request);
    }
    List<ValueListElement> allLoanPurposes = this.loanProductDao.findAllLoanPurposes();
    SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, allLoanPurposes, request);
    if ((null != loanIndividualMonitoringIsEnabled && 0 != loanIndividualMonitoringIsEnabled.intValue() && loanInformationDto.isGroup()) || loanInformationDto.isGroupLoanWithMembersEnabled() || (null != GroupLoanWithMembers && GroupLoanWithMembers != false)) {
        List<LoanAccountDetailsDto> loanAccountDetails = this.loanAccountServiceFacade.retrieveLoanAccountDetails(loanInformationDto);
        addEmptyBuisnessActivities(loanAccountDetails);
        SessionUtils.setCollectionAttribute("loanAccountDetailsView", loanAccountDetails, request);
    }
    SessionUtils.setCollectionAttribute(CUSTOM_FIELDS, new ArrayList<CustomFieldDefinitionEntity>(), request);
    // Retrieve and set into the session all collateral types from the
    // lookup_value_locale table associated with the current user context
    // locale
    SessionUtils.setCollectionAttribute(MasterConstants.COLLATERAL_TYPES, legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES).getCustomValueListElements(), request);
    SessionUtils.setAttribute(AccountConstants.LAST_PAYMENT_ACTION, loanBusinessService.getLastPaymentAction(loanInformationDto.getAccountId()), request);
    SessionUtils.removeThenSetAttribute("loanInformationDto", loanInformationDto, request);
    //loanAccountServiceFacade.putLoanBusinessKeyInSession(globalAccountNum, request);
    List<LoanActivityDto> activities = loanInformationDto.getRecentAccountActivity();
    for (LoanActivityDto activity : activities) {
        activity.setUserPrefferedDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), activity.getActionDate().toString()));
    }
    SessionUtils.removeAttribute(RECENTACCOUNTACTIVITIES, request.getSession());
    SessionUtils.setCollectionAttribute(RECENTACCOUNTACTIVITIES, activities, request);
    request.setAttribute(CustomerConstants.SURVEY_KEY, loanInformationDto.getAccountSurveys());
    request.setAttribute(CustomerConstants.SURVEY_COUNT, loanInformationDto.getActiveSurveys());
    request.setAttribute(AccountConstants.SURVEY_KEY, loanInformationDto.getAccountSurveys());
    Integer administrativeDocumentsIsEnabled = configurationPersistence.getConfigurationValueInteger(ADMINISTRATIVE_DOCUMENT_IS_ENABLED);
    if (null != administrativeDocumentsIsEnabled && administrativeDocumentsIsEnabled.intValue() == 1) {
        SessionUtils.setCollectionAttribute(AdminDocumentsContants.ADMINISTRATIVEDOCUMENTSLIST, legacyAdminDocumentDao.getAllActiveAdminDocuments(), request);
        SessionUtils.setCollectionAttribute(AdminDocumentsContants.ADMINISTRATIVEDOCUMENTSACCSTATEMIXLIST, legacyAdminDocAccStateMixDao.getAllMixedAdminDocuments(), request);
    }
    List<QuestionGroupInstanceDetail> questions = new ArrayList<QuestionGroupInstanceDetail>();
    QuestionnaireServiceFacade questionnaireServiceFacade = questionnaireServiceFacadeLocator.getService(request);
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Create", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Approve", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "View", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Disburse", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Close", "Loan"));
    SessionUtils.setCollectionAttribute("questionGroups", questions, request);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("Loan"), request);
    LoanBO loan = getLoan(loanInformationDto.getAccountId());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
    LoanAccountAction.setSessionAtributeForGLIM(request, loan);
    setCurrentPageUrl(request, loan);
    setQuestionGroupInstances(request, loan);
    setOverpayments(request, loan);
    List<RepaymentScheduleInstallment> installments = loan.toRepaymentScheduleDto(userContext.getPreferredLocale());
    loanAccountActionForm.initializeInstallments(installments);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) MessageLookup(org.mifos.application.master.MessageLookup) HashSet(java.util.HashSet) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) ValueListElement(org.mifos.dto.domain.ValueListElement) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with LoanActivityDto

use of org.mifos.dto.domain.LoanActivityDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method getApplicablePayments.

private List<LoanActivityDto> getApplicablePayments(LoanBO loan) {
    List<LoanActivityDto> payments = new ArrayList<LoanActivityDto>();
    List<AccountPaymentEntity> accountPayments = loan.getAccountPayments();
    int i = accountPayments.size() - 1;
    if (accountPayments.size() > 0) {
        for (AccountPaymentEntity accountPayment : accountPayments) {
            if (accountPayment.getAmount().isGreaterThanZero()) {
                Money amount = new Money(accountPayment.getAmount().getCurrency());
                if (i == 0) {
                    for (AccountTrxnEntity accountTrxn : accountPayment.getAccountTrxns()) {
                        short accountActionTypeId = accountTrxn.getAccountActionEntity().getId().shortValue();
                        boolean isLoanRepayment = accountActionTypeId == AccountActionTypes.LOAN_REPAYMENT.getValue();
                        boolean isFeeRepayment = accountActionTypeId == AccountActionTypes.FEE_REPAYMENT.getValue();
                        if (isLoanRepayment || isFeeRepayment) {
                            amount = amount.add(accountTrxn.getAmount());
                        }
                    }
                } else {
                    amount = accountPayment.getAmount();
                }
                if (amount.isGreaterThanZero()) {
                    LoanActivityDto loanActivityDto = new LoanActivityDto();
                    loanActivityDto.setActionDate(accountPayment.getPaymentDate());
                    loanActivityDto.setTotal(amount.toString());
                    loanActivityDto.setTotalValue(amount.getAmount().doubleValue());
                    payments.add(0, loanActivityDto);
                }
            }
            i--;
        }
    }
    return payments;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) ArrayList(java.util.ArrayList) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity)

Example 3 with LoanActivityDto

use of org.mifos.dto.domain.LoanActivityDto in project head by mifos.

the class GroupLoanAccountServiceFacadeWebTier method getRecentActivityView.

private List<LoanActivityDto> getRecentActivityView(final String globalAccountNumber) {
    LoanBO loanBO = loanDao.findByGlobalAccountNum(globalAccountNumber);
    List<LoanActivityEntity> loanAccountActivityDetails = loanBO.getLoanActivityDetails();
    List<LoanActivityDto> recentActivityView = new ArrayList<LoanActivityDto>();
    int count = 0;
    for (LoanActivityEntity loanActivity : loanAccountActivityDetails) {
        recentActivityView.add(getLoanActivityView(loanActivity));
        if (++count == 3) {
            break;
        }
    }
    return recentActivityView;
}
Also used : LoanActivityEntity(org.mifos.accounts.loan.business.LoanActivityEntity) LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList)

Example 4 with LoanActivityDto

use of org.mifos.dto.domain.LoanActivityDto in project head by mifos.

the class ViewLoanAccountDetailsController method showLoanAccountDetails.

@RequestMapping(value = "/viewLoanAccountDetails", method = RequestMethod.GET)
public ModelAndView showLoanAccountDetails(HttpServletRequest request, HttpServletResponse response) throws ApplicationException {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewLoanAccountDetails", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    LoanInformationDto loanInformationDto = loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
    modelAndView.addObject("loanInformationDto", loanInformationDto);
    boolean containsQGForCloseLoan = questionnaireServiceFacade.getQuestionGroupInstances(loanInformationDto.getAccountId(), "Close", "Loan").size() > 0;
    modelAndView.addObject("containsQGForCloseLoan", containsQGForCloseLoan);
    // for mifostabletag
    List<LoanActivityDto> activities = loanInformationDto.getRecentAccountActivity();
    for (LoanActivityDto activity : activities) {
        activity.setUserPrefferedDate(DateFormatUtils.format(activity.getActionDate(), "dd/MM/yyyy", personnelServiceFacade.getUserPreferredLocale()));
    }
    request.getSession().setAttribute("recentAccountActivities", loanInformationDto.getRecentAccountActivity());
    request.getSession().setAttribute("guarantyInformation", loanAccountServiceFacade.handleGuaranties(loanInformationDto));
    //for GLIM
    if (configurationServiceFacade.isGlimEnabled() && loanInformationDto.isGroup()) {
        List<LoanAccountDetailsDto> loanAccountsDetails = loanAccountServiceFacade.retrieveLoanAccountDetails(loanInformationDto);
        addEmptyBuisnessActivities(loanAccountsDetails);
        modelAndView.addObject("loanAccountDetailsView");
        request.setAttribute("loanAccountDetailsView", loanAccountsDetails);
    }
    modelAndView.addObject("backPageUrl", UrlHelper.constructCurrentPageUrl(request));
    request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
    loanAccountServiceFacade.putLoanBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with LoanActivityDto

use of org.mifos.dto.domain.LoanActivityDto in project head by mifos.

the class ViewLoanAccountDetailsController method showLoanAccountAllActivity.

@RequestMapping(value = "/viewLoanAccountAllActivity", method = RequestMethod.GET)
public ModelAndView showLoanAccountAllActivity(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewLoanAccountAllActivity", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    LoanInformationDto loanInformationDto = loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
    modelAndView.addObject("loanInformationDto", loanInformationDto);
    modelAndView.addObject("currentDate", new Date());
    List<LoanActivityDto> allLoanAccountActivities = this.loanAccountServiceFacade.retrieveAllLoanAccountActivities(globalAccountNum);
    request.setAttribute("loanAllActivityView", allLoanAccountActivities);
    this.loanAccountServiceFacade.putLoanBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)16 LoanBO (org.mifos.accounts.loan.business.LoanBO)8 ArrayList (java.util.ArrayList)7 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)5 Money (org.mifos.framework.util.helpers.Money)5 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 UserContext (org.mifos.security.util.UserContext)4 HashSet (java.util.HashSet)3 LoanActivityEntity (org.mifos.accounts.loan.business.LoanActivityEntity)3 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)3 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)3 MessageLookup (org.mifos.application.master.MessageLookup)3 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)3 IncludePage (freemarker.ext.servlet.IncludePage)2 Date (java.util.Date)2