Search in sources :

Example 81 with TransactionDemarcate

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

the class LoanAccountAction method getLoanRepaymentSchedule.

@TransactionDemarcate(saveToken = true)
public ActionForward getLoanRepaymentSchedule(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanAccountActionForm loanAccountActionForm = (LoanAccountActionForm) form;
    UserContext userContext = getUserContext(request);
    Integer loanId = Integer.valueOf(request.getParameter(ACCOUNT_ID));
    Locale locale = userContext.getPreferredLocale();
    Date viewDate = loanAccountActionForm.getScheduleViewDateValue(locale);
    LoanBO loan = getLoan(loanId);
    setSessionAtributeForGLIM(request, loan);
    loan.updateDetails(userContext);
    Errors errors = loanBusinessService.computeExtraInterest(loan, viewDate);
    if (errors.hasErrors()) {
        loanAccountActionForm.resetScheduleViewDate();
    }
    OriginalScheduleInfoDto originalSchedule = this.loanServiceFacade.retrieveOriginalLoanSchedule(loanId);
    String memberAccountIdParam = request.getParameter("memberAccountId");
    if (StringUtils.isNotBlank(memberAccountIdParam)) {
        Integer memberId = Integer.valueOf(memberAccountIdParam);
        LoanBO member = loan.findMemberById(memberId);
        if (member != null) {
            SessionUtils.setAttribute(CustomerConstants.CUSTOMER_NAME, member.getCustomer().getDisplayName(), request);
            SessionUtils.setAttribute(CustomerConstants.GLOBAL_CUST_NUM, member.getCustomer().getGlobalCustNum(), request);
        }
    }
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
    SessionUtils.setAttribute(Constants.ORIGINAL_SCHEDULE_AVAILABLE, originalSchedule.hasOriginalInstallments(), request);
    SessionUtils.setAttribute(Constants.VIEW_DATE, viewDate, request);
    String forward = errors.hasErrors() ? ActionForwards.getLoanRepaymentScheduleFailure.toString() : ActionForwards.getLoanRepaymentSchedule.toString();
    addErrors(request, getActionErrors(errors));
    return mapping.findForward(forward);
}
Also used : Locale(java.util.Locale) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) ActionErrors(org.apache.struts.action.ActionErrors) Errors(org.mifos.platform.validations.Errors) UserContext(org.mifos.security.util.UserContext) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.util.Date) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 82 with TransactionDemarcate

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

the class LoanAccountAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanAccountActionForm loanActionForm = (LoanAccountActionForm) form;
    String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
    CustomerBO customer = getCustomerFromRequest(request);
    if (isGlimEnabled() || isNewGlimEnabled()) {
        populateGlimAttributes(request, loanActionForm, globalAccountNum, customer);
    }
    String recurMonth = customer.getCustomerMeeting().getMeeting().getMeetingDetails().getRecurAfter().toString();
    handleRepaymentsIndependentOfMeetingIfConfigured(request, loanActionForm, recurMonth);
    LoanBO loanBO = new LoanDaoHibernate(new GenericDaoHibernate()).findByGlobalAccountNum(globalAccountNum);
    UserContext userContext = getUserContext(request);
    loanBO.setUserContext(userContext);
    SessionUtils.setAttribute(PROPOSED_DISBURSAL_DATE, loanBO.getDisbursementDate(), request);
    SessionUtils.removeAttribute(LOANOFFERING, request);
    LoanOfferingBO loanOffering = getLoanOffering(loanBO.getLoanOffering().getPrdOfferingId(), userContext.getLocaleId());
    loanActionForm.setInstallmentRange(loanBO.getMaxMinNoOfInstall());
    loanActionForm.setLoanAmountRange(loanBO.getMaxMinLoanAmount());
    MaxMinInterestRate interestRateRange = loanBO.getMaxMinInterestRate();
    loanActionForm.setMaxInterestRate(interestRateRange.getMaxLoanAmount());
    loanActionForm.setMinInterestRate(interestRateRange.getMinLoanAmount());
    loanActionForm.setExternalId(loanBO.getExternalId());
    if (null != loanBO.getFund()) {
        loanActionForm.setLoanOfferingFund(loanBO.getFund().getFundId().toString());
    }
    if (configService.isRepaymentIndepOfMeetingEnabled()) {
        MeetingDetailsEntity meetingDetail = loanBO.getLoanMeeting().getMeetingDetails();
        loanActionForm.setMonthDay("");
        loanActionForm.setMonthWeek("0");
        loanActionForm.setMonthRank("0");
        if (meetingDetail.getRecurrenceTypeEnum() == RecurrenceType.MONTHLY) {
            setMonthlySchedule(loanActionForm, meetingDetail);
        } else {
            setWeeklySchedule(loanActionForm, meetingDetail);
        }
    }
    setSessionAtributeForGLIM(request, loanBO);
    SessionUtils.setAttribute(LOANOFFERING, loanOffering, 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.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, legacyMasterDao.findValueListElements(MasterConstants.LOAN_PURPOSES), request);
    SessionUtils.setCollectionAttribute(CUSTOM_FIELDS, new ArrayList<CustomFieldDefinitionEntity>(), request);
    SessionUtils.setAttribute(RECURRENCEID, loanBO.getLoanMeeting().getMeetingDetails().getRecurrenceTypeEnum().getValue(), request);
    SessionUtils.setAttribute(RECURRENCENAME, loanBO.getLoanMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceName(), request);
    SessionUtils.setCollectionAttribute(LOANFUNDS, getFunds(loanOffering), request);
    setRequestAttributesForEditPage(request, loanBO);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.setCollectionAttribute("detailsInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateLoan"), request);
    setFormAttributes(loanBO, form, request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) MaxMinInterestRate(org.mifos.accounts.loan.business.MaxMinInterestRate) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) LoanDaoHibernate(org.mifos.accounts.loan.persistance.LoanDaoHibernate) MeetingDetailsEntity(org.mifos.application.meeting.business.MeetingDetailsEntity) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) CustomerBO(org.mifos.customers.business.CustomerBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 83 with TransactionDemarcate

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

the class LoanAccountAction method viewStatusHistory.

@TransactionDemarcate(joinToken = true)
public ActionForward viewStatusHistory(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    UserContext userContext = getUserContext(request);
    String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
    LoanBO loan = this.loanDao.findByGlobalAccountNum(globalAccountNum);
    loan.updateDetails(userContext);
    List<AccountStatusChangeHistoryEntity> accStatusChangeHistory = new ArrayList<AccountStatusChangeHistoryEntity>(loan.getAccountStatusChangeHistory());
    SessionUtils.setCollectionAttribute(STATUS_HISTORY, accStatusChangeHistory, request);
    return mapping.findForward(ActionForwards.viewStatusHistory.toString());
}
Also used : UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) AccountStatusChangeHistoryEntity(org.mifos.accounts.business.AccountStatusChangeHistoryEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 84 with TransactionDemarcate

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

the class LoanAccountAction method getInstallmentDetails.

@TransactionDemarcate(joinToken = true)
public ActionForward getInstallmentDetails(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    Integer accountId = Integer.valueOf(request.getParameter(ACCOUNT_ID));
    LoanInstallmentDetailsDto loanInstallmentDetailsDto = this.loanAccountServiceFacade.retrieveInstallmentDetails(accountId);
    SessionUtils.setAttribute(VIEW_UPCOMING_INSTALLMENT_DETAILS, loanInstallmentDetailsDto.getUpcomingInstallmentDetails(), request);
    SessionUtils.setAttribute(VIEW_OVERDUE_INSTALLMENT_DETAILS, loanInstallmentDetailsDto.getOverDueInstallmentDetails(), request);
    SessionUtils.setAttribute(TOTAL_AMOUNT_OVERDUE, loanInstallmentDetailsDto.getTotalAmountDue(), request);
    SessionUtils.setAttribute(NEXTMEETING_DATE, loanInstallmentDetailsDto.getNextMeetingDate(), request);
    if (null == this.loanDao.findById(accountId).getParentAccount() && this.loanDao.findById(accountId).isGroupLoanAccount()) {
        SessionUtils.setAttribute("isNewGlim", "isNewGlim", request);
    }
    return mapping.findForward(VIEWINSTALLMENTDETAILS_SUCCESS);
}
Also used : LoanInstallmentDetailsDto(org.mifos.dto.domain.LoanInstallmentDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 85 with TransactionDemarcate

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

the class LoanAccountAction method viewOriginalSchedule.

@TransactionDemarcate(joinToken = true)
public ActionForward viewOriginalSchedule(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    UserContext userContext = getUserContext(request);
    Integer loanId = Integer.valueOf(request.getParameter(ACCOUNT_ID));
    LoanBO loan = (LoanBO) SessionUtils.getAttribute(BUSINESS_KEY, request);
    boolean originalSchedule = (request.getParameter("individual") == null ? true : false);
    OriginalScheduleInfoDto dto = loanServiceFacade.retrieveOriginalLoanSchedule(loanId);
    SessionUtils.setAttribute("originalSchedule", originalSchedule, request);
    SessionUtils.setAttribute(CustomerConstants.DISBURSEMENT_DATE, dto.getDisbursementDate(), request);
    SessionUtils.setAttribute(CustomerConstants.LOAN_AMOUNT, dto.getLoanAmount(), request);
    SessionUtils.setCollectionAttribute(LoanConstants.ORIGINAL_INSTALLMENTS, dto.getOriginalLoanScheduleInstallment(), request);
    return mapping.findForward(ActionForwards.viewOriginalSchedule.name());
}
Also used : UserContext(org.mifos.security.util.UserContext) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) 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