use of org.mifos.framework.exceptions.ApplicationException 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.framework.exceptions.ApplicationException in project head by mifos.
the class SavingsApplyAdjustmentActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = new ActionErrors();
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
try {
if (method != null && method.equals("preview")) {
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
AccountPaymentEntity payment = savings.findPaymentById(this.paymentId);
if (payment == null || savings.getLastPmntAmnt() == 0 || !(new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue()) || new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue()))) {
errors.add(SavingsConstants.INVALID_LAST_PAYMENT, new ActionMessage(SavingsConstants.INVALID_LAST_PAYMENT));
} else {
if (StringUtils.isBlank(getLastPaymentAmount())) {
errors.add(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT, new ActionMessage(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT));
}
if (StringUtils.isNotBlank(getLastPaymentAmount())) {
Locale locale = getUserContext(request).getPreferredLocale();
validateAmount(errors, locale);
}
if (StringUtils.isNotBlank(getNote()) && getNote().length() > CustomerConstants.COMMENT_LENGTH) {
errors.add(AccountConstants.MAX_NOTE_LENGTH, new ActionMessage(AccountConstants.MAX_NOTE_LENGTH, AccountConstants.COMMENT_LENGTH));
}
validateDate(errors);
errors.add(super.validate(mapping, request));
}
}
} catch (ApplicationException ae) {
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleAccountStateObjectsForLoan.
private List<AccountStateEntity> retrieveNextPossibleAccountStateObjectsForLoan(StateEntity accountStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleAccountStateObjectsForLoan()");
List<AccountStateEntity> stateEntityList = new ArrayList<AccountStateEntity>();
try {
List<StateEntity> stateList = statesMapForLoan.get(accountStateEntityObj);
if (null != stateList) {
for (StateEntity accountStateEntity : stateList) {
for (AccountStateEntity accountStateEnty : accountStateEntityListForLoan) {
if (accountStateEntity.sameId(accountStateEnty)) {
stateEntityList.add(accountStateEnty);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleCustomerStateForClient.
private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForClient(StateEntity customerStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForClient()");
List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
try {
List<StateEntity> stateList = statesMapForClient.get(customerStateEntityObj);
if (null != stateList) {
for (StateEntity customerStateEntity : stateList) {
for (CustomerStatusEntity customerStatusEntry : customerStatusListForClient) {
if (customerStatusEntry.sameId(customerStateEntity)) {
stateEntityList.add(customerStatusEntry);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleCustomerStateForGroup.
private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForGroup(StateEntity customerStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForGroup()");
List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
try {
List<StateEntity> stateList = statesMapForGroup.get(customerStateEntityObj);
if (null != stateList) {
for (StateEntity customerStateEntity : stateList) {
for (CustomerStatusEntity customerStatusEntry : customerStatusListForGroup) {
if (customerStatusEntry.sameId(customerStateEntity)) {
stateEntityList.add(customerStatusEntry);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
Aggregations