Search in sources :

Example 6 with ClientCreationDetail

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

the class ClientRESTController method createClient.

@RequestMapping(value = "client/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createClient(@RequestBody String request) throws Throwable {
    ObjectMapper om = createClientMapping();
    CreateClientCreationDetail creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateClientCreationDetail.class);
    } catch (JsonMappingException e) {
        e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    ClientCreationDetail client = createClient(creationDetail);
    CustomerDetailsDto clientDetails = clientServiceFacade.createNewClient(client, meetingBO.toDto(), null);
    ClientInformationDto clientInfo = clientServiceFacade.getClientInformationDto(clientDetails.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", clientInfo.getClientDisplay().getGlobalCustNum());
    map.put("accountNum", clientInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("address", clientInfo.getAddress().getDisplayAddress());
    map.put("city", clientInfo.getAddress().getCity());
    map.put("state", clientInfo.getAddress().getState());
    map.put("country", clientInfo.getAddress().getCountry());
    map.put("postal code", clientInfo.getAddress().getZip());
    map.put("phone", clientInfo.getAddress().getPhoneNumber());
    map.put("dispalyName", clientInfo.getClientDisplay().getDisplayName());
    map.put("externalId", clientInfo.getClientDisplay().getExternalId());
    map.put("loanOfficer", clientInfo.getClientDisplay().getLoanOfficerName());
    return map;
}
Also used : CreateClientCreationDetail(org.mifos.application.servicefacade.CreateClientCreationDetail) CreateClientCreationDetail(org.mifos.application.servicefacade.CreateClientCreationDetail) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)5 AddressDto (org.mifos.dto.domain.AddressDto)5 MeetingDto (org.mifos.dto.domain.MeetingDto)5 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 LocalDate (org.joda.time.LocalDate)4 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)4 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)4 Date (java.util.Date)3 DateTime (org.joda.time.DateTime)3 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)3 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)3 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)3 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)3 ClientBO (org.mifos.customers.client.business.ClientBO)2 CustomerException (org.mifos.customers.exceptions.CustomerException)2 OfficeBO (org.mifos.customers.office.business.OfficeBO)2 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)2