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