Search in sources :

Example 1 with CenterCreation

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

the class ClientServiceFacadeWebTier method retrieveMfiInfoForEdit.

@Override
public ClientMfiInfoDto retrieveMfiInfoForEdit(String clientSystemId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
    String groupDisplayName = "";
    String centerDisplayName = "";
    if (client.getParentCustomer() != null) {
        groupDisplayName = client.getParentCustomer().getDisplayName();
        if (client.getParentCustomer().getParentCustomer() != null) {
            centerDisplayName = client.getParentCustomer().getParentCustomer().getDisplayName();
        }
    }
    List<PersonnelDto> loanOfficersList = new ArrayList<PersonnelDto>();
    if (!client.isClientUnderGroup()) {
        CenterCreation centerCreation = new CenterCreation(client.getOffice().getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        loanOfficersList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    }
    CustomerDetailDto customerDetail = client.toCustomerDetailDto();
    ClientDetailDto clientDetail = client.toClientDetailDto(ClientRules.isFamilyDetailsRequired());
    return new ClientMfiInfoDto(groupDisplayName, centerDisplayName, loanOfficersList, customerDetail, clientDetail);
}
Also used : UserContext(org.mifos.security.util.UserContext) CenterCreation(org.mifos.dto.domain.CenterCreation) ClientBO(org.mifos.customers.client.business.ClientBO) ClientDetailDto(org.mifos.dto.screen.ClientDetailDto) ArrayList(java.util.ArrayList) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) ClientMfiInfoDto(org.mifos.dto.screen.ClientMfiInfoDto)

Example 2 with CenterCreation

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

the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.

@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
        client.updateDetails(userContext);
        client.checkIfClientIsATitleHolder();
        List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
        boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
        boolean isActive = client.isActive();
        Short loanOfficerId = client.getPersonnel().getPersonnelId();
        CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
        return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ClientRemovalFromGroupDto(org.mifos.dto.screen.ClientRemovalFromGroupDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) BusinessRuleException(org.mifos.service.BusinessRuleException) CenterCreation(org.mifos.dto.domain.CenterCreation)

Example 3 with CenterCreation

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

the class LoanAccountServiceFacadeWebTier method retrieveAllActiveBranchesAndLoanOfficerDetails.

@Override
public ChangeAccountStatusDto retrieveAllActiveBranchesAndLoanOfficerDetails() {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    List<PersonnelDto> loanOfficers = new ArrayList<PersonnelDto>();
    List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
    if (onlyOneActiveBranchExists(activeBranches)) {
        OfficeDetailsDto singleOffice = activeBranches.get(0);
        CenterCreation officeDetails = new CenterCreation(singleOffice.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(officeDetails);
    }
    boolean loanPendingApprovalStateEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
    Short accountState = AccountState.LOAN_PARTIAL_APPLICATION.getValue();
    if (loanPendingApprovalStateEnabled) {
        accountState = AccountState.LOAN_PENDING_APPROVAL.getValue();
    }
    boolean centerHierarchyExists = ClientRules.getCenterHierarchyExists();
    return new ChangeAccountStatusDto(activeBranches, loanOfficers, loanPendingApprovalStateEnabled, accountState, centerHierarchyExists);
}
Also used : ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) UserContext(org.mifos.security.util.UserContext) CenterCreation(org.mifos.dto.domain.CenterCreation) ArrayList(java.util.ArrayList) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Example 4 with CenterCreation

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

the class LoanAccountServiceFacadeWebTier method retrieveLoanOfficerDetailsForBranch.

@Override
public ChangeAccountStatusDto retrieveLoanOfficerDetailsForBranch(Short officeId) {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    CenterCreation officeDetails = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
    List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(officeDetails);
    boolean loanPendingApprovalStateEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
    Short accountState = AccountState.LOAN_PARTIAL_APPLICATION.getValue();
    if (loanPendingApprovalStateEnabled) {
        accountState = AccountState.LOAN_PENDING_APPROVAL.getValue();
    }
    boolean centerHierarchyExists = ClientRules.getCenterHierarchyExists();
    return new ChangeAccountStatusDto(new ArrayList<OfficeDetailsDto>(), loanOfficers, loanPendingApprovalStateEnabled, accountState, centerHierarchyExists);
}
Also used : ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) UserContext(org.mifos.security.util.UserContext) CenterCreation(org.mifos.dto.domain.CenterCreation) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Example 5 with CenterCreation

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

the class GroupServiceFacadeWebTier method retrieveGroupDetailsForUpdate.

@Override
public CenterDto retrieveGroupDetailsForUpdate(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    List<PersonnelDto> activeLoanOfficersForBranch = new ArrayList<PersonnelDto>();
    GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
    Short officeId = group.getOffice().getOfficeId();
    String searchId = group.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(group);
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (!isCenterHierarchyExists) {
        CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    }
    List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
    List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(group, userContext.getLocaleId());
    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (group.getMfiJoiningDate() != null) {
        mfiJoiningDate = new DateTime(group.getMfiJoiningDate());
        mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), group.getMfiJoiningDate().toString());
    }
    AddressDto address = null;
    if (group.getAddress() != null) {
        address = Address.toDto(group.getAddress());
    }
    return new CenterDto(loanOfficerId, group.getCustomerId(), group.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, group.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, isCenterHierarchyExists);
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) 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) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

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