Search in sources :

Example 6 with CenterCreation

use of org.mifos.dto.domain.CenterCreation 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 7 with CenterCreation

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

the class CenterCustAction method load.

@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    actionForm.clearActionFormFields();
    SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request);
    UserContext userContext = getUserContext(request);
    CenterCreation centerCreationDto = new CenterCreation(actionForm.getOfficeIdValue(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
    CenterFormCreationDto centerFormCreation = this.centerServiceFacade.retrieveCenterFormCreationData(centerCreationDto);
    //        SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<Serializable>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerFormCreation.getActiveLoanOfficersForBranch(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, centerFormCreation.getAdditionalFees(), request);
    //        actionForm.setCustomFields(centerFormCreation.getCustomFieldViews());
    actionForm.setDefaultFees(centerFormCreation.getDefaultFees());
    DateTime today = new DateTime().toDateMidnight().toDateTime();
    actionForm.setMfiJoiningDate(today.getDayOfMonth(), today.getMonthOfYear(), today.getYear());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) UserContext(org.mifos.security.util.UserContext) CenterCreation(org.mifos.dto.domain.CenterCreation) CenterFormCreationDto(org.mifos.dto.screen.CenterFormCreationDto) DateTime(org.joda.time.DateTime) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with CenterCreation

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

the class CenterServiceFacadeWebTier method retrieveCenterDetailsForUpdate.

@Override
public CenterDto retrieveCenterDetailsForUpdate(Integer centerId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO center = customerDao.findCustomerById(centerId);
    Short officeId = center.getOffice().getOfficeId();
    String searchId = center.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(center);
    CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
    List<PersonnelDto> activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
    List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(center, userContext.getLocaleId());
    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (center.getMfiJoiningDate() != null) {
        mfiJoiningDate = new DateTime(center.getMfiJoiningDate());
        mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), center.getMfiJoiningDate().toString());
    }
    AddressDto address = null;
    if (center.getAddress() != null) {
        address = Address.toDto(center.getAddress());
    }
    return new CenterDto(loanOfficerId, center.getCustomerId(), center.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, center.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, true);
}
Also used : UserContext(org.mifos.security.util.UserContext) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) CenterDto(org.mifos.dto.domain.CenterDto) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CenterCreation(org.mifos.dto.domain.CenterCreation) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 9 with CenterCreation

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

the class ClientServiceFacadeWebTier method retrieveClientFormCreationData.

@Override
public ClientFormCreationDto retrieveClientFormCreationData(Short groupFlag, Short officeId, String parentGroupId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
    MeetingBO parentCustomerMeeting = null;
    Short formedByPersonnelId = null;
    String formedByPersonnelName = "";
    String centerDisplayName = "";
    String groupDisplayName = "";
    String officeName = "";
    List<FeeBO> fees = new ArrayList<FeeBO>();
    Short applicableOfficeId = officeId;
    if (YesNoFlag.YES.getValue().equals(groupFlag)) {
        Integer parentCustomerId = Integer.valueOf(parentGroupId);
        CustomerBO parentCustomer = this.customerDao.findCustomerById(parentCustomerId);
        groupDisplayName = parentCustomer.getDisplayName();
        if (parentCustomer.getPersonnel() != null) {
            formedByPersonnelId = parentCustomer.getPersonnel().getPersonnelId();
            formedByPersonnelName = parentCustomer.getPersonnel().getDisplayName();
        }
        if (parentCustomer.getParentCustomer() != null) {
            centerDisplayName = parentCustomer.getParentCustomer().getDisplayName();
        }
        applicableOfficeId = parentCustomer.getOffice().getOfficeId();
        officeName = parentCustomer.getOffice().getOfficeName();
        if (parentCustomer.getCustomerMeeting() != null) {
            parentCustomerMeeting = parentCustomer.getCustomerMeetingValue();
            fees = this.customerDao.retrieveFeesApplicableToClientsRefinedBy(parentCustomer.getCustomerMeetingValue());
        } else {
            fees = this.customerDao.retrieveFeesApplicableToClients();
        }
    } else if (YesNoFlag.NO.getValue().equals(groupFlag)) {
        CenterCreation centerCreation = new CenterCreation(applicableOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
        fees = this.customerDao.retrieveFeesApplicableToClients();
    }
    CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    List<ApplicableAccountFeeDto> defaultFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getDefaultFees()) {
        defaultFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<ApplicableAccountFeeDto> additionalFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getAdditionalFees()) {
        additionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<SavingsDetailDto> savingsOfferings = this.customerDao.retrieveSavingOfferingsApplicableToClient();
    ClientRulesDto clientRules = retrieveClientRules();
    ClientDropdownsDto clientDropdowns = retrieveClientDropdownData();
    List<PersonnelDto> formedByPersonnel = this.customerDao.findLoanOfficerThatFormedOffice(applicableOfficeId);
    MeetingDto parentMeeting = null;
    if (parentCustomerMeeting != null) {
        parentMeeting = parentCustomerMeeting.toDto();
    }
    return new ClientFormCreationDto(clientDropdowns, clientRules, applicableOfficeId, officeName, formedByPersonnelId, formedByPersonnelName, personnelList, formedByPersonnel, savingsOfferings, parentMeeting, centerDisplayName, groupDisplayName, additionalFees, defaultFees);
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) 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) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreation(org.mifos.dto.domain.CenterCreation) ClientRulesDto(org.mifos.dto.domain.ClientRulesDto) CustomerBO(org.mifos.customers.business.CustomerBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) ClientFormCreationDto(org.mifos.dto.screen.ClientFormCreationDto) ClientDropdownsDto(org.mifos.dto.screen.ClientDropdownsDto)

Aggregations

CenterCreation (org.mifos.dto.domain.CenterCreation)9 UserContext (org.mifos.security.util.UserContext)9 PersonnelDto (org.mifos.dto.domain.PersonnelDto)8 MifosUser (org.mifos.security.MifosUser)8 ArrayList (java.util.ArrayList)5 DateTime (org.joda.time.DateTime)3 CustomerBO (org.mifos.customers.business.CustomerBO)3 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)3 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 FeeDto (org.mifos.accounts.fees.business.FeeDto)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 AddressDto (org.mifos.dto.domain.AddressDto)2 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)2 CenterDto (org.mifos.dto.domain.CenterDto)2 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)2 CustomerDto (org.mifos.dto.domain.CustomerDto)2 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)2 ChangeAccountStatusDto (org.mifos.dto.screen.ChangeAccountStatusDto)2