Search in sources :

Example 66 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class GroupBO method updatePerformanceHistoryOnReversal.

@Override
public void updatePerformanceHistoryOnReversal(final LoanBO loan, final Money lastLoanAmount) throws CustomerException {
    try {
        GroupPerformanceHistoryEntity groupPerformanceHistoryEntity = (GroupPerformanceHistoryEntity) getPerformanceHistory();
        groupPerformanceHistoryEntity.updateOnReversal(loan, lastLoanAmount);
    } catch (AccountException e) {
        throw new CustomerException(e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) AccountException(org.mifos.accounts.exceptions.AccountException)

Example 67 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class CenterServiceFacadeWebTier method updateCustomerStatus.

@Override
public void updateCustomerStatus(Integer customerId, Integer previousCustomerVersionNo, String flagIdAsString, String newStatusIdAsString, String notes) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    Short flagId = null;
    Short newStatusId = null;
    if (StringUtils.isNotBlank(flagIdAsString)) {
        flagId = Short.valueOf(flagIdAsString);
    }
    if (StringUtils.isNotBlank(newStatusIdAsString)) {
        newStatusId = Short.valueOf(newStatusIdAsString);
    }
    CustomerStatusFlag customerStatusFlag = null;
    if (flagId != null) {
        customerStatusFlag = CustomerStatusFlag.fromInt(flagId);
    }
    CustomerStatus newStatus = CustomerStatus.fromInt(newStatusId);
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdate(customerId, previousCustomerVersionNo, customerStatusFlag, newStatus, notes);
    try {
        this.customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) UserContext(org.mifos.security.util.UserContext) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) MifosUser(org.mifos.security.MifosUser)

Example 68 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class CustomerPersistence method saveCustomer.

public void saveCustomer(final CustomerBO customer) throws CustomerException {
    try {
        createOrUpdate(customer);
        customer.generateGlobalCustomerNumber();
        createOrUpdate(customer);
    } catch (PersistenceException e) {
        throw new CustomerException(CustomerConstants.CREATE_FAILED_EXCEPTION, e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 69 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class CustSearchAction method mainSearch.

@TransactionDemarcate(joinToken = true)
public ActionForward mainSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CustSearchActionForm actionForm = (CustSearchActionForm) form;
    Short officeId = getShortValue(actionForm.getOfficeId());
    String searchString = actionForm.getSearchString();
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
    super.search(mapping, form, request, response);
    if (searchString == null || searchString.equals("")) {
        ActionErrors errors = new ActionErrors();
        errors.add(CustomerSearchConstants.NAMEMANDATORYEXCEPTION, new ActionMessage(CustomerSearchConstants.NAMEMANDATORYEXCEPTION));
        request.setAttribute(Globals.ERROR_KEY, errors);
        return mapping.findForward(ActionForwards.mainSearch_success.toString());
    }
    if (officeId != null && officeId != 0) {
        addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(officeId).getOfficeName(), request);
    } else {
        addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(userContext.getBranchId()).getOfficeName(), request);
    }
    searchString = SearchUtils.normalizeSearchString(searchString);
    if (searchString.equals("")) {
        throw new CustomerException(CustomerSearchConstants.NAMEMANDATORYEXCEPTION);
    }
    if (actionForm.getFilters() == null) {
        actionForm.setFilters(new SearchFiltersDto());
    }
    QueryResult customerSearchResult = new CustomerPersistence().search(searchString, officeId, userContext.getId(), userContext.getBranchId(), actionForm.getFilters());
    SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, customerSearchResult, request);
    return mapping.findForward(ActionForwards.mainSearch_success.toString());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) QueryResult(org.mifos.framework.hibernate.helper.QueryResult) CustSearchActionForm(org.mifos.customers.struts.actionforms.CustSearchActionForm) UserContext(org.mifos.security.util.UserContext) ActionMessage(org.apache.struts.action.ActionMessage) SearchFiltersDto(org.mifos.dto.screen.SearchFiltersDto) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) ActionErrors(org.apache.struts.action.ActionErrors) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 70 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class PictureFormFile method updateMfiInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer clientId = clientInSession.getCustomerId();
    Integer oldVersionNumber = clientInSession.getVersionNo();
    boolean trained = false;
    if (trainedValue(actionForm) != null && trainedValue(actionForm).equals(YesNoFlag.YES.getValue())) {
        trained = true;
    }
    DateTime trainedDate = null;
    try {
        java.sql.Date inputDate = trainedDate(actionForm);
        if (inputDate != null) {
            trainedDate = new DateTime(trainedDate(actionForm));
        }
    } catch (InvalidDateException e) {
        throw new CustomerException(ClientConstants.TRAINED_DATE_MANDATORY);
    }
    Short personnelId = Short.valueOf("-1");
    if (groupFlagValue(actionForm).equals(YesNoFlag.NO.getValue())) {
        if (actionForm.getLoanOfficerIdValue() != null) {
            personnelId = actionForm.getLoanOfficerIdValue();
        }
    } else if (groupFlagValue(actionForm).equals(YesNoFlag.YES.getValue())) {
        // TODO for an urgent fix this reads client to get personnelId.
        // Client is read again in updateClientMfiInfo. Refactor to only read in
        // updateClientMfiInfo.
        ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId);
        personnelId = client.getPersonnel().getPersonnelId();
    }
    ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdate(clientId, oldVersionNumber, personnelId, externalId(actionForm), trained, trainedDate);
    this.clientServiceFacade.updateClientMfiInfo(clientMfiInfoUpdate);
    return mapping.findForward(ActionForwards.updateMfiInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) CustomerException(org.mifos.customers.exceptions.CustomerException) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ClientMfiInfoUpdate(org.mifos.dto.domain.ClientMfiInfoUpdate) ClientBO(org.mifos.customers.client.business.ClientBO) DateTime(org.joda.time.DateTime) Date(java.sql.Date) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CustomerException (org.mifos.customers.exceptions.CustomerException)103 Test (org.junit.Test)52 UserContext (org.mifos.security.util.UserContext)29 ClientBO (org.mifos.customers.client.business.ClientBO)23 GroupBuilder (org.mifos.domain.builders.GroupBuilder)21 PersistenceException (org.mifos.framework.exceptions.PersistenceException)21 BusinessRuleException (org.mifos.service.BusinessRuleException)21 CenterBO (org.mifos.customers.center.business.CenterBO)20 GroupBO (org.mifos.customers.group.business.GroupBO)20 AccountException (org.mifos.accounts.exceptions.AccountException)18 CenterBuilder (org.mifos.domain.builders.CenterBuilder)18 ArrayList (java.util.ArrayList)17 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)13 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 MifosUser (org.mifos.security.MifosUser)11 DateTime (org.joda.time.DateTime)10