use of org.mifos.dto.domain.ProcessRulesDto in project head by mifos.
the class ClientServiceFacadeWebTier method previewClient.
@Override
public ProcessRulesDto previewClient(String governmentId, DateTime dateOfBirth, String clientName, boolean defaultFeeRemoval, Short officeId, Short loanOfficerId) {
try {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
boolean clientPendingApprovalStateEnabled = ProcessFlowRules.isClientPendingApprovalStateEnabled();
boolean governmentIdValidationFailing = false;
boolean duplicateNameOnClosedClient = false;
boolean duplicateNameOnBlackListedClient = false;
boolean governmentIdValidationUnclosedFailing = false;
boolean duplicateNameOnClient = false;
List<ClientBO> matchedClients = new ArrayList<ClientBO>();
List<ClientBO> temp;
if (defaultFeeRemoval) {
customerDao.checkPermissionForDefaultFeeRemoval(userContext, officeId, loanOfficerId);
}
if (StringUtils.isNotBlank(governmentId)) {
temp = this.customerDao.validateGovernmentIdForUnclosedClient(governmentId);
if (temp != null) {
matchedClients.addAll(temp);
}
governmentIdValidationUnclosedFailing = temp != null && temp.size() > 0;
if (!governmentIdValidationUnclosedFailing) {
temp = this.customerDao.validateGovernmentIdForClient(governmentId);
if (temp != null) {
matchedClients.addAll(temp);
}
governmentIdValidationFailing = temp != null && temp.size() > 0;
}
}
if (!governmentIdValidationFailing && !governmentIdValidationUnclosedFailing) {
temp = this.customerDao.validateForBlackListedClientsOnNameAndDob(clientName, dateOfBirth);
if (temp != null) {
matchedClients.addAll(temp);
}
duplicateNameOnBlackListedClient = temp != null && temp.size() > 0;
if (!duplicateNameOnBlackListedClient) {
temp = this.customerDao.validateForClosedClientsOnNameAndDob(clientName, dateOfBirth);
if (temp != null) {
matchedClients.addAll(temp);
}
duplicateNameOnClosedClient = temp != null && temp.size() > 0;
if (!duplicateNameOnClosedClient) {
temp = this.customerDao.validateForClientsOnName(clientName);
if (temp != null) {
matchedClients.addAll(temp);
}
duplicateNameOnClient = temp != null && temp.size() > 0;
}
}
}
List<MatchedClientDto> matched = new ArrayList<MatchedClientDto>();
for (ClientBO client : matchedClients) {
matched.add(new MatchedClientDto(client.getGlobalCustNum(), client.getDisplayName(), client.getAddress().getPhoneNumber(), client.getGovernmentId(), client.getDisplayAddress(), client.getOffice().getOfficeName(), client.getOffice().getGlobalOfficeNum()));
}
return new ProcessRulesDto(clientPendingApprovalStateEnabled, governmentIdValidationFailing, duplicateNameOnClosedClient, duplicateNameOnBlackListedClient, governmentIdValidationUnclosedFailing, duplicateNameOnClient, matched);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.dto.domain.ProcessRulesDto in project head by mifos.
the class PictureFormFile method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
String governmentId = actionForm.getGovernmentId();
ClientNameDetailDto clientNameDetail = actionForm.getClientName();
clientNameDetail.setNames(ClientRules.getNameSequence());
String clientName = clientNameDetail.getDisplayName();
String givenDateOfBirth = actionForm.getDateOfBirth();
ClientNameDetailDto spouseName = actionForm.getSpouseName();
spouseName.setNames(ClientRules.getNameSequence());
DateTime dateOfBirth = new DateTime(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth));
ProcessRulesDto processRules = this.clientServiceFacade.previewClient(governmentId, dateOfBirth, clientName, actionForm.isDefaultFeeRemoved(), actionForm.getOfficeIdValue(), actionForm.getLoanOfficerIdValue());
String pendingApprovalState = processRules.isClientPendingApprovalStateEnabled() ? CustomerConstants.YES : CustomerConstants.NO;
SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, pendingApprovalState, request);
Short officeId = actionForm.getOfficeIdValue();
Short groupFlag = actionForm.getGroupFlagValue();
String parentGroupId = actionForm.getParentGroupId();
ClientFormCreationDto clientFormCreationDto = this.clientServiceFacade.retrieveClientFormCreationData(groupFlag, officeId, parentGroupId);
InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateClient"), request);
if (clientFormCreationDto.getFormedByPersonnelId() != null) {
UserContext userContext = getUserContext(request);
MeetingBO groupMeeting = customerDao.findCustomerById(Integer.valueOf(parentGroupId)).getCustomerMeetingValue();
clientFormCreationDto.getParentCustomerMeeting().setMeetingSchedule(CustomerUIHelperFn.getMeetingSchedule(groupMeeting, userContext));
SessionUtils.setAttribute("meeting", clientFormCreationDto.getParentCustomerMeeting(), request);
}
addWarningMessages(request, processRules, calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
actionForm.setEditFamily("edit");
actionForm.setAge(calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
actionForm.setClientName(clientNameDetail);
actionForm.setSpouseName(spouseName);
return mapping.findForward(ActionForwards.preview_success.toString());
}
use of org.mifos.dto.domain.ProcessRulesDto in project head by mifos.
the class PictureFormFile method previewPersonalInfo.
@TransactionDemarcate(joinToken = true)
public ActionForward previewPersonalInfo(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
actionForm.setAge(calculateAge(DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth())));
String governmentId = actionForm.getGovernmentId();
ClientNameDetailDto clientNameDetail = actionForm.getClientName();
clientNameDetail.setNames(ClientRules.getNameSequence());
String clientName = clientNameDetail.getDisplayName();
String givenDateOfBirth = actionForm.getDateOfBirth();
ClientNameDetailDto spouseName = actionForm.getSpouseName();
spouseName.setNames(ClientRules.getNameSequence());
DateTime dateOfBirth = new DateTime(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth));
ProcessRulesDto processRules = this.clientServiceFacade.previewClient(governmentId, dateOfBirth, clientName, actionForm.isDefaultFeeRemoved(), actionForm.getOfficeIdValue(), actionForm.getLoanOfficerIdValue());
addWarningMessages(request, processRules, calculateAge(DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth())));
return mapping.findForward(ActionForwards.previewPersonalInfo_success.toString());
}
Aggregations