Search in sources :

Example 1 with CustomerPositionDto

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

the class CenterServiceFacadeWebTier method generatePositionsFromExistingCustomerPositions.

private void generatePositionsFromExistingCustomerPositions(CustomerBO customer, List<PositionEntity> customerPositions, List<CustomerPositionDto> customerPositionDtos) {
    for (PositionEntity position : customerPositions) {
        for (CustomerPositionEntity entity : customer.getCustomerPositions()) {
            if (position.getId().equals(entity.getPosition().getId())) {
                CustomerPositionDto customerPosition;
                if (entity.getCustomer() != null) {
                    customerPosition = new CustomerPositionDto(entity.getCustomer().getCustomerId(), entity.getPosition().getId(), entity.getPosition().getName());
                } else {
                    customerPosition = new CustomerPositionDto(customer.getCustomerId(), entity.getPosition().getId(), entity.getPosition().getName());
                }
                customerPositionDtos.add(customerPosition);
            }
        }
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 2 with CustomerPositionDto

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

the class GroupCustActionForm method cleanForm.

public void cleanForm() {
    setDefaultFees(new ArrayList<ApplicableAccountFeeDto>());
    setAdditionalFees(new ArrayList<ApplicableAccountFeeDto>());
    setCustomerPositions(new ArrayList<CustomerPositionDto>());
    setCustomFields(new ArrayList<CustomFieldDto>());
    setAddress(new Address());
    setDisplayName(null);
    setMfiJoiningDate(null);
    setGlobalCustNum(null);
    setCustomerId(null);
    setExternalId(null);
    setLoanOfficerId(null);
    setTrained(null);
    setTrainedDate(null);
    setFormedByPersonnel(null);
    setQuestionGroups(null);
}
Also used : Address(org.mifos.framework.business.util.Address) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto)

Example 3 with CustomerPositionDto

use of org.mifos.dto.domain.CustomerPositionDto 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)

Example 4 with CustomerPositionDto

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

the class CenterCustActionForm method clearActionFormFields.

public void clearActionFormFields() {
    setDefaultFees(new ArrayList<ApplicableAccountFeeDto>());
    setAdditionalFees(new ArrayList<ApplicableAccountFeeDto>());
    setCustomerPositions(new ArrayList<CustomerPositionDto>());
    setCustomFields(new ArrayList<CustomFieldDto>());
    setAddress(new Address());
    setDisplayName(null);
    setMfiJoiningDate(null);
    setGlobalCustNum(null);
    setCustomerId(null);
    setExternalId(null);
    setLoanOfficerId(null);
    setQuestionGroups(null);
}
Also used : Address(org.mifos.framework.business.util.Address) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto)

Example 5 with CustomerPositionDto

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

the class CenterUpdateUsingCustomerServiceIntegrationTest method canUpdateCenterWithDifferentLoanOfficer.

@Test
public void canUpdateCenterWithDifferentLoanOfficer() throws Exception {
    // setup
    String externalId = center.getExternalId();
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(center.getMfiJoiningDate());
    AddressDto address = null;
    if (center.getAddress() != null) {
        address = Address.toDto(center.getAddress());
    }
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    UserContext userContext = TestUtils.makeUser();
    otherLoanOfficer.setPreferredLocale(userContext.getLocaleId());
    IntegrationTestObjectMother.createPersonnel(otherLoanOfficer);
    String updatedDisplayName = "Center " + RandomStringUtils.randomAlphanumeric(5);
    CenterUpdate centerUpdate = new CenterUpdate(center.getCustomerId(), updatedDisplayName, center.getVersionNo(), otherLoanOfficer.getPersonnelId(), externalId, mfiJoiningDate, address, customFields, customerPositions);
    // exercise test
    customerService.updateCenter(userContext, centerUpdate);
    // verification
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    assertThat(center.getPersonnel().getDisplayName(), is(otherLoanOfficer.getDisplayName()));
}
Also used : CenterUpdate(org.mifos.dto.domain.CenterUpdate) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) AddressDto(org.mifos.dto.domain.AddressDto) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)15 AddressDto (org.mifos.dto.domain.AddressDto)8 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)8 ArrayList (java.util.ArrayList)7 UserContext (org.mifos.security.util.UserContext)7 SimpleDateFormat (java.text.SimpleDateFormat)6 CenterUpdate (org.mifos.dto.domain.CenterUpdate)6 Test (org.junit.Test)5 CustomerPositionEntity (org.mifos.customers.business.CustomerPositionEntity)5 PositionEntity (org.mifos.customers.business.PositionEntity)5 DateTime (org.joda.time.DateTime)2 LocalDate (org.joda.time.LocalDate)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)2 CenterCreation (org.mifos.dto.domain.CenterCreation)2 CenterDto (org.mifos.dto.domain.CenterDto)2 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)2 CustomerDto (org.mifos.dto.domain.CustomerDto)2 PersonnelDto (org.mifos.dto.domain.PersonnelDto)2 Address (org.mifos.framework.business.util.Address)2