Search in sources :

Example 11 with CustomerDetailsDto

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

the class GroupServiceFacadeWebTierIntegrationTest method shouldTransferGroupFromOfficeToOffice.

@Test
public void shouldTransferGroupFromOfficeToOffice() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    ClientRules.setCenterHierarchyExists(false);
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId1 = branch1.getOfficeId();
    CustomerDetailsDto group1Details = createGroup("group1", officeId1);
    Short officeId2 = branch2.getOfficeId();
    CustomerDetailsDto group2Details = createGroup("group2", officeId2);
    CustomerDetailsDto newlyCreatedCustomerDetails = createClient(group1Details.getId().toString());
    GroupBO group1 = customerDao.findGroupBySystemId(group1Details.getGlobalCustNum());
    groupServiceFacade.transferGroupToBranch(group1Details.getGlobalCustNum(), officeId2, group1.getVersionNo());
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Example 12 with CustomerDetailsDto

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

the class GroupServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithActivationDateInPast.

@Test
public void shouldCreateGroupWithActivationDateInPast() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String displayName = "testGroup";
    String externalId = null;
    AddressDto addressDto = null;
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
    Short customerStatus = CustomerStatus.GROUP_ACTIVE.getValue();
    boolean trained = false;
    DateTime trainedOn = null;
    String parentSystemId = null;
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId = branch1.getOfficeId();
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    DateTime activationDate = new DateTime().minusWeeks(1);
    GroupCreationDetail groupCenterDetail = new GroupCreationDetail(displayName, externalId, addressDto, loanOfficerId, feesToApply, customerStatus, trained, trainedOn, parentSystemId, officeId, mfiJoiningDate, activationDate);
    // exercise test
    ClientRules.setCenterHierarchyExists(false);
    CustomerDetailsDto newlyCreatedGroupDetails = groupServiceFacade.createNewGroup(groupCenterDetail, meetingDto);
    // verification
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
    GroupBO group = customerDao.findGroupBySystemId(newlyCreatedGroupDetails.getGlobalCustNum());
    Assert.assertThat(new LocalDate(group.getCustomerActivationDate()), is(activationDate.toLocalDate()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Example 13 with CustomerDetailsDto

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

the class GroupServiceFacadeWebTierIntegrationTest method createClient.

private CustomerDetailsDto createClient(String parentGroupId) {
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String externalId = null;
    AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
    CustomerStatus.CLIENT_ACTIVE.getValue();
    boolean trained = false;
    // setup
    Short officeId = branch1.getOfficeId();
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    DateTime activationDate = new DateTime().minusWeeks(1);
    List<Short> selectedSavingProducts = new ArrayList<Short>();
    String clientName = "client";
    Short formedBy = loanOfficerId;
    Date dateOfBirth = new LocalDate(1990, 1, 1).toDateMidnight().toDate();
    String governmentId = "";
    Date trainedDate = new LocalDate(2000, 1, 1).toDateMidnight().toDate();
    ;
    // not in a group
    Short groupFlag = YesNoFlag.YES.getValue();
    Integer salutation = 1;
    String firstName = "first";
    String middleName = null;
    String lastName = "last";
    String secondLastName = null;
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, firstName, middleName, lastName, secondLastName);
    // magic numbers from default data
    Integer ethnicity = 218;
    Integer citizenship = 130;
    Integer handicapped = 138;
    Integer businessActivities = 225;
    Integer educationLevel = 226;
    Short numChildren = 0;
    Short gender = 49;
    Short povertyStatus = 41;
    Integer maritalStatus = ClientPersonalDetailDto.MARRIED;
    // active
    Short clientStatus = 3;
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethnicity, citizenship, handicapped, businessActivities, maritalStatus, educationLevel, numChildren, gender, povertyStatus);
    ClientNameDetailDto spouseFatherName = new ClientNameDetailDto(NameType.SPOUSE.getValue(), salutation, firstName, middleName, lastName, secondLastName);
    InputStream picture = null;
    List<ClientNameDetailDto> familyNames = null;
    List<ClientFamilyDetailDto> familyDetails = null;
    ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate.toDate(), externalId, addressDto, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, feesToApply, parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDate.toLocalDate());
    // exercise test
    List<SavingsDetailDto> allowedSavingProducts = new ArrayList<SavingsDetailDto>();
    CustomerDetailsDto newlyCreatedCustomerDetails = clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
    return newlyCreatedCustomerDetails;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) InputStream(java.io.InputStream) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) AddressDto(org.mifos.dto.domain.AddressDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) MeetingDto(org.mifos.dto.domain.MeetingDto) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder)

Example 14 with CustomerDetailsDto

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

the class GroupServiceFacadeWebTierIntegrationTest method createGroup.

private CustomerDetailsDto createGroup(String displayName, Short officeId) {
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String externalId = null;
    AddressDto addressDto = null;
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
    Short customerStatus = CustomerStatus.GROUP_ACTIVE.getValue();
    boolean trained = false;
    DateTime trainedOn = null;
    String parentSystemId = null;
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    DateTime activationDate = new DateTime().minusWeeks(1);
    GroupCreationDetail groupCenterDetail = new GroupCreationDetail(displayName, externalId, addressDto, loanOfficerId, feesToApply, customerStatus, trained, trainedOn, parentSystemId, officeId, mfiJoiningDate, activationDate);
    // exercise test
    CustomerDetailsDto newlyCreatedGroupDetails = groupServiceFacade.createNewGroup(groupCenterDetail, meetingDto);
    return newlyCreatedGroupDetails;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto)

Example 15 with CustomerDetailsDto

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

the class CenterRESTController method createCenter.

@RequestMapping(value = "/center/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createCenter(@RequestBody String request) throws Throwable {
    ObjectMapper om = createCenterMaping();
    CreateCenterDetailsDto creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateCenterDetailsDto.class);
    } catch (JsonMappingException e) {
        throw e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    CenterCreationDetail center = createCenter(creationDetail);
    CustomerDetailsDto details = this.centerServiceFacade.createNewCenter(center, meetingBO.toDto());
    CenterInformationDto centerInfo = this.centerServiceFacade.getCenterInformationDto(details.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", centerInfo.getCenterDisplay().getGlobalCustNum());
    map.put("accountNum", centerInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("name", center.getDisplayName());
    map.put("externalId", center.getExternalId());
    map.put("mfiDate", center.getMfiJoiningDate().toString());
    map.put("address", center.getAddressDto().getDisplayAddress());
    map.put("city", center.getAddressDto().getCity());
    map.put("state", center.getAddressDto().getState());
    map.put("country", center.getAddressDto().getCountry());
    map.put("postal code", center.getAddressDto().getZip());
    map.put("phone", center.getAddressDto().getPhoneNumber());
    return map;
}
Also used : CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CreateCenterDetailsDto(org.mifos.application.servicefacade.CreateCenterDetailsDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)16 MeetingBO (org.mifos.application.meeting.business.MeetingBO)14 AddressDto (org.mifos.dto.domain.AddressDto)11 DateTime (org.joda.time.DateTime)9 OfficeBO (org.mifos.customers.office.business.OfficeBO)8 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)8 MeetingDto (org.mifos.dto.domain.MeetingDto)8 ArrayList (java.util.ArrayList)7 LocalDate (org.joda.time.LocalDate)5 Test (org.junit.Test)5 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)5 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)5 GroupBO (org.mifos.customers.group.business.GroupBO)4 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)4 GroupCreationDetail (org.mifos.dto.domain.GroupCreationDetail)4 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)4 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)4 UserContext (org.mifos.security.util.UserContext)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 InputStream (java.io.InputStream)3