Search in sources :

Example 1 with CenterCreationDetail

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

the class CenterCustAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
    LocalDate mfiJoiningDate = new LocalDate(CalendarUtils.getDateFromString(actionForm.getMfiJoiningDate(), getUserContext(request).getPreferredLocale()));
    Address address = actionForm.getAddress();
    AddressDto addressDto = Address.toDto(address);
    MeetingDto meetingDto = meeting.toDto();
    List<CreateAccountFeeDto> accountFeesToBeApplied = new ArrayList<CreateAccountFeeDto>();
    List<ApplicableAccountFeeDto> feesToBeApplied = actionForm.getFeesToApply();
    for (ApplicableAccountFeeDto feeDto : feesToBeApplied) {
        accountFeesToBeApplied.add(new CreateAccountFeeDto(feeDto.getFeeId(), feeDto.getAmount()));
    }
    try {
        CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate, actionForm.getDisplayName(), actionForm.getExternalId(), addressDto, actionForm.getLoanOfficerIdValue(), actionForm.getOfficeIdValue(), accountFeesToBeApplied);
        CustomerDetailsDto centerDetails = this.centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
        createCenterQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
        actionForm.setCustomerId(centerDetails.getId().toString());
        actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e.getMessageValues());
    }
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) Address(org.mifos.framework.business.util.Address) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) LocalDate(org.joda.time.LocalDate) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with CenterCreationDetail

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

the class CenterServiceFacadeWebTierIntegrationTest method shouldCreateCenterWithExpectedSearchId.

@Test
public void shouldCreateCenterWithExpectedSearchId() {
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String displayName = "testCenter";
    String externalId = null;
    AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<CreateAccountFeeDto> feesToApply = new ArrayList<CreateAccountFeeDto>();
    CustomerStatus.GROUP_ACTIVE.getValue();
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId = branch1.getOfficeId();
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    new DateTime().minusWeeks(1);
    CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate.toLocalDate(), displayName, externalId, addressDto, loanOfficerId, officeId, feesToApply);
    // exercise test
    CustomerDetailsDto newlyCreatedCenterDetails = centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
    // verification
    CenterBO center = customerDao.findCenterBySystemId(newlyCreatedCenterDetails.getGlobalCustNum());
    Assert.assertThat(center.getSearchId(), is("1." + center.getCustomerId()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Example 3 with CenterCreationDetail

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

the class CenterRESTController method createCenter.

@RequestMapping(value = "/center/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createCenter(@RequestBody String request) throws Throwable {
    ObjectMapper om = createCenterMaping();
    CreateCenterDetailsDto creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateCenterDetailsDto.class);
    } catch (JsonMappingException e) {
        throw e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    CenterCreationDetail center = createCenter(creationDetail);
    CustomerDetailsDto details = this.centerServiceFacade.createNewCenter(center, meetingBO.toDto());
    CenterInformationDto centerInfo = this.centerServiceFacade.getCenterInformationDto(details.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", centerInfo.getCenterDisplay().getGlobalCustNum());
    map.put("accountNum", centerInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("name", center.getDisplayName());
    map.put("externalId", center.getExternalId());
    map.put("mfiDate", center.getMfiJoiningDate().toString());
    map.put("address", center.getAddressDto().getDisplayAddress());
    map.put("city", center.getAddressDto().getCity());
    map.put("state", center.getAddressDto().getState());
    map.put("country", center.getAddressDto().getCountry());
    map.put("postal code", center.getAddressDto().getZip());
    map.put("phone", center.getAddressDto().getPhoneNumber());
    return map;
}
Also used : CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CreateCenterDetailsDto(org.mifos.application.servicefacade.CreateCenterDetailsDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 CenterCreationDetail (org.mifos.dto.domain.CenterCreationDetail)3 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)3 ArrayList (java.util.ArrayList)2 AddressDto (org.mifos.dto.domain.AddressDto)2 CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)2 MeetingDto (org.mifos.dto.domain.MeetingDto)2 HashMap (java.util.HashMap)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 Test (org.junit.Test)1 CreateCenterDetailsDto (org.mifos.application.servicefacade.CreateCenterDetailsDto)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 CenterCustActionForm (org.mifos.customers.center.struts.actionforms.CenterCustActionForm)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)1 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)1