Search in sources :

Example 6 with CustomerPositionDto

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

the class CenterUpdateUsingCustomerServiceIntegrationTest method canUpdateCenterWithExternalId.

@Test
public void canUpdateCenterWithExternalId() throws Exception {
    // setup
    Short loanOfficerId = center.getPersonnel().getPersonnelId();
    String newExternalId = "ext123";
    LocalDate dateInPast = new LocalDate(center.getMfiJoiningDate()).minusWeeks(4);
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(dateInPast.toDateMidnight().toDate());
    AddressDto newAddress = null;
    if (center.getAddress() != null) {
        newAddress = Address.toDto(center.getAddress());
    }
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    String updatedDisplayName = "Center " + RandomStringUtils.randomAlphanumeric(5);
    CenterUpdate centerUpdate = new CenterUpdate(center.getCustomerId(), updatedDisplayName, center.getVersionNo(), loanOfficerId, newExternalId, mfiJoiningDate, newAddress, customFields, customerPositions);
    UserContext userContext = TestUtils.makeUser();
    // exercise test
    customerService.updateCenter(userContext, centerUpdate);
    // verification
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    assertThat(center.getExternalId(), is(newExternalId));
}
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) LocalDate(org.joda.time.LocalDate) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 7 with CustomerPositionDto

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

the class CenterUpdateBuilder method build.

public CenterUpdate build() {
    int versionNum = 1;
    int customerId = -1;
    Short loanOfficerId = -1;
    String externalId = null;
    String updatedDisplayName = "Center " + RandomStringUtils.random(5);
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(new Date());
    AddressDto address = null;
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    return new CenterUpdate(customerId, updatedDisplayName, versionNum, loanOfficerId, externalId, mfiJoiningDate, address, customFields, customerPositions);
}
Also used : CenterUpdate(org.mifos.dto.domain.CenterUpdate) 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) Date(java.util.Date)

Example 8 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 9 with CustomerPositionDto

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

the class GroupServiceFacadeWebTier 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 10 with CustomerPositionDto

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

the class GroupServiceFacadeWebTier method generateNewListOfPositions.

private void generateNewListOfPositions(CustomerBO customer, List<PositionEntity> customerPositions, List<CustomerPositionDto> customerPositionDtos) {
    for (PositionEntity position : customerPositions) {
        CustomerPositionDto customerPosition = new CustomerPositionDto(customer.getCustomerId(), position.getId(), position.getName());
        customerPositionDtos.add(customerPosition);
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

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