Search in sources :

Example 6 with CustomerException

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

the class ClientBO method createDepositSchedule.

/**
     * delete when usage in constructor is removed...
     */
@Deprecated
public void createDepositSchedule(final List<Days> workingDays, final List<Holiday> holidays) throws CustomerException {
    try {
        if (getParentCustomer() != null) {
            List<SavingsBO> savingsList = getCustomerPersistence().retrieveSavingsAccountForCustomer(getParentCustomer().getCustomerId());
            if (getParentCustomer().getParentCustomer() != null) {
                savingsList.addAll(getCustomerPersistence().retrieveSavingsAccountForCustomer(getParentCustomer().getParentCustomer().getCustomerId()));
            }
            for (SavingsBO savings : savingsList) {
                savings.setUserContext(getUserContext());
                savings.generateAndUpdateDepositActionsForClient(this, workingDays, holidays);
            }
        }
    } catch (PersistenceException pe) {
        throw new CustomerException(pe);
    } catch (AccountException ae) {
        throw new CustomerException(ae);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) AccountException(org.mifos.accounts.exceptions.AccountException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Example 7 with CustomerException

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

the class ClientBO method updatePersonalInfo.

public void updatePersonalInfo(ClientPersonalInfoUpdate personalInfo) throws CustomerException {
    this.governmentId = personalInfo.getGovernmentId();
    try {
        setDateOfBirth(DateUtils.getDateAsSentFromBrowser(personalInfo.getDateOfBirth()));
    } catch (InvalidDateException e) {
        throw new CustomerException(ClientConstants.INVALID_DOB_EXCEPTION);
    }
    ClientNameDetailDto clientName = personalInfo.getClientNameDetails();
    this.getClientName().updateNameDetails(clientName);
    this.firstName = clientName.getFirstName();
    this.lastName = clientName.getLastName();
    this.secondLastName = clientName.getSecondLastName();
    if (personalInfo.getSpouseFather() != null) {
        // can be null when family details configuration is turned on
        if (this.getSpouseName() != null) {
            this.getSpouseName().updateNameDetails(personalInfo.getSpouseFather());
        } else {
            ClientNameDetailEntity spouseFatherNameDetailEntity = new ClientNameDetailEntity(this, personalInfo.getSpouseFather().getSecondLastName(), personalInfo.getSpouseFather());
            addNameDetailSet(spouseFatherNameDetailEntity);
        }
    }
    this.updateClientDetails(personalInfo.getClientDetail());
    setDisplayName(personalInfo.getClientDisplayName());
    Address address = null;
    if (personalInfo.getAddress() != null) {
        ;
    }
    {
        address = new Address(personalInfo.getAddress().getLine1(), personalInfo.getAddress().getLine2(), personalInfo.getAddress().getLine3(), personalInfo.getAddress().getCity(), personalInfo.getAddress().getState(), personalInfo.getAddress().getCountry(), personalInfo.getAddress().getZip(), personalInfo.getAddress().getPhoneNumber());
        updateAddress(address);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) Address(org.mifos.framework.business.util.Address) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto)

Example 8 with CustomerException

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

the class CustomerServiceImpl method createCenter.

@Override
public final void createCenter(CenterBO customer, MeetingBO meeting, List<AccountFeesEntity> accountFees) {
    try {
        customer.validate();
        customer.validateMeetingAndFees(accountFees);
        customerDao.validateCenterNameIsNotTakenForOffice(customer.getDisplayName(), customer.getOfficeId());
        createCustomer(customer, meeting, accountFees);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), new Object[] { customer.getDisplayName() });
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException)

Example 9 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, CenterBO receivingCenter) throws CustomerException {
    group.validateReceivingCenter(receivingCenter);
    group.validateNoActiveAccountsExist();
    if (group.isDifferentBranch(receivingCenter.getOffice())) {
        customerDao.validateGroupNameIsNotTakenForOffice(group.getDisplayName(), receivingCenter.getOfficeId());
    }
    CustomerBO oldParent = group.getParentCustomer();
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(group);
        boolean regenerateSchedules = group.transferTo(receivingCenter);
        if (oldParent != null) {
            oldParent.updateDetails(group.getUserContext());
            customerDao.save(oldParent);
        }
        receivingCenter.updateDetails(group.getUserContext());
        customerDao.save(receivingCenter);
        group.updateDetails(group.getUserContext());
        customerDao.save(group);
        Set<CustomerBO> clients = group.getChildren();
        for (CustomerBO client : clients) {
            client.setUserContext(group.getUserContext());
            ((ClientBO) client).handleGroupTransfer();
            client.setUpdateDetails();
            customerDao.save(client);
        }
        hibernateTransactionHelper.flushSession();
        GroupBO groupInitialised = group;
        if (regenerateSchedules) {
            CalendarEvent calendarEvents = holidayDao.findCalendarEventsForThisYearAndNext(group.getOfficeId());
            groupInitialised = customerDao.findGroupBySystemId(group.getGlobalCustNum());
            handleChangeInMeetingSchedule(groupInitialised, calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
        }
        hibernateTransactionHelper.commitTransaction();
        return groupInitialised.getGlobalCustNum();
    } catch (ApplicationException e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (Exception e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        this.hibernateTransactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) GroupBO(org.mifos.customers.group.business.GroupBO) CalendarEvent(org.mifos.calendar.CalendarEvent) 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 10 with CustomerException

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

the class CustomerServiceImpl method updateClientStatus.

@Override
public final void updateClientStatus(ClientBO client, CustomerStatus oldStatus, CustomerStatus newStatus, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote) throws CustomerException {
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(client.getUserContext().getId());
    handeClientChangeOfStatus(client, newStatus);
    CustomerStatusFlagEntity customerStatusFlagEntity = populateCustomerStatusFlag(customerStatusFlag);
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(client);
        client.clearCustomerFlagsIfApplicable(oldStatus, newStatus);
        client.updateCustomerStatus(newStatus);
        changeStatus(client, oldStatus, newStatus);
        if (customerStatusFlagEntity != null) {
            client.addCustomerFlag(customerStatusFlagEntity);
        }
        client.addCustomerNotes(customerNote);
        this.handleChangeOfClientStatusToClosedOrCancelled(client, customerStatusFlag, customerNote, loggedInUser);
        customerDao.save(client);
        hibernateTransactionHelper.commitTransaction();
    } catch (ApplicationException e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (Exception e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        this.hibernateTransactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) 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)

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