Search in sources :

Example 76 with ServiceException

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) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 77 with ServiceException

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;
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) BranchReportClientSummaryBO(org.mifos.reports.branchreport.BranchReportClientSummaryBO) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 78 with ServiceException

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);
    }
}
Also used : BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) ServiceException(org.mifos.framework.exceptions.ServiceException) BranchReportStaffSummaryBO(org.mifos.reports.branchreport.BranchReportStaffSummaryBO)

Example 79 with ServiceException

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);
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) OfficeBusinessService(org.mifos.customers.office.business.service.OfficeBusinessService) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanPrdBusinessService(org.mifos.accounts.productdefinition.business.service.LoanPrdBusinessService) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao)

Example 80 with ServiceException

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);
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO) ParseException(java.text.ParseException)

Aggregations

ServiceException (org.mifos.framework.exceptions.ServiceException)93 PersistenceException (org.mifos.framework.exceptions.PersistenceException)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)39 Test (org.junit.Test)34 ExpectedException (org.springframework.test.annotation.ExpectedException)29 ArrayList (java.util.ArrayList)24 UserContext (org.mifos.security.util.UserContext)19 AccountBO (org.mifos.accounts.business.AccountBO)17 MifosUser (org.mifos.security.MifosUser)16 LoanBO (org.mifos.accounts.loan.business.LoanBO)15 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)14 AccountException (org.mifos.accounts.exceptions.AccountException)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 BusinessRuleException (org.mifos.service.BusinessRuleException)11 Date (java.util.Date)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 BigDecimal (java.math.BigDecimal)6 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)6 DateTimeService (org.mifos.framework.util.DateTimeService)6 LocalDate (org.joda.time.LocalDate)5