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());
}
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()));
}
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;
}
Aggregations