Search in sources :

Example 16 with SavingsDetailDto

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

the class PictureFormFile method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
    List<SavingsDetailDto> allowedSavingProducts = getSavingsOfferingsFromSession(request);
    if (ClientRules.isFamilyDetailsRequired()) {
        actionForm.setFamilyDateOfBirth();
        actionForm.constructFamilyDetails();
    }
    List<Short> selectedSavingProducts = actionForm.getSelectedOfferings();
    String clientName = actionForm.getClientName().getDisplayName();
    Short clientStatus = actionForm.getStatusValue().getValue();
    java.sql.Date mfiJoiningDate = DateUtils.getDateAsSentFromBrowser(actionForm.getMfiJoiningDate());
    String externalId = actionForm.getExternalId();
    AddressDto address = null;
    if (actionForm.getAddress() != null) {
        address = Address.toDto(actionForm.getAddress());
    }
    Short formedBy = actionForm.getFormedByPersonnelValue();
    java.sql.Date dateOfBirth = DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth());
    String governmentId = actionForm.getGovernmentId();
    boolean trained = isTrained(actionForm.getTrainedValue());
    java.sql.Date trainedDate = DateUtils.getDateAsSentFromBrowser(actionForm.getTrainedDate());
    Short groupFlagValue = actionForm.getGroupFlagValue();
    ClientNameDetailDto clientNameDetailDto = actionForm.getClientName();
    ClientPersonalDetailDto clientPersonalDetailDto = actionForm.getClientDetailView();
    ClientNameDetailDto spouseFatherName = actionForm.getSpouseName();
    InputStream picture = actionForm.getCustomerPicture();
    String parentGroupId = actionForm.getParentGroupId();
    List<ClientNameDetailDto> familyNames = actionForm.getFamilyNames();
    List<ClientFamilyDetailDto> familyDetails = actionForm.getFamilyDetails();
    Short loanOfficerId = actionForm.getLoanOfficerIdValue();
    Short officeId = actionForm.getOfficeIdValue();
    // only applies when status is active
    LocalDate activationDateAsToday = new LocalDate();
    ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate, externalId, address, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlagValue, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, actionForm.getFeesToApply(), parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDateAsToday);
    MeetingDto meetingDto = null;
    if (meeting != null) {
        meetingDto = meeting.toDto();
    }
    CustomerDetailsDto clientDetails = this.clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
    List<FormFile> formFiles = actionForm.getFiles();
    List<UploadedFileDto> filesMetadata = actionForm.getFilesMetadata();
    for (int i = 0; i < formFiles.size(); i++) {
        if (formFiles.get(i).getFileSize() != 0) {
            InputStream inputStream = formFiles.get(i).getInputStream();
            UploadedFileDto fileMetadata = filesMetadata.get(i);
            clientServiceFacade.uploadFile(clientDetails.getId(), inputStream, fileMetadata);
        }
    }
    actionForm.setCustomerId(clientDetails.getId().toString());
    actionForm.setGlobalCustNum(clientDetails.getGlobalCustNum());
    actionForm.setEditFamily("notEdit");
    createClientQuestionnaire.saveResponses(request, actionForm, clientDetails.getId());
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LocalDate(org.joda.time.LocalDate) FormFile(org.apache.struts.upload.FormFile) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto) ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) AddressDto(org.mifos.dto.domain.AddressDto) Date(java.sql.Date) MeetingDto(org.mifos.dto.domain.MeetingDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 17 with SavingsDetailDto

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

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

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

the class ClientCustActionStrutsTest method testPreviewFailure_DuplicateOfferingsSelected.

@Test
public void testPreviewFailure_DuplicateOfferingsSelected() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("savingsPrd1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    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);
    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", "11");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<SavingsDetailDto> savingsOfferingList = getSavingsOfferingsFromSession();
    SavingsDetailDto savingsOffering = savingsOfferingList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("savingsOffering[0]", savingsOffering.getPrdOfferingId().toString());
    addRequestParameter("savingsOffering[1]", savingsOffering.getPrdOfferingId().toString());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, new MeetingBO(RecurrenceType.MONTHLY, Short.valueOf("2"), new Date(), MeetingType.CUSTOMER_MEETING), request);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    Assert.assertEquals("Duplicate Offerings", 1, getErrorSize(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED));
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 20 with SavingsDetailDto

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

the class ClientCustActionStrutsTest method testSuccessfulPreviewWithSavingsOfferingsSelected.

@Test
public void testSuccessfulPreviewWithSavingsOfferingsSelected() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("savingsPrd1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    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);
    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", "11");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<SavingsDetailDto> savingsOfferingList = getSavingsOfferingsFromSession();
    SavingsDetailDto savingsOffering = savingsOfferingList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("savingsOffering[0]", savingsOffering.getPrdOfferingId().toString());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, new MeetingBO(RecurrenceType.MONTHLY, Short.valueOf("2"), new Date(), MeetingType.CUSTOMER_MEETING), request);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.preview_success.toString());
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)20 ArrayList (java.util.ArrayList)17 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 List (java.util.List)7 MifosUser (org.mifos.security.MifosUser)7 Date (java.util.Date)6 UserContext (org.mifos.security.util.UserContext)6 Test (org.junit.Test)5 AccountBO (org.mifos.accounts.business.AccountBO)5 AccountException (org.mifos.accounts.exceptions.AccountException)5 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)5 LocalDate (org.joda.time.LocalDate)4 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)4 AddressDto (org.mifos.dto.domain.AddressDto)4 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)4 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)4 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)4 MeetingDto (org.mifos.dto.domain.MeetingDto)4 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)4