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));
}
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);
}
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);
}
}
}
}
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);
}
}
}
}
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);
}
}
Aggregations