Search in sources :

Example 1 with GuarantyEntity

use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTier method disactiveGuarantiesByLoanId.

@SuppressWarnings("unchecked")
public void disactiveGuarantiesByLoanId(Integer loanId) throws PersistenceException {
    List<GuarantyEntity> guarantyEntities = legacyAccountDao.getGuarantyByLoanId(loanId);
    if (guarantyEntities != null) {
        for (GuarantyEntity guarantyEntity : guarantyEntities) {
            transactionHelper.startTransaction();
            guarantyEntity.setState(false);
            try {
                transactionHelper.commitTransaction();
            } catch (Exception e) {
                transactionHelper.rollbackTransaction();
            }
        }
    }
}
Also used : GuarantyEntity(org.mifos.accounts.loan.business.GuarantyEntity) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) BusinessRuleException(org.mifos.service.BusinessRuleException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) AccountException(org.mifos.accounts.exceptions.AccountException) PropertyNotFoundException(org.mifos.framework.exceptions.PropertyNotFoundException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException)

Example 2 with GuarantyEntity

use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveLoanGuarantors.

@Override
public List<CustomerDetailDto> retrieveLoanGuarantors(String globalAccountNum) throws PersistenceException {
    LoanBO loan = loanDao.findByGlobalAccountNum(globalAccountNum);
    List<CustomerDetailDto> guarantors = new ArrayList<CustomerDetailDto>();
    List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByLoanId(loan.getAccountId());
    for (GuarantyEntity guaranty : guaranties) {
        CustomerBO customerBO = customerDao.findCustomerById(guaranty.getGuarantorId());
        guarantors.add(new CustomerDetailDto(customerBO.getCustomerId(), customerBO.getDisplayName(), customerBO.getSearchId(), customerBO.getGlobalCustNum(), null, null, null));
    }
    return guarantors;
}
Also used : GuarantyEntity(org.mifos.accounts.loan.business.GuarantyEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO)

Example 3 with GuarantyEntity

use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveGuarantyClientInformation.

public List<LoanAccountDetailsDto> retrieveGuarantyClientInformation(ClientInformationDto clientInformationDto) throws PersistenceException {
    List<LoanAccountDetailsDto> guarantyInfo = new ArrayList<LoanAccountDetailsDto>();
    List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByGurantorId(clientInformationDto.getClientDisplay().getCustomerId());
    for (GuarantyEntity guaranty : guaranties) {
        if (guaranty.getState()) {
            LoanBO loan = loanDao.findById(guaranty.getLoanId());
            LoanAccountDetailsDto loanAccountDetailsDto = new LoanAccountDetailsDto();
            loanAccountDetailsDto.setLoanGlobalAccountNum(loan.getGlobalAccountNum());
            loanAccountDetailsDto.setClientId(loan.getCustomer().getGlobalCustNum());
            loanAccountDetailsDto.setClientName(loan.getCustomer().getDisplayName());
            guarantyInfo.add(loanAccountDetailsDto);
        }
    }
    return guarantyInfo;
}
Also used : GuarantyEntity(org.mifos.accounts.loan.business.GuarantyEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) MultipleLoanAccountDetailsDto(org.mifos.dto.screen.MultipleLoanAccountDetailsDto)

Example 4 with GuarantyEntity

use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTier method isApplicableForGuaranty.

private boolean isApplicableForGuaranty(AccountSearchResultsDto customerBO, Integer loanId) throws PersistenceException {
    Integer guarantorId = customerBO.getClientId();
    List<GuarantyEntity> guarantyEntities = legacyAccountDao.getGuarantyByGurantorId(guarantorId);
    for (GuarantyEntity guarantyEntity : guarantyEntities) {
        if (guarantyEntity.getLoanId().equals(loanId)) {
            return false;
        }
    }
    return true;
}
Also used : GuarantyEntity(org.mifos.accounts.loan.business.GuarantyEntity)

Example 5 with GuarantyEntity

use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.

the class ClientServiceFacadeWebTier method getClientInformationDto.

@Override
public ClientInformationDto getClientInformationDto(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    ClientBO client = customerDao.findClientBySystemId(globalCustNum);
    if (client == null) {
        throw new MifosRuntimeException("Client not found for globalCustNum, levelId: " + globalCustNum);
    }
    try {
        personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    ClientDisplayDto clientDisplay = this.customerDao.getClientDisplayDto(client.getCustomerId(), userContext);
    Integer clientId = client.getCustomerId();
    CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(clientId);
    ClientPerformanceHistoryDto clientPerformanceHistory = assembleClientPerformanceHistoryDto(client.getClientPerformanceHistory(), clientId);
    CustomerAddressDto clientAddress = this.customerDao.getCustomerAddressDto(client);
    List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(clientId);
    List<CustomerFlagDto> customerFlags = customerDao.getCustomerFlagDto(client.getCustomerFlags());
    List<LoanDetailDto> loanDetail = customerDao.getLoanDetailDto(client.getOpenLoanAccounts());
    List<LoanDetailDto> groupLoanDetail = customerDao.getLoanDetailDto(client.getOpenGroupLoanAccounts());
    List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(clientId, userContext);
    CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(client.getCustomerMeeting(), userContext);
    List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(clientId);
    List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
    List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
    for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
        if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
            closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
        } else {
            closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
        }
    }
    Boolean activeSurveys = Boolean.FALSE;
    //        Boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CLIENT);
    List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
    List<LoanDetailDto> guarantedLoanAccounts = new ArrayList<LoanDetailDto>();
    try {
        List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByGurantorId(clientId);
        if (guaranties != null && guaranties.size() > 0) {
            for (GuarantyEntity guaranty : guaranties) {
                if (guaranty != null && guaranty.getState() != null && guaranty.getState()) {
                    LoanBO loan = loanDao.findById(guaranty.getLoanId());
                    guarantedLoanAccounts.add(new LoanDetailDto(loan.getGlobalAccountNum(), loan.getLoanOffering().getPrdOfferingName(), loan.getAccountState().getId(), loan.getAccountState().getName(), loan.getLoanSummary().getOutstandingBalance().toString(), loan.getTotalAmountDue().toString(), loan.getAccountType().getAccountTypeId(), loan.getTotalAmountInArrears().toString()));
                }
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException("Can not get guaranted loan accounts", e);
    }
    return new ClientInformationDto(clientDisplay, customerAccountSummary, clientPerformanceHistory, clientAddress, recentCustomerNotes, customerFlags, loanDetail, groupLoanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, closedLoanAccounts, closedSavingsAccounts, guarantedLoanAccounts);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) GuarantyEntity(org.mifos.accounts.loan.business.GuarantyEntity) AccountBO(org.mifos.accounts.business.AccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ClientPerformanceHistoryDto(org.mifos.dto.screen.ClientPerformanceHistoryDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) ClientDisplayDto(org.mifos.dto.screen.ClientDisplayDto) UserContext(org.mifos.security.util.UserContext) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) MifosUser(org.mifos.security.MifosUser) CustomerFlagDto(org.mifos.dto.domain.CustomerFlagDto) AccountException(org.mifos.accounts.exceptions.AccountException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

GuarantyEntity (org.mifos.accounts.loan.business.GuarantyEntity)8 ArrayList (java.util.ArrayList)4 AccountException (org.mifos.accounts.exceptions.AccountException)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 PersistenceException (org.mifos.framework.exceptions.PersistenceException)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)3 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)3 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)3 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)3 PropertyNotFoundException (org.mifos.framework.exceptions.PropertyNotFoundException)3 ServiceException (org.mifos.framework.exceptions.ServiceException)3 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)3 SystemException (org.mifos.framework.exceptions.SystemException)3 BusinessRuleException (org.mifos.service.BusinessRuleException)3 CustomerBO (org.mifos.customers.business.CustomerBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 AccountBO (org.mifos.accounts.business.AccountBO)1 CustomerAccountSummaryDto (org.mifos.dto.domain.CustomerAccountSummaryDto)1 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)1