Search in sources :

Example 66 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class CenterServiceFacadeWebTier method updateCenter.

@Override
public void updateCenter(CenterUpdate centerUpdate) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        customerService.updateCenter(userContext, centerUpdate);
    } catch (ApplicationException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser)

Example 67 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class ClientServiceFacadeWebTier method previewClient.

@Override
public ProcessRulesDto previewClient(String governmentId, DateTime dateOfBirth, String clientName, boolean defaultFeeRemoval, Short officeId, Short loanOfficerId) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        boolean clientPendingApprovalStateEnabled = ProcessFlowRules.isClientPendingApprovalStateEnabled();
        boolean governmentIdValidationFailing = false;
        boolean duplicateNameOnClosedClient = false;
        boolean duplicateNameOnBlackListedClient = false;
        boolean governmentIdValidationUnclosedFailing = false;
        boolean duplicateNameOnClient = false;
        List<ClientBO> matchedClients = new ArrayList<ClientBO>();
        List<ClientBO> temp;
        if (defaultFeeRemoval) {
            customerDao.checkPermissionForDefaultFeeRemoval(userContext, officeId, loanOfficerId);
        }
        if (StringUtils.isNotBlank(governmentId)) {
            temp = this.customerDao.validateGovernmentIdForUnclosedClient(governmentId);
            if (temp != null) {
                matchedClients.addAll(temp);
            }
            governmentIdValidationUnclosedFailing = temp != null && temp.size() > 0;
            if (!governmentIdValidationUnclosedFailing) {
                temp = this.customerDao.validateGovernmentIdForClient(governmentId);
                if (temp != null) {
                    matchedClients.addAll(temp);
                }
                governmentIdValidationFailing = temp != null && temp.size() > 0;
            }
        }
        if (!governmentIdValidationFailing && !governmentIdValidationUnclosedFailing) {
            temp = this.customerDao.validateForBlackListedClientsOnNameAndDob(clientName, dateOfBirth);
            if (temp != null) {
                matchedClients.addAll(temp);
            }
            duplicateNameOnBlackListedClient = temp != null && temp.size() > 0;
            if (!duplicateNameOnBlackListedClient) {
                temp = this.customerDao.validateForClosedClientsOnNameAndDob(clientName, dateOfBirth);
                if (temp != null) {
                    matchedClients.addAll(temp);
                }
                duplicateNameOnClosedClient = temp != null && temp.size() > 0;
                if (!duplicateNameOnClosedClient) {
                    temp = this.customerDao.validateForClientsOnName(clientName);
                    if (temp != null) {
                        matchedClients.addAll(temp);
                    }
                    duplicateNameOnClient = temp != null && temp.size() > 0;
                }
            }
        }
        List<MatchedClientDto> matched = new ArrayList<MatchedClientDto>();
        for (ClientBO client : matchedClients) {
            matched.add(new MatchedClientDto(client.getGlobalCustNum(), client.getDisplayName(), client.getAddress().getPhoneNumber(), client.getGovernmentId(), client.getDisplayAddress(), client.getOffice().getOfficeName(), client.getOffice().getGlobalOfficeNum()));
        }
        return new ProcessRulesDto(clientPendingApprovalStateEnabled, governmentIdValidationFailing, duplicateNameOnClosedClient, duplicateNameOnBlackListedClient, governmentIdValidationUnclosedFailing, duplicateNameOnClient, matched);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ProcessRulesDto(org.mifos.dto.domain.ProcessRulesDto) CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) MatchedClientDto(org.mifos.dto.domain.MatchedClientDto) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser)

Example 68 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class ClientServiceFacadeWebTier method updateFamilyInfo.

@Override
public void updateFamilyInfo(ClientFamilyInfoUpdate clientFamilyInfoUpdate) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        this.customerService.updateClientFamilyInfo(userContext, clientFamilyInfoUpdate);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser)

Example 69 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.

@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
        client.updateDetails(userContext);
        client.checkIfClientIsATitleHolder();
        List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
        boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
        boolean isActive = client.isActive();
        Short loanOfficerId = client.getPersonnel().getPersonnelId();
        CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
        return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ClientRemovalFromGroupDto(org.mifos.dto.screen.ClientRemovalFromGroupDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) BusinessRuleException(org.mifos.service.BusinessRuleException) CenterCreation(org.mifos.dto.domain.CenterCreation)

Example 70 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class MeetingFactory method create.

public MeetingBO create(MeetingDto meetingDto) {
    try {
        MeetingDetailsDto meetingDetailsDto = meetingDto.getMeetingDetailsDto();
        MeetingBO meeting = new MeetingBO(RecurrenceType.fromInt(meetingDetailsDto.getRecurrenceTypeId().shortValue()), meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING);
        RankOfDay rank = null;
        Integer weekOfMonth = meetingDetailsDto.getRecurrenceDetails().getWeekOfMonth();
        if (weekOfMonth != null && weekOfMonth > 0) {
            rank = RankOfDay.getRankOfDay(meetingDetailsDto.getRecurrenceDetails().getWeekOfMonth());
        }
        WeekDay weekDay = null;
        Integer weekDayNum = meetingDetailsDto.getRecurrenceDetails().getDayOfWeek();
        if (weekDayNum != null && weekDayNum > 0) {
            weekDay = WeekDay.getWeekDay(meetingDetailsDto.getRecurrenceDetails().getDayOfWeek());
        }
        if (meetingDetailsDto.getRecurrenceDetails().getDayNumber() > 0) {
            meeting.update(meetingDetailsDto.getRecurrenceDetails().getDayNumber().shortValue(), meetingDto.getMeetingPlace());
        }
        if (rank != null && weekDay != null) {
            meeting = new MeetingBO(weekDay, rank, meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
        } else if (weekDay != null) {
            meeting = new MeetingBO(weekDay, meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
        }
        if (meetingDetailsDto.getRecurrenceTypeId().equals(new Integer(RecurrenceType.DAILY.getValue().shortValue()))) {
            meeting = new MeetingBO(meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateTimeAtStartOfDay().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
        }
        return meeting;
    } catch (MeetingException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) BusinessRuleException(org.mifos.service.BusinessRuleException) RankOfDay(org.mifos.application.meeting.util.helpers.RankOfDay) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) MeetingDetailsDto(org.mifos.dto.domain.MeetingDetailsDto)

Aggregations

BusinessRuleException (org.mifos.service.BusinessRuleException)140 MifosRuntimeException (org.mifos.core.MifosRuntimeException)68 UserContext (org.mifos.security.util.UserContext)63 MifosUser (org.mifos.security.MifosUser)61 AccountException (org.mifos.accounts.exceptions.AccountException)46 PersistenceException (org.mifos.framework.exceptions.PersistenceException)43 ApplicationException (org.mifos.framework.exceptions.ApplicationException)33 LocalDate (org.joda.time.LocalDate)31 ServiceException (org.mifos.framework.exceptions.ServiceException)30 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)26 ArrayList (java.util.ArrayList)23 CustomerBO (org.mifos.customers.business.CustomerBO)22 Money (org.mifos.framework.util.helpers.Money)22 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)20 CustomerException (org.mifos.customers.exceptions.CustomerException)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)16 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)16 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)16 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)16