Search in sources :

Example 6 with BranchReportStaffSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffSummaryBO in project head by mifos.

the class BranchReportPersistence method extractBranchReportStaffSummary.

public List<BranchReportStaffSummaryBO> extractBranchReportStaffSummary(Short branchId, Integer daysInArrears, MifosCurrency currency) throws PersistenceException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(OFFICEID, branchId);
    List<Object[]> queryResults = executeNamedQuery(EXTRACT_BRANCH_REPORT_STAFF_SUMMARY_ACTIVE_BORROWERS_LOANS, params);
    Map<Short, BranchReportStaffSummaryBO> staffSummaries = new HashMap<Short, BranchReportStaffSummaryBO>();
    for (Object[] queryResult : queryResults) {
        BranchReportStaffSummaryBO staffSummary = createStaffSummaryFromResultset(queryResult, currency);
        staffSummaries.put(staffSummary.getPersonnelId(), staffSummary);
    }
    populateCustomerCounts(staffSummaries, params);
    populateTotalClientsEnrolledByPersonnel(staffSummaries);
    populateClientsEnrolledByPersonnelThisMonth(staffSummaries);
    populateOutstandingAmounts(staffSummaries, branchId, currency);
    params.put(DAYS_IN_ARREARS, daysInArrears);
    populatePortfolioAtRiskPercentage(staffSummaries, params);
    populateLoanArrearsAmountForPersonnel(staffSummaries, currency);
    return new ArrayList<BranchReportStaffSummaryBO>(staffSummaries.values());
}
Also used : HashMap(java.util.HashMap) BranchReportStaffSummaryBO(org.mifos.reports.branchreport.BranchReportStaffSummaryBO) ArrayList(java.util.ArrayList)

Example 7 with BranchReportStaffSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffSummaryBO in project head by mifos.

the class BranchReportPersistence method populateOutstandingAmounts.

void populateOutstandingAmounts(Map<Short, BranchReportStaffSummaryBO> staffSummaries, Short branchId, MifosCurrency currency) throws PersistenceException {
    List<Object[]> resultSet = executeNamedQuery(EXTRACT_BRANCH_REPORT_STAFF_SUMMARY_LOAN_AMOUNT_OUTSTANDING, populateQueryParamsWithBranchAndCurrency(branchId));
    for (Object[] outstandingAmounts : resultSet) {
        BranchReportStaffSummaryBO staffSummary = staffSummaries.get(outstandingAmounts[0]);
        staffSummary.setLoanAmountOutstanding(createMoney(currency, (BigDecimal) outstandingAmounts[1]));
        staffSummary.setInterestAndFeesAmountOutstanding(createMoney(currency, (BigDecimal) outstandingAmounts[2]));
    }
}
Also used : BranchReportStaffSummaryBO(org.mifos.reports.branchreport.BranchReportStaffSummaryBO) BigDecimal(java.math.BigDecimal)

Example 8 with BranchReportStaffSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffSummaryBO 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 9 with BranchReportStaffSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffSummaryBO in project head by mifos.

the class BranchReportServiceIntegrationTest method testGetStaffSummaryReportReturnsStaffSummaryForBranchAndDate.

@Test
public void testGetStaffSummaryReportReturnsStaffSummaryForBranchAndDate() throws Exception {
    BranchReportBO branchReportWithStaffSummary = createBranchReportWithStaffSummary(BRANCH_ID_SHORT, RUN_DATE);
    BranchReportBO otherBranchReportWithStaffSummary = createBranchReportWithStaffSummary(BRANCH_ID_SHORT, FIRST_JAN_2008);
    session.save(branchReportWithStaffSummary);
    session.save(otherBranchReportWithStaffSummary);
    List<BranchReportStaffSummaryBO> retrievedStaffSummary = branchReportService.getStaffSummary(BRANCH_ID, RUN_DATE_STR);
    Assert.assertEquals(1, retrievedStaffSummary.size());
    assertSameCollections(branchReportWithStaffSummary.getStaffSummaries(), retrievedStaffSummary);
}
Also used : BranchReportStaffSummaryBO(org.mifos.reports.branchreport.BranchReportStaffSummaryBO) BranchReportBO(org.mifos.reports.branchreport.BranchReportBO) Test(org.junit.Test)

Aggregations

BranchReportStaffSummaryBO (org.mifos.reports.branchreport.BranchReportStaffSummaryBO)9 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 BranchReportBO (org.mifos.reports.branchreport.BranchReportBO)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 PersonnelLevel (org.mifos.customers.personnel.util.helpers.PersonnelLevel)1 BatchJobException (org.mifos.framework.components.batchjobs.exceptions.BatchJobException)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 BranchReportService (org.mifos.reports.business.service.BranchReportService)1