Search in sources :

Example 16 with CustomerDetailsDto

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

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