Search in sources :

Example 26 with ApplicableAccountFeeDto

use of org.mifos.dto.domain.ApplicableAccountFeeDto 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 27 with ApplicableAccountFeeDto

use of org.mifos.dto.domain.ApplicableAccountFeeDto 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 28 with ApplicableAccountFeeDto

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

the class ClientServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithExpectedSearchId.

@Test
public void shouldCreateGroupWithExpectedSearchId() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    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;
    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);
    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.NO.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;
    String parentGroupId = 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
    ClientRules.setCenterHierarchyExists(false);
    List<SavingsDetailDto> allowedSavingProducts = new ArrayList<SavingsDetailDto>();
    CustomerDetailsDto newlyCreatedCustomerDetails = clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
    // verification
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
    ClientBO client = customerDao.findClientBySystemId(newlyCreatedCustomerDetails.getGlobalCustNum());
    Assert.assertThat(client.getSearchId(), is("1." + client.getCustomerId()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) 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) OfficeBO(org.mifos.customers.office.business.OfficeBO) 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) Test(org.junit.Test)

Example 29 with ApplicableAccountFeeDto

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

the class ClientCustActionStrutsTest method testFailurePreview_WithDuplicateFee.

@Test
public void testFailurePreview_WithDuplicateFee() throws Exception {
    List<FeeDto> feesToRemove = getFees(RecurrenceType.WEEKLY);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<ApplicableAccountFeeDto> feeList = (List<ApplicableAccountFeeDto>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request);
    ApplicableAccountFeeDto fee = feeList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("selectedFee[0].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[0].amount", "100");
    addRequestParameter("selectedFee[1].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[1].amount", "150");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    Assert.assertEquals("Fee", 1, getErrorSize(CustomerConstants.FEE));
    removeFees(feesToRemove);
}
Also used : ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) List(java.util.List) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Test(org.junit.Test)

Example 30 with ApplicableAccountFeeDto

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

the class ClientCustActionStrutsTest method testFailurePreview_FeeFrequencyMismatch.

@Test
public void testFailurePreview_FeeFrequencyMismatch() throws Exception {
    List<FeeDto> feesToRemove = getFees(RecurrenceType.MONTHLY);
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    List<BusinessActivityEntity> povertyStatus = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    List<ApplicableAccountFeeDto> feeList = (List<ApplicableAccountFeeDto>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request);
    Assert.assertEquals(1, feeList.size());
    ApplicableAccountFeeDto fee = feeList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter("customerDetail.povertyStatus", povertyStatus.get(0).getId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("selectedFee[0].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[0].amount", fee.getAmount());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, new MeetingBO(RecurrenceType.WEEKLY, (short) 2, new Date(), MeetingType.CUSTOMER_MEETING), request);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    Assert.assertEquals("Fee", 1, getErrorSize(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH));
    removeFees(feesToRemove);
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) List(java.util.List) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)32 ArrayList (java.util.ArrayList)19 Test (org.junit.Test)15 FeeDto (org.mifos.accounts.fees.business.FeeDto)15 MeetingBO (org.mifos.application.meeting.business.MeetingBO)14 Date (java.util.Date)7 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)7 MeetingDto (org.mifos.dto.domain.MeetingDto)7 List (java.util.List)6 AddressDto (org.mifos.dto.domain.AddressDto)6 LocalDate (org.joda.time.LocalDate)5 FeeBO (org.mifos.accounts.fees.business.FeeBO)5 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)5 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)5 Address (org.mifos.framework.business.util.Address)5 DateTime (org.joda.time.DateTime)4 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)4 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)4 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)4