Search in sources :

Example 56 with CustomerException

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

the class CustomerServiceImpl method updateClientMfiInfo.

@Override
public final void updateClientMfiInfo(UserContext userContext, ClientMfiInfoUpdate clientMfiInfoUpdate) throws CustomerException {
    ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientMfiInfoUpdate.getClientId());
    client.validateVersion(clientMfiInfoUpdate.getOrginalClientVersionNumber());
    client.updateDetails(userContext);
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(client);
        PersonnelBO personnel = this.personnelDao.findPersonnelById(clientMfiInfoUpdate.getPersonnelId());
        client.updateMfiInfo(personnel, clientMfiInfoUpdate);
        customerDao.save(client);
        hibernateTransactionHelper.commitTransaction();
    } catch (CustomerException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw e;
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientBO(org.mifos.customers.client.business.ClientBO) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 57 with CustomerException

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

the class CustomerServiceImpl method transferGroupTo.

@Override
public final String transferGroupTo(GroupBO group, OfficeBO transferToOffice) throws CustomerException {
    group.validateNewOffice(transferToOffice);
    group.validateNoActiveAccountsExist();
    customerDao.validateGroupNameIsNotTakenForOffice(group.getDisplayName(), transferToOffice.getOfficeId());
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(group);
        group.makeCustomerMovementEntries(transferToOffice);
        group.setPersonnel(null);
        if (group.isActive()) {
            group.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
        }
        CustomerBO oldParentOfGroup = group.getParentCustomer();
        if (oldParentOfGroup != null) {
            oldParentOfGroup.incrementChildCount();
            customerDao.save(oldParentOfGroup);
        }
        this.hibernateTransactionHelper.flushSession();
        group.generateSearchId();
        group.setUpdateDetails();
        customerDao.save(group);
        Set<CustomerBO> clients = group.getChildren();
        if (clients != null) {
            for (CustomerBO client : clients) {
                client.setUserContext(group.getUserContext());
                ((ClientBO) client).handleGroupTransfer();
                client.setUpdateDetails();
                customerDao.save(client);
            }
        }
        hibernateTransactionHelper.commitTransaction();
        return group.getGlobalCustNum();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 58 with CustomerException

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

the class CustomerServiceImpl method updateClientFamilyInfo.

@Override
public void updateClientFamilyInfo(UserContext userContext, ClientFamilyInfoUpdate clientFamilyInfoUpdate) throws CustomerException {
    ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId());
    client.validateVersion(clientFamilyInfoUpdate.getOldVersionNum());
    client.updateDetails(userContext);
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(client);
        client.updateFamilyInfo(clientFamilyInfoUpdate);
        customerDao.save(client);
        hibernateTransactionHelper.commitTransaction();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 59 with CustomerException

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

the class CenterBO method validateMeetingAndFees.

public void validateMeetingAndFees(List<AccountFeesEntity> accountFees) throws CustomerException {
    if (this.getCustomerMeeting() == null || this.getCustomerMeetingValue() == null) {
        if (accountFees.size() > 0) {
            throw new CustomerException(CustomerConstants.MEETING_REQUIRED_EXCEPTION);
        }
        throw new CustomerException(CustomerConstants.ERRORS_SPECIFY_MEETING);
    }
    for (AccountFeesEntity accountFee : accountFees) {
        if (accountFee.getFees().isPeriodic()) {
            MeetingBO feeMeeting = accountFee.getFees().getFeeFrequency().getFeeMeetingFrequency();
            if (!feeMeeting.hasSameRecurrenceAs(this.getCustomerMeetingValue())) {
                throw new CustomerException(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH);
            }
            FeeBO fee = accountFee.getFees();
            if (AccountFeesEntity.isPeriodicFeeDuplicated(accountFees, fee)) {
                throw new CustomerException(CustomerConstants.ERRORS_DUPLICATE_PERIODIC_FEE);
            }
        }
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Example 60 with CustomerException

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

the class GroupBO method update.

/**
     * @deprecated - use DAOs to do CRUD operations
     */
@Deprecated
@Override
public void update() throws CustomerException {
    try {
        setUpdateDetails();
        getCustomerPersistence().createOrUpdate(this);
    } catch (PersistenceException e) {
        throw new CustomerException(CustomerConstants.UPDATE_FAILED_EXCEPTION, e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

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