Search in sources :

Example 31 with CustomerBO

use of org.mifos.customers.business.CustomerBO 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 32 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class LoanAccountAction method performGlimSpecificOnManagePreview.

private void performGlimSpecificOnManagePreview(final HttpServletRequest request, final LoanAccountActionForm loanAccountForm) throws PageExpiredException {
    CustomerBO customer = getCustomer(loanAccountForm.getCustomerIdValue());
    setGlimEnabledSessionAttributes(request, customer.isGroup());
    if (customer.isGroup()) {
        List<LoanAccountDetailsDto> loanAccountDetailsView = populateDetailsForSelectedClients(loanAccountForm.getClientDetails(), loanAccountForm.getClients());
        SessionUtils.setCollectionAttribute("loanAccountDetailsView", loanAccountDetailsView, request);
    }
}
Also used : CustomerBO(org.mifos.customers.business.CustomerBO) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto)

Example 33 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class CustomerApplyAdjustmentAction method applyAdjustment.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String forward = null;
    request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_APPLY_ADJUSTMENT);
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
        throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
    }
    try {
        this.centerServiceFacade.revertLastChargesPayment(globalCustNum, applyAdjustmentActionForm.getAdjustmentNote());
    } catch (BusinessRuleException e) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
        throw e;
    }
    String inputPage = applyAdjustmentActionForm.getInput();
    resetActionFormFields(applyAdjustmentActionForm);
    if (inputPage != null) {
        if (inputPage.equals(CustomerConstants.VIEW_GROUP_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_GROUP_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CENTER_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_CENTER_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CLIENT_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_CLIENT_SUCCESS;
        }
    }
    return mapping.findForward(forward);
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 34 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class CustomerApplyAdjustmentAction method loadAdjustment.

@TransactionDemarcate(joinToken = true)
public ActionForward loadAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    resetActionFormFields(applyAdjustmentActionForm);
    String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_LOAD_ADJUSTMENT);
    if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
        request.setAttribute("isDisabled", "true");
        throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
    }
    return mapping.findForward(CustomerConstants.METHOD_LOAD_ADJUSTMENT_SUCCESS);
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 35 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class EditCustomerStatusAction method loadStatus.

@TransactionDemarcate(joinToken = true)
public ActionForward loadStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In EditCustomerStatusAction:load()");
    EditCustomerStatusActionForm editCustomerStatusActionForm = (EditCustomerStatusActionForm) form;
    editCustomerStatusActionForm.clear();
    UserContext userContext = getUserContext(request);
    Integer customerId = editCustomerStatusActionForm.getCustomerIdValue();
    CustomerBO customer = this.customerDao.findCustomerById(customerId);
    customer.setUserContext(userContext);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
    List<CustomerStatusEntity> statusList = new ArrayList<CustomerStatusEntity>();
    switch(customer.getLevel()) {
        case CENTER:
            this.centerServiceFacade.initializeCenterStates(customer.getGlobalCustNum());
            statusList = AccountStateMachines.getInstance().getCenterStatusList(customer.getCustomerStatus());
            editCustomerStatusActionForm.setInput("center");
            break;
        case GROUP:
            this.centerServiceFacade.initializeGroupStates(customer.getGlobalCustNum());
            statusList = AccountStateMachines.getInstance().getGroupStatusList(customer.getCustomerStatus());
            editCustomerStatusActionForm.setInput("group");
            break;
        case CLIENT:
            this.centerServiceFacade.initializeClientStates(customer.getGlobalCustNum());
            statusList = AccountStateMachines.getInstance().getClientStatusList(customer.getCustomerStatus());
            editCustomerStatusActionForm.setInput("client");
            break;
        default:
            break;
    }
    ;
    for (CustomerStatusEntity customerStatusEntity : statusList) {
        for (CustomerStatusFlagEntity flag : customerStatusEntity.getFlagSet()) {
            String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
            flag.setStatusFlagMessageText(statusMessageText);
        }
    }
    editCustomerStatusActionForm.setLevelId(customer.getCustomerLevel().getId().toString());
    editCustomerStatusActionForm.setCurrentStatusId(customer.getCustomerStatus().getId().toString());
    editCustomerStatusActionForm.setGlobalAccountNum(customer.getGlobalCustNum());
    editCustomerStatusActionForm.setCustomerName(customer.getDisplayName());
    SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, statusList, request);
    return mapping.findForward(ActionForwards.loadStatus_success.toString());
}
Also used : EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) UserContext(org.mifos.security.util.UserContext) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CustomerBO (org.mifos.customers.business.CustomerBO)138 ArrayList (java.util.ArrayList)39 Money (org.mifos.framework.util.helpers.Money)38 MifosUser (org.mifos.security.MifosUser)38 UserContext (org.mifos.security.util.UserContext)37 LocalDate (org.joda.time.LocalDate)35 MifosRuntimeException (org.mifos.core.MifosRuntimeException)31 AccountException (org.mifos.accounts.exceptions.AccountException)30 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)27 BusinessRuleException (org.mifos.service.BusinessRuleException)27 MeetingBO (org.mifos.application.meeting.business.MeetingBO)23 ClientBO (org.mifos.customers.client.business.ClientBO)23 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 DateTime (org.joda.time.DateTime)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)20 Date (java.util.Date)19 Test (org.junit.Test)19 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)18 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 HashMap (java.util.HashMap)15