Search in sources :

Example 86 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate 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 87 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class ReverseLoanDisbursalAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("Inside update method");
    ReverseLoanDisbursalActionForm actionForm = (ReverseLoanDisbursalActionForm) form;
    LoanBO loan = (LoanBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    this.loanAccountServiceFacade.reverseLoanDisbursal(loan.getGlobalAccountNum(), actionForm.getNote());
    if (loan.isGroupLoanAccountParent()) {
        for (LoanBO member : loan.getMemberAccounts()) {
            this.loanAccountServiceFacade.reverseLoanDisbursal(member.getGlobalAccountNum(), actionForm.getNote());
        }
    }
    logger.debug("Outside update method");
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : ReverseLoanDisbursalActionForm(org.mifos.accounts.loan.struts.actionforms.ReverseLoanDisbursalActionForm) LoanBO(org.mifos.accounts.loan.business.LoanBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 88 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class AccountStatusAction method searchResults.

@TransactionDemarcate(joinToken = true)
public ActionForward searchResults(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse httpservletresponse) throws Exception {
    AccountStatusActionForm accountStatusActionForm = (AccountStatusActionForm) form;
    List<LoanBO> searchResults = loanService.getSearchResults(accountStatusActionForm.getOfficeId(), accountStatusActionForm.getPersonnelId(), accountStatusActionForm.getCurrentStatus());
    if (searchResults.size() == 0) {
        return mapping.findForward(ActionForwards.noresultfound.toString());
    }
    SessionUtils.setCollectionAttribute(LoanConstants.SEARCH_RESULTS, searchResults, request);
    return mapping.findForward(ActionForwards.changeAccountStatusSearch_success.toString());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountStatusActionForm(org.mifos.accounts.loan.struts.actionforms.AccountStatusActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 89 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class AccountStatusAction method getLoanOfficers.

@TransactionDemarcate(joinToken = true)
public ActionForward getLoanOfficers(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse httpservletresponse) throws Exception {
    AccountStatusActionForm accountStatusActionForm = (AccountStatusActionForm) form;
    Short officeId = Short.valueOf(accountStatusActionForm.getOfficeId());
    ChangeAccountStatusDto changeAccountStatusDto = this.loanAccountServiceFacade.retrieveLoanOfficerDetailsForBranch(officeId);
    SessionUtils.setCollectionAttribute(LoanConstants.LOAN_OFFICERS, changeAccountStatusDto.getLoanOfficers(), request);
    if (officeId != null) {
        AccountStateEntity accountStateEntity = legacyMasterDao.getPersistentObject(AccountStateEntity.class, changeAccountStatusDto.getAccountState());
        SessionUtils.setAttribute(LoanConstants.LOANACCOUNTSTAES, accountStateEntity, request);
    }
    return mapping.findForward(ActionForwards.changeAccountStatus_success.toString());
}
Also used : ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) AccountStatusActionForm(org.mifos.accounts.loan.struts.actionforms.AccountStatusActionForm) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 90 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class AccountStatusAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse httpservletresponse) throws Exception {
    AccountStatusActionForm accountStatusActionForm = (AccountStatusActionForm) form;
    List<AccountUpdateStatus> accountsForUpdate = new ArrayList<AccountUpdateStatus>();
    List<AccountUpdateStatus> individualAccountsForUpdate = new ArrayList<AccountUpdateStatus>();
    for (String accountId : accountStatusActionForm.getAccountRecords()) {
        if (StringUtils.isNotBlank(accountId)) {
            Long accountIdValue = Long.parseLong(accountId);
            //GLIM
            List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(Integer.valueOf(accountId));
            for (LoanBO indivdual : individualLoans) {
                Short newStatusId = getShortValue(accountStatusActionForm.getNewStatus());
                individualAccountsForUpdate.add(new AccountUpdateStatus(indivdual.getAccountId().longValue(), newStatusId, null, accountStatusActionForm.getComments()));
            }
            this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(individualAccountsForUpdate, null);
            Short newStatusId = getShortValue(accountStatusActionForm.getNewStatus());
            Short flagId = null;
            String comment = accountStatusActionForm.getComments();
            accountsForUpdate.add(new AccountUpdateStatus(accountIdValue, newStatusId, flagId, comment));
        }
    }
    List<String> accountNumbers = this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(accountsForUpdate, null);
    request.setAttribute(LoanConstants.ACCOUNTS_LIST, accountNumbers);
    return mapping.findForward(ActionForwards.changeAccountStatusConfirmation_success.toString());
}
Also used : AccountUpdateStatus(org.mifos.dto.domain.AccountUpdateStatus) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountStatusActionForm(org.mifos.accounts.loan.struts.actionforms.AccountStatusActionForm) ArrayList(java.util.ArrayList) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)259 UserContext (org.mifos.security.util.UserContext)72 ArrayList (java.util.ArrayList)41 CloseSession (org.mifos.framework.util.helpers.CloseSession)35 LoanBO (org.mifos.accounts.loan.business.LoanBO)26 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)21 CustomerBO (org.mifos.customers.business.CustomerBO)20 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)19 AccountBO (org.mifos.accounts.business.AccountBO)18 ApplicationException (org.mifos.framework.exceptions.ApplicationException)17 ActionErrors (org.apache.struts.action.ActionErrors)14 LocalDate (org.joda.time.LocalDate)14 AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)13 List (java.util.List)12 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)12 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 ActionForward (org.apache.struts.action.ActionForward)11