use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class OfficeBusinessServiceTest method testInvalidConnectionInGetChildOffice.
@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetChildOffice() throws PersistenceException {
try {
String searchId = "somestr";
when(officePersistence.getChildOffices(searchId)).thenThrow(new PersistenceException("some exception"));
service.getChildOffices(searchId);
junit.framework.Assert.fail("should fail because of invalid session");
} catch (ServiceException e) {
}
}
use of org.mifos.framework.exceptions.ServiceException 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.framework.exceptions.ServiceException in project head by mifos.
the class BranchReportStaffSummaryHelper method populateStaffSummary.
public void populateStaffSummary() throws BatchJobException {
try {
List<BranchReportStaffSummaryBO> staffSummaries = branchReportService.extractBranchReportStaffSummary(branchReport.getBranchId(), branchReportConfigService.getGracePeriodDays(), branchReportConfigService.getCurrency());
branchReport.addStaffSummaries(staffSummaries);
} catch (ServiceException e) {
throw new BatchJobException(e);
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class ReportsDataServiceTest method setUp.
@Override
protected void setUp() throws Exception {
loanPrdBusinessServiceMock = createMock(LoanPrdBusinessService.class);
personnelBusinessServiceMock = createMock(PersonnelBusinessService.class);
officeBusinessServiceMock = createMock(OfficeBusinessService.class);
personnelMock = createMock(PersonnelBO.class);
legacyLoanDaoMock = createMock(LegacyLoanDao.class);
expectedException = new ServiceException("someServiceException");
userId = 1;
branchId = 2;
localeId = 3;
loanOfficerId = 3;
loanProductId = 4;
reportsDataService = new ReportsDataService();
reportsDataService.setLoanPrdBusinessService(loanPrdBusinessServiceMock);
reportsDataService.setPersonnelBusinessService(personnelBusinessServiceMock);
reportsDataService.setOfficeBusinessService(officeBusinessServiceMock);
reportsDataService.setPersonnel(personnelMock);
reportsDataService.setlegacyLoanDao(legacyLoanDaoMock);
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class BranchReportService method getStaffingLevelSummary.
@Override
public List<BranchReportStaffingLevelSummaryBO> getStaffingLevelSummary(Integer branchId, String runDate) throws ServiceException {
try {
List<BranchReportStaffingLevelSummaryBO> staffingLevelSummary = branchReportPersistence.getBranchReportStaffingLevelSummary(convertIntegerToShort(branchId), ReportUtils.parseReportDate(runDate));
Collections.sort(staffingLevelSummary);
return staffingLevelSummary;
} catch (PersistenceException e) {
throw new ServiceException(e);
} catch (ParseException e) {
throw new ServiceException(e);
}
}
Aggregations