Search in sources :

Example 1 with GroupCreationDetail

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

the class GroupRESTController method createGroup.

@RequestMapping(value = "group/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createGroup(@RequestBody String request) throws Throwable {
    ObjectMapper om = createGroupMapping();
    CreateGroupCreationDetailDto creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateGroupCreationDetailDto.class);
    } catch (JsonMappingException e) {
        throw e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    GroupCreationDetail group = createGroup(creationDetail);
    CustomerDetailsDto groupDetails = groupServiceFacade.createNewGroup(group, meetingBO.toDto());
    GroupInformationDto groupInfo = groupServiceFacade.getGroupInformationDto(groupDetails.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCusNum", groupInfo.getGroupDisplay().getGlobalCustNum());
    map.put("accountNum", groupInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("address", groupInfo.getAddress().getDisplayAddress());
    map.put("city", groupInfo.getAddress().getCity());
    map.put("state", groupInfo.getAddress().getState());
    map.put("country", groupInfo.getAddress().getCountry());
    map.put("postal code", groupInfo.getAddress().getZip());
    map.put("phone", groupInfo.getAddress().getPhoneNumber());
    map.put("dispalyName", groupInfo.getGroupDisplay().getDisplayName());
    map.put("externalId", groupInfo.getGroupDisplay().getExternalId());
    map.put("loanOfficer", groupInfo.getGroupDisplay().getLoanOfficerName());
    return map;
}
Also used : HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) CreateGroupCreationDetailDto(org.mifos.application.servicefacade.CreateGroupCreationDetailDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with GroupCreationDetail

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

the class GroupCustAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
    UserContext userContext = getUserContext(request);
    String groupName = actionForm.getDisplayName();
    String externalId = actionForm.getExternalId();
    boolean trained = actionForm.isCustomerTrained();
    DateTime trainedOn = new DateTime(actionForm.getTrainedDateValue(userContext.getPreferredLocale()));
    AddressDto addressDto = null;
    if (actionForm.getAddress() != null) {
        addressDto = Address.toDto(actionForm.getAddress());
    }
    Short customerStatusId = actionForm.getStatusValue().getValue();
    String centerSystemId = "";
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (isCenterHierarchyExists) {
        centerSystemId = actionForm.getParentCustomer().getGlobalCustNum();
    }
    Short officeId = actionForm.getOfficeIdValue();
    MeetingDto meetingDto = null;
    if (meeting != null) {
        meetingDto = meeting.toDto();
    }
    DateTime mfiJoiningDate = new DateTime().toDateMidnight().toDateTime();
    DateTime activationDate = new DateTime().toDateMidnight().toDateTime();
    try {
        GroupCreationDetail groupCreationDetail = new GroupCreationDetail(groupName, externalId, addressDto, actionForm.getFormedByPersonnelValue(), actionForm.getFeesToApply(), customerStatusId, trained, trainedOn, centerSystemId, officeId, mfiJoiningDate, activationDate);
        CustomerDetailsDto centerDetails = this.groupServiceFacade.createNewGroup(groupCreationDetail, meetingDto);
        createGroupQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
        actionForm.setCustomerId(centerDetails.getId().toString());
        actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e);
    }
    SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) UserContext(org.mifos.security.util.UserContext) AddressDto(org.mifos.dto.domain.AddressDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with GroupCreationDetail

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

use of org.mifos.dto.domain.GroupCreationDetail 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)

Aggregations

MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)4 GroupCreationDetail (org.mifos.dto.domain.GroupCreationDetail)4 DateTime (org.joda.time.DateTime)3 AddressDto (org.mifos.dto.domain.AddressDto)3 MeetingDto (org.mifos.dto.domain.MeetingDto)3 ArrayList (java.util.ArrayList)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)2 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)2 HashMap (java.util.HashMap)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 LocalDate (org.joda.time.LocalDate)1 Test (org.junit.Test)1 CreateGroupCreationDetailDto (org.mifos.application.servicefacade.CreateGroupCreationDetailDto)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 GroupInformationDto (org.mifos.dto.screen.GroupInformationDto)1