use of org.mifos.dto.domain.SurveyDto in project head by mifos.
the class LoanDaoHibernate method getAccountSurveyDto.
@SuppressWarnings("unchecked")
@Override
public List<SurveyDto> getAccountSurveyDto(final Integer accountId) {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("ACCOUNT_ID", accountId);
List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("Account.getAccountSurveyDto", queryParameters);
if (queryResult.size() == 0) {
return null;
}
List<SurveyDto> accountSurveys = new ArrayList<SurveyDto>();
Integer instanceId;
String surveyName;
Date dateConducted;
for (Object[] accountSurvey : queryResult) {
instanceId = (Integer) accountSurvey[0];
surveyName = (String) accountSurvey[1];
dateConducted = (Date) accountSurvey[2];
accountSurveys.add(new SurveyDto(instanceId, surveyName, dateConducted));
}
return accountSurveys;
}
use of org.mifos.dto.domain.SurveyDto 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);
}
use of org.mifos.dto.domain.SurveyDto in project head by mifos.
the class CenterServiceFacadeWebTier method getCenterInformationDto.
@Override
public CenterInformationDto getCenterInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CenterBO center = customerDao.findCenterBySystemId(globalCustNum);
if (center == null) {
throw new MifosRuntimeException("Center not found for globalCustNum" + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
CenterDisplayDto centerDisplay = customerDao.getCenterDisplayDto(center.getCustomerId(), userContext);
Integer centerId = center.getCustomerId();
String searchId = center.getSearchId();
Short branchId = centerDisplay.getBranchId();
CustomerAccountSummaryDto customerAccountSummary = customerDao.getCustomerAccountSummaryDto(centerId);
CenterPerformanceHistoryDto centerPerformanceHistory = customerDao.getCenterPerformanceHistory(searchId, branchId);
CustomerAddressDto centerAddress = customerDao.getCustomerAddressDto(center);
List<CustomerDetailDto> groups = customerDao.getGroupsOtherThanClosedAndCancelledForGroup(searchId, branchId);
List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(centerId);
List<CustomerPositionOtherDto> customerPositions = customerDao.getCustomerPositionDto(centerId, userContext);
List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(centerId, userContext);
CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(center.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(centerId);
List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.SAVINGS_ACCOUNT.getValue().intValue()) {
closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
}
}
//new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CENTER);
Boolean activeSurveys = Boolean.FALSE;
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
return new CenterInformationDto(centerDisplay, customerAccountSummary, centerPerformanceHistory, centerAddress, groups, recentCustomerNotes, customerPositions, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedSavingsAccounts);
}
use of org.mifos.dto.domain.SurveyDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveLoanInformation.
@Override
public LoanInformationDto retrieveLoanInformation(String globalAccountNum) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
LoanBO loan = this.loanDao.findByGlobalAccountNum(globalAccountNum);
if (loan.isDecliningBalanceInterestRecalculation()) {
loanBusinessService.computeExtraInterest(loan, DateUtils.getCurrentDateWithoutTimeStamp());
}
try {
personnelDao.checkAccessPermission(userContext, loan.getOfficeId(), loan.getCustomer().getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
String fundName = null;
if (loan.getFund() != null) {
fundName = loan.getFund().getFundName();
}
// boolean activeSurveys = surveysPersistence.isActiveSurveysForSurveyType(SurveyType.LOAN);
boolean activeSurveys = false;
List<SurveyDto> accountSurveys = loanDao.getAccountSurveyDto(loan.getAccountId());
LoanSummaryDto loanSummary = new LoanSummaryDto(loan.getLoanSummary().getOriginalPrincipal().toString(), loan.getLoanSummary().getPrincipalPaid().toString(), loan.getLoanSummary().getPrincipalDue().toString(), loan.getLoanSummary().getOriginalInterest().toString(), loan.getLoanSummary().getInterestPaid().toString(), loan.getLoanSummary().getInterestDue().toString(), loan.getLoanSummary().getOriginalFees().toString(), loan.getLoanSummary().getFeesPaid().toString(), loan.getLoanSummary().getFeesDue().toString(), loan.getLoanSummary().getOriginalPenalty().toString(), loan.getLoanSummary().getPenaltyPaid().toString(), loan.getLoanSummary().getPenaltyDue().toString(), loan.getLoanSummary().getTotalLoanAmnt().toString(), loan.getLoanSummary().getTotalAmntPaid().toString(), loan.getLoanSummary().getTotalAmntDue().toString());
LoanPerformanceHistoryEntity performanceHistory = loan.getPerformanceHistory();
LoanPerformanceHistoryDto loanPerformanceHistory = new LoanPerformanceHistoryDto(performanceHistory.getNoOfPayments(), performanceHistory.getTotalNoOfMissedPayments(), performanceHistory.getDaysInArrears(), performanceHistory.getLoanMaturityDate());
Set<AccountFeesDto> accountFeesDtos = new HashSet<AccountFeesDto>();
if (!loan.getAccountFees().isEmpty()) {
for (AccountFeesEntity accountFeesEntity : loan.getAccountFees()) {
AccountFeesDto accountFeesDto = new AccountFeesDto(accountFeesEntity.getFees().getFeeFrequency().getFeeFrequencyType().getId(), (accountFeesEntity.getFees().getFeeFrequency().getFeePayment() != null ? accountFeesEntity.getFees().getFeeFrequency().getFeePayment().getId() : null), accountFeesEntity.getFeeStatus(), accountFeesEntity.getFees().getFeeName(), accountFeesEntity.getAccountFeeAmount().toString(), getMeetingRecurrence(accountFeesEntity.getFees().getFeeFrequency().getFeeMeetingFrequency(), userContext), accountFeesEntity.getFees().getFeeId());
accountFeesDtos.add(accountFeesDto);
}
}
Set<AccountPenaltiesDto> accountPenaltiesDtos = new HashSet<AccountPenaltiesDto>();
if (!loan.getAccountPenalties().isEmpty()) {
for (AccountPenaltiesEntity accountPenaltiesEntity : loan.getAccountPenalties()) {
accountPenaltiesDtos.add(new AccountPenaltiesDto(accountPenaltiesEntity.getPenalty().getPenaltyFrequency().getId(), accountPenaltiesEntity.getPenaltyStatus(), accountPenaltiesEntity.getPenalty().getPenaltyName(), accountPenaltiesEntity.getAccountPenaltyAmount().toString(), accountPenaltiesEntity.getPenalty().getPenaltyFrequency().getName(), accountPenaltiesEntity.getPenalty().getPenaltyId()));
}
}
Set<String> accountFlagNames = getAccountStateFlagEntityNames(loan.getAccountFlags());
Short accountStateId = loan.getAccountState().getId();
String accountStateName = getAccountStateName(accountStateId);
boolean disbursed = AccountState.isDisbursed(accountStateId);
String gracePeriodTypeName = getGracePeriodTypeName(loan.getGracePeriodType().getId());
Short interestType = loan.getInterestType().getId();
String interestTypeName = getInterestTypeName(interestType);
List<CustomerNoteDto> recentNoteDtos = new ArrayList<CustomerNoteDto>();
List<AccountNotesEntity> recentNotes = loan.getRecentAccountNotes();
for (AccountNotesEntity accountNotesEntity : recentNotes) {
recentNoteDtos.add(new CustomerNoteDto(accountNotesEntity.getCommentDate(), accountNotesEntity.getComment(), accountNotesEntity.getPersonnelName()));
}
CustomValueDto customValueDto = legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES);
List<CustomValueListElementDto> collateralTypes = customValueDto.getCustomValueListElements();
String collateralTypeName = null;
for (CustomValueListElementDto collateralType : collateralTypes) {
if (collateralType.getId() == loan.getCollateralTypeId()) {
collateralTypeName = collateralType.getName();
break;
}
}
return new LoanInformationDto(loan.getLoanOffering().getPrdOfferingName(), globalAccountNum, accountStateId, accountStateName, disbursed, accountFlagNames, loan.getDisbursementDate(), loan.isRedone(), loan.getBusinessActivityId(), loan.getAccountId(), gracePeriodTypeName, interestType, interestTypeName, loan.getCustomer().getCustomerId(), loan.getAccountType().getAccountTypeId(), loan.getOffice().getOfficeId(), loan.getPersonnel().getPersonnelId(), loan.getNextMeetingDate(), loan.getTotalAmountDue().toString(), loan.getTotalAmountInArrears().toString(), loanSummary, loan.getLoanActivityDetails().isEmpty() ? false : true, loan.getInterestRate(), loan.isInterestDeductedAtDisbursement(), loan.getLoanMeeting().getMeetingDetails().getRecurAfter(), loan.getLoanMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId(), loan.getLoanOffering().isPrinDueLastInst(), loan.getNoOfInstallments(), loan.getMaxMinNoOfInstall().getMinNoOfInstall(), loan.getMaxMinNoOfInstall().getMaxNoOfInstall(), loan.getGracePeriodDuration(), fundName, loan.getCollateralTypeId(), collateralTypeName, loan.getCollateralNote(), loan.getExternalId(), accountFeesDtos, loan.getCreatedDate(), loanPerformanceHistory, loan.getCustomer().isGroup(), getRecentActivityView(globalAccountNum), activeSurveys, accountSurveys, loan.getCustomer().getDisplayName(), loan.getCustomer().getGlobalCustNum(), loan.getOffice().getOfficeName(), recentNoteDtos, accountPenaltiesDtos, AccountingRules.isGroupLoanWithMembers());
}
use of org.mifos.dto.domain.SurveyDto in project head by mifos.
the class GroupLoanAccountServiceFacadeWebTier method retrieveLoanInformation.
@Override
public LoanInformationDto retrieveLoanInformation(String globalAccountNum) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
LoanBO loan = this.loanDao.findByGlobalAccountNum(globalAccountNum);
try {
personnelDao.checkAccessPermission(userContext, loan.getOfficeId(), loan.getCustomer().getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
String fundName = null;
if (loan.getFund() != null) {
fundName = loan.getFund().getFundName();
}
boolean activeSurveys = false;
List<SurveyDto> accountSurveys = loanDao.getAccountSurveyDto(loan.getAccountId());
LoanSummaryDto loanSummary = generateGroupLoanSummaryDto(new ArrayList<LoanBO>(loan.getMemberAccounts()));
LoanPerformanceHistoryEntity performanceHistory = loan.getPerformanceHistory();
LoanPerformanceHistoryDto loanPerformanceHistory = new LoanPerformanceHistoryDto(performanceHistory.getNoOfPayments(), performanceHistory.getTotalNoOfMissedPayments(), performanceHistory.getDaysInArrears(), performanceHistory.getLoanMaturityDate());
Set<AccountFeesDto> accountFeesDtos = new HashSet<AccountFeesDto>();
if (!loan.getAccountFees().isEmpty()) {
for (AccountFeesEntity accountFeesEntity : loan.getAccountFees()) {
AccountFeesDto accountFeesDto = new AccountFeesDto(accountFeesEntity.getFees().getFeeFrequency().getFeeFrequencyType().getId(), (accountFeesEntity.getFees().getFeeFrequency().getFeePayment() != null ? accountFeesEntity.getFees().getFeeFrequency().getFeePayment().getId() : null), accountFeesEntity.getFeeStatus(), accountFeesEntity.getFees().getFeeName(), accountFeesEntity.getAccountFeeAmount().toString(), getMeetingRecurrence(accountFeesEntity.getFees().getFeeFrequency().getFeeMeetingFrequency(), userContext), accountFeesEntity.getFees().getFeeId());
accountFeesDtos.add(accountFeesDto);
}
}
Set<AccountPenaltiesDto> accountPenaltiesDtos = new HashSet<AccountPenaltiesDto>();
if (!loan.getAccountPenalties().isEmpty()) {
for (AccountPenaltiesEntity accountPenaltiesEntity : loan.getAccountPenalties()) {
accountPenaltiesDtos.add(new AccountPenaltiesDto(accountPenaltiesEntity.getPenalty().getPenaltyFrequency().getId(), accountPenaltiesEntity.getPenaltyStatus(), accountPenaltiesEntity.getPenalty().getPenaltyName(), accountPenaltiesEntity.getAccountPenaltyAmount().toString(), accountPenaltiesEntity.getPenalty().getPenaltyFrequency().getName(), accountPenaltiesEntity.getPenalty().getPenaltyId()));
}
}
Set<String> accountFlagNames = getAccountStateFlagEntityNames(loan.getAccountFlags());
Short accountStateId = loan.getAccountState().getId();
String accountStateName = getAccountStateName(accountStateId);
boolean disbursed = AccountState.isDisbursed(accountStateId);
String gracePeriodTypeName = getGracePeriodTypeName(loan.getGracePeriodType().getId());
Short interestType = loan.getInterestType().getId();
String interestTypeName = getInterestTypeName(interestType);
List<CustomerNoteDto> recentNoteDtos = new ArrayList<CustomerNoteDto>();
List<AccountNotesEntity> recentNotes = loan.getRecentAccountNotes();
for (AccountNotesEntity accountNotesEntity : recentNotes) {
recentNoteDtos.add(new CustomerNoteDto(accountNotesEntity.getCommentDate(), accountNotesEntity.getComment(), accountNotesEntity.getPersonnelName()));
}
CustomValueDto customValueDto = legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES);
List<CustomValueListElementDto> collateralTypes = customValueDto.getCustomValueListElements();
String collateralTypeName = null;
for (CustomValueListElementDto collateralType : collateralTypes) {
if (collateralType.getId() == loan.getCollateralTypeId()) {
collateralTypeName = collateralType.getName();
break;
}
}
Boolean groupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
return new LoanInformationDto(loan.getLoanOffering().getPrdOfferingName(), globalAccountNum, accountStateId, accountStateName, disbursed, accountFlagNames, loan.getDisbursementDate(), loan.isRedone(), loan.getBusinessActivityId(), loan.getAccountId(), gracePeriodTypeName, interestType, interestTypeName, loan.getCustomer().getCustomerId(), loan.getAccountType().getAccountTypeId(), loan.getOffice().getOfficeId(), loan.getPersonnel().getPersonnelId(), loan.getNextMeetingDate(), loan.getTotalAmountDue().toString(), loan.getTotalAmountInArrears().toString(), loanSummary, loan.getLoanActivityDetails().isEmpty() ? false : true, loan.getInterestRate(), loan.isInterestDeductedAtDisbursement(), loan.getLoanOffering().getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter(), loan.getLoanOffering().getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId(), loan.getLoanOffering().isPrinDueLastInst(), loan.getNoOfInstallments(), loan.getMaxMinNoOfInstall().getMinNoOfInstall(), loan.getMaxMinNoOfInstall().getMaxNoOfInstall(), loan.getGracePeriodDuration(), fundName, loan.getCollateralTypeId(), collateralTypeName, loan.getCollateralNote(), loan.getExternalId(), accountFeesDtos, loan.getCreatedDate(), loanPerformanceHistory, loan.getCustomer().isGroup(), getRecentActivityView(globalAccountNum), activeSurveys, accountSurveys, loan.getCustomer().getDisplayName(), loan.getCustomer().getGlobalCustNum(), loan.getOffice().getOfficeName(), recentNoteDtos, accountPenaltiesDtos, groupLoanWithMembers);
}
Aggregations