use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustSearchAction method search.
/**
* FIXME: KEITHW - When replacing search functionality for customers with spring/ftl implementation,
* find cleaner way of implementing search that returns a non domain related class (data only object)
*/
@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
if (request.getParameter("perspective") != null) {
request.setAttribute("perspective", request.getParameter("perspective"));
}
ActionForward actionForward = super.search(mapping, form, request, response);
CustSearchActionForm actionForm = (CustSearchActionForm) form;
UserContext userContext = getUserContext(request);
String searchString = actionForm.getSearchString();
if (searchString == null) {
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
String officeName = this.centerServiceFacade.retrieveOfficeName(userContext.getBranchId());
addSeachValues(searchString, userContext.getBranchId().toString(), officeName, request);
searchString = SearchUtils.normalizeSearchString(searchString);
if (StringUtils.isBlank(searchString)) {
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
if (actionForm.getInput() != null && actionForm.getInput().equals("loan")) {
QueryResult groupClients = new CustomerPersistence().searchGroupClient(searchString, userContext.getId(), false);
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, groupClients, request);
} else if (actionForm.getInput() != null && actionForm.getInput().equals("savings")) {
QueryResult customerForSavings = new CustomerPersistence().searchCustForSavings(searchString, userContext.getId());
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, customerForSavings, request);
}
return actionForward;
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class EditCustomerStatusAction method updateStatus.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditCustomerStatusActionForm editStatusActionForm = (EditCustomerStatusActionForm) form;
CustomerBO customerBOInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
if (customerBOInSession.isBlackListed() && customerBOInSession.getStatus().getValue() == CustomerConstants.CLIENT_CLOSED) {
try {
this.clientServiceFacade.removeFromBlacklist(customerBOInSession.getCustomerId());
customerBOInSession.setVersionNo(customerBOInSession.getVersionNo() + 1);
} catch (AccessDeniedException e) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
try {
this.centerServiceFacade.updateCustomerStatus(customerBOInSession.getCustomerId(), customerBOInSession.getVersionNo(), editStatusActionForm.getFlagId(), editStatusActionForm.getNewStatusId(), editStatusActionForm.getNotes());
createClientQuestionnaire.saveResponses(request, editStatusActionForm, customerBOInSession.getCustomerId());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
return mapping.findForward(getDetailAccountPage(form));
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class SavingsBO method generateNextSetOfMeetingDates.
public void generateNextSetOfMeetingDates(final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
CustomerBO customerBO = getCustomer();
if (customerBO.getCustomerMeeting() != null && customerBO.getCustomerMeeting().getMeeting() != null) {
MeetingBO depositSchedule = customerBO.getCustomerMeeting().getMeeting();
Date oldMeetingDate = depositSchedule.getStartDate();
Short lastInstallmentId = getLastInstallmentId();
AccountActionDateEntity lastInstallment = getAccountActionDate(lastInstallmentId);
if (lastInstallment == null) {
// a special workaround for MIFOS-5107
lastInstallment = new SavingsScheduleEntity(this, this.getCustomer(), (short) 0, new java.sql.Date(new LocalDate().minusDays(1).toDateMidnight().getMillis()), PaymentStatus.UNPAID, new Money(Money.getDefaultCurrency(), 0.0));
}
depositSchedule.setMeetingStartDate(lastInstallment.getActionDate());
if (customerBO.getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || customerBO.getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
generateDepositAccountActions(customerBO, depositSchedule, lastInstallment, workingDays, holidays);
} else {
List<CustomerBO> children;
try {
children = getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
for (CustomerBO customer : children) {
generateDepositAccountActions(customer, depositSchedule, lastInstallment, workingDays, holidays);
}
}
depositSchedule.setStartDate(oldMeetingDate);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class SavingsBO method regenerateFutureInstallments.
@Override
protected void regenerateFutureInstallments(final AccountActionDateEntity nextInstallment, final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
MeetingBO customerMeeting = getCustomer().getCustomerMeetingValue();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting);
LocalDate currentDate = new LocalDate();
LocalDate thisIntervalStartDate = customerMeeting.startDateForMeetingInterval(currentDate);
LocalDate nextMatchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(thisIntervalStartDate.toDateTimeAtStartOfDay()));
DateTime futureIntervalStartDate = customerMeeting.startDateForMeetingInterval(nextMatchingDate).toDateTimeAtStartOfDay();
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
int numberOfInstallmentsToGenerate = getLastInstallmentId();
List<DateTime> meetingDates = dateGeneration.generateScheduledDates(numberOfInstallmentsToGenerate, futureIntervalStartDate, scheduledEvent, false);
if (getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || getCustomer().getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
updateSchedule(nextInstallment.getInstallmentId(), meetingDates);
} else {
List<CustomerBO> children;
try {
children = getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
updateSavingsSchedule(nextInstallment.getInstallmentId(), meetingDates, children);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class SavingsBO method goActiveForFristTimeAndGenerateSavingsSchedule.
/**
* use minimal constructor which generates scheduled savings payments correctly and does not
* do through this method.
*/
@Deprecated
private void goActiveForFristTimeAndGenerateSavingsSchedule(final CustomerBO customer) throws AccountException {
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
CalendarEvent futureCalendarEventsApplicableToOffice = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
this.activationDate = new DateTime(new DateTimeService().getCurrentJavaDateTime()).toDate();
List<Days> workingDays = futureCalendarEventsApplicableToOffice.getWorkingDays();
List<Holiday> holidays = futureCalendarEventsApplicableToOffice.getHolidays();
logger.debug("In SavingsBO::generateDepositAccountActions()");
// center/group with individual deposits, insert row for every client
if (this.getCustomer().getCustomerMeeting() != null && this.getCustomer().getCustomerMeeting().getMeeting() != null) {
MeetingBO depositSchedule = this.getCustomer().getCustomerMeeting().getMeeting();
if (this.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || this.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && this.getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
this.generateDepositAccountActions(this.getCustomer(), depositSchedule, workingDays, holidays, new DateTime(this.activationDate));
} else {
List<CustomerBO> children;
try {
children = this.getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.ACTIVE_AND_ONHOLD);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
for (CustomerBO customer1 : children) {
this.generateDepositAccountActions(customer1, depositSchedule, workingDays, holidays, new DateTime(this.activationDate));
}
}
}
InterestScheduledEvent interestPostingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(this.savingsOffering.getFreqOfPostIntcalc().getMeeting());
this.nextIntPostDate = interestPostingEvent.nextMatchingDateAfter(new LocalDate(startOfFiscalYear()), new LocalDate(this.activationDate)).toDateMidnight().toDate();
}
Aggregations