use of org.mifos.reports.branchreport.BranchReportClientSummaryBO in project head by mifos.
the class BranchReportPersistenceDataAggregator method createClientDropOutRateSummary.
private BranchReportClientSummaryBO createClientDropOutRateSummary(OfficeBO branchOffice) throws ServiceException {
BigDecimal clientDropOutRateForOffice = customerBusinessService.getClientDropOutRateForOffice(branchOffice);
BigDecimal veryPoorClientDropoutRateForOffice = customerBusinessService.getVeryPoorClientDropoutRateForOffice(branchOffice);
return new BranchReportClientSummaryBO(BranchReportClientSummaryBO.DROP_OUT_RATE, clientDropOutRateForOffice, veryPoorClientDropoutRateForOffice);
}
use of org.mifos.reports.branchreport.BranchReportClientSummaryBO in project head by mifos.
the class BranchReportSqlDataAggregator method fetchClientSummaries.
@Override
public List<BranchReportClientSummaryBO> fetchClientSummaries(OfficeBO branchOffice) throws ServiceException {
List<BranchReportClientSummaryBO> clientSummaries = new ArrayList<BranchReportClientSummaryBO>();
try {
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.CENTER_COUNT, persistence.getCustomerCount(branchOffice.getOfficeId(), CustomerLevel.CENTER), null));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.GROUP_COUNT, persistence.getCustomerCount(branchOffice.getOfficeId(), CustomerLevel.GROUP), null));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.PORTFOLIO_AT_RISK, branchReportService.extractPortfolioAtRiskForOffice(branchOffice, configService.getGracePeriodDays()), null));
Map<String, Integer> customerCountBasedOnStatus = persistence.getCustomerCountBasedOnStatus(branchOffice.getOfficeId(), CustomerLevel.CLIENT, CollectionUtils.asList(new String[] { CUSTOMER_WAS_ACTIVE, CUSTOMER_WAS_HOLD, CUSTOMER_WAS_CLOSE }));
Map<String, Integer> customerCountBasedOnStatusForPoorClients = persistence.getVeryPoorCustomerCountBasedOnStatus(branchOffice.getOfficeId(), CustomerLevel.CLIENT, CollectionUtils.asList(new String[] { CUSTOMER_WAS_ACTIVE, CUSTOMER_WAS_HOLD, CUSTOMER_WAS_CLOSE }));
Integer activeClientCount = nullSafeValue(customerCountBasedOnStatus.get(CUSTOMER_WAS_ACTIVE));
Integer activeVeryPoorClientCount = nullSafeValue(customerCountBasedOnStatusForPoorClients.get(CUSTOMER_WAS_ACTIVE));
Integer holdClientCount = nullSafeValue(customerCountBasedOnStatus.get(CUSTOMER_WAS_HOLD));
Integer holdVeryPoorClientCount = nullSafeValue(customerCountBasedOnStatusForPoorClients.get(CUSTOMER_WAS_HOLD));
Integer closedClientCount = nullSafeValue(customerCountBasedOnStatus.get(CUSTOMER_WAS_CLOSE));
Integer closedVeryPoorClientCount = nullSafeValue(customerCountBasedOnStatusForPoorClients.get(CUSTOMER_WAS_CLOSE));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.ACTIVE_CLIENTS_COUNT, activeClientCount, activeVeryPoorClientCount));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.ON_HOLDS_COUNT, holdClientCount, holdVeryPoorClientCount));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.DROP_OUTS_COUNT, closedClientCount, closedVeryPoorClientCount));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.DROP_OUT_RATE, NumberUtils.getPercentage(closedClientCount, closedClientCount + activeClientCount + holdClientCount), NumberUtils.getPercentage(closedVeryPoorClientCount, closedVeryPoorClientCount + activeVeryPoorClientCount + holdVeryPoorClientCount)));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.ACTIVE_BORROWERS_COUNT, persistence.getActiveBorrowersCount(branchOffice.getOfficeId(), CustomerLevel.CLIENT), persistence.getVeryPoorActiveBorrowersCount(branchOffice.getOfficeId(), CustomerLevel.CLIENT)));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.ACTIVE_SAVERS_COUNT, persistence.getActiveSaversCount(branchOffice.getOfficeId(), CustomerLevel.CLIENT), persistence.getVeryPoorActiveSaversCount(branchOffice.getOfficeId(), CustomerLevel.CLIENT)));
clientSummaries.add(createLoanAccountDormantClientsSummary(branchOffice));
clientSummaries.add(createSavingAccountDormantClientsSummary(branchOffice));
clientSummaries.add(new BranchReportClientSummaryBO(BranchReportClientSummaryBO.REPLACEMENTS_COUNT, persistence.getReplacementCountForOffice(branchOffice.getOfficeId(), CustomerLevel.CLIENT, configService.getReplacementFieldId(), configService.getReplacementFieldValue()), persistence.getVeryPoorReplaceCountForOffice(branchOffice.getOfficeId(), CustomerLevel.CLIENT, configService.getReplacementFieldId(), configService.getReplacementFieldValue())));
} catch (PersistenceException e) {
throw new ServiceException(e);
}
return clientSummaries;
}
use of org.mifos.reports.branchreport.BranchReportClientSummaryBO in project head by mifos.
the class BranchReportClientSummaryHelperIntegrationTest method assertClientSummary.
private void assertClientSummary(BranchReportBO branchReport) throws PersistenceException {
Assert.assertNotNull(branchReport.getBranchReportId());
Set<BranchReportClientSummaryBO> branchReportClientSummaries = branchReport.getClientSummaries();
Assert.assertNotNull(branchReportClientSummaries);
Assert.assertEquals(12, branchReportClientSummaries.size());
Predicate predicate = new BranchReportClientSummaryBatchBOExtractor().matchAllPredicates(branchReportClientSummaries);
Assert.assertNull(predicate + " not found in summaries", predicate);
}
Aggregations