Search in sources :

Example 1 with GroupFormCreationDto

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

the class GroupServiceFacadeWebTier method retrieveGroupFormCreationData.

@Override
public GroupFormCreationDto retrieveGroupFormCreationData(GroupCreation groupCreation) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO parentCustomer = null;
    Short parentOfficeId = groupCreation.getOfficeId();
    CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.empty();
    List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
    CenterCreation centerCreation;
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (isCenterHierarchyExists) {
        parentCustomer = this.customerDao.findCenterBySystemId(groupCreation.getParentSystemId());
        parentOfficeId = parentCustomer.getOffice().getOfficeId();
        centerCreation = new CenterCreation(parentOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        MeetingBO customerMeeting = parentCustomer.getCustomerMeetingValue();
        List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroupsRefinedBy(customerMeeting);
        applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    } else {
        centerCreation = new CenterCreation(groupCreation.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
        List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroups();
        applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    }
    List<ApplicableAccountFeeDto> applicableDefaultAccountFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getDefaultFees()) {
        applicableDefaultAccountFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<ApplicableAccountFeeDto> applicableDefaultAdditionalFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getAdditionalFees()) {
        applicableDefaultAdditionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<PersonnelDto> formedByPersonnel = customerDao.findLoanOfficerThatFormedOffice(centerCreation.getOfficeId());
    return new GroupFormCreationDto(isCenterHierarchyExists, personnelList, formedByPersonnel, applicableDefaultAccountFees, applicableDefaultAdditionalFees);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) GroupFormCreationDto(org.mifos.dto.domain.GroupFormCreationDto) CenterCreation(org.mifos.dto.domain.CenterCreation) CustomerBO(org.mifos.customers.business.CustomerBO) FeeBO(org.mifos.accounts.fees.business.FeeBO)

Example 2 with GroupFormCreationDto

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

the class GroupCustAction method load.

@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    actionForm.cleanForm();
    SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request.getSession());
    GroupCreation groupCreation = null;
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (isCenterHierarchyExists) {
        String centerSystemId = actionForm.getCenterSystemId();
        CenterBO center = this.customerDao.findCenterBySystemId(centerSystemId);
        groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), centerSystemId);
        // inherit these settings from center/parent if center hierarchy is configured
        actionForm.setParentCustomer(center);
        actionForm.setOfficeId(center.getOfficeId().toString());
        actionForm.setFormedByPersonnel(center.getLoanOfficerId().toString());
    } else {
        groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), "");
    }
    GroupFormCreationDto groupFormCreationDto = this.groupServiceFacade.retrieveGroupFormCreationData(groupCreation);
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    actionForm.setDefaultFees(groupFormCreationDto.getDefaultFees());
    SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, groupFormCreationDto.getAdditionalFees(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, groupFormCreationDto.getPersonnelList(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.FORMEDBY_LOAN_OFFICER_LIST, groupFormCreationDto.getFormedByPersonnel(), request);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, groupFormCreationDto.isCenterHierarchyExists(), request);
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : GroupFormCreationDto(org.mifos.dto.domain.GroupFormCreationDto) GroupCreation(org.mifos.dto.domain.GroupCreation) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CenterBO(org.mifos.customers.center.business.CenterBO) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

GroupFormCreationDto (org.mifos.dto.domain.GroupFormCreationDto)2 ArrayList (java.util.ArrayList)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 FeeDto (org.mifos.accounts.fees.business.FeeDto)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)1 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)1 CenterCreation (org.mifos.dto.domain.CenterCreation)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 GroupCreation (org.mifos.dto.domain.GroupCreation)1 PersonnelDto (org.mifos.dto.domain.PersonnelDto)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1