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();
}
}
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations