Search in sources :

Example 1 with LoanCycleCounter

use of org.mifos.dto.screen.LoanCycleCounter in project head by mifos.

the class CustomerDaoHibernate method runLoanCycleQuery.

@SuppressWarnings("unchecked")
private List<LoanCycleCounter> runLoanCycleQuery(final String queryName, final Integer customerId) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("customerId", customerId);
    List<LoanCycleCounter> loanCycleCounters = new ArrayList<LoanCycleCounter>();
    List<Object[]> queryResult = (List<Object[]>) genericDao.executeNamedQuery(queryName, queryParameters);
    if (null != queryResult && queryResult.size() > 0) {
        for (Object[] objects : queryResult) {
            loanCycleCounters.add(new LoanCycleCounter((String) objects[0], (Integer) objects[1]));
        }
    }
    return loanCycleCounters;
}
Also used : BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LoanCycleCounter(org.mifos.dto.screen.LoanCycleCounter)

Example 2 with LoanCycleCounter

use of org.mifos.dto.screen.LoanCycleCounter in project head by mifos.

the class GroupServiceFacadeWebTier method assembleGroupPerformanceHistoryDto.

private GroupPerformanceHistoryDto assembleGroupPerformanceHistoryDto(GroupPerformanceHistoryEntity groupPerformanceHistory, String searchId, Short branchId, Integer groupId) {
    Integer activeClientCount = this.customerDao.getActiveAndOnHoldClientCountForGroup(searchId, branchId);
    Money lastGroupLoanAmountMoney = groupPerformanceHistory.getLastGroupLoanAmount();
    String lastGroupLoanAmount = "";
    if (lastGroupLoanAmountMoney != null) {
        lastGroupLoanAmount = lastGroupLoanAmountMoney.toString();
    }
    String avgLoanAmountForMember = this.customerDao.getAvgLoanAmountForMemberInGoodOrBadStanding(searchId, branchId);
    String totalLoanAmountForGroup = this.customerDao.getTotalLoanAmountForGroup(searchId, branchId);
    String portfolioAtRisk;
    String totalSavingsAmount;
    try {
        if (groupPerformanceHistory.getPortfolioAtRisk() == null) {
            portfolioAtRisk = "0";
        } else {
            portfolioAtRisk = groupPerformanceHistory.getPortfolioAtRisk().toString();
        }
    } catch (CurrencyMismatchException e) {
        portfolioAtRisk = localizedMessageLookup("errors.multipleCurrencies");
    }
    totalSavingsAmount = this.customerDao.getTotalSavingsAmountForGroupandClientsOfGroup(searchId, branchId);
    List<LoanCycleCounter> loanCycleCounters = this.customerDao.fetchLoanCycleCounter(groupId, CustomerLevel.GROUP.getValue());
    return new GroupPerformanceHistoryDto(activeClientCount.toString(), lastGroupLoanAmount, avgLoanAmountForMember, totalLoanAmountForGroup, portfolioAtRisk, totalSavingsAmount, loanCycleCounters);
}
Also used : Money(org.mifos.framework.util.helpers.Money) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) GroupPerformanceHistoryDto(org.mifos.dto.screen.GroupPerformanceHistoryDto) LoanCycleCounter(org.mifos.dto.screen.LoanCycleCounter)

Example 3 with LoanCycleCounter

use of org.mifos.dto.screen.LoanCycleCounter in project head by mifos.

the class LoanCycleCounterTest method testEqualsObject.

public void testEqualsObject() {
    LoanCycleCounter x = new LoanCycleCounter();
    LoanCycleCounter notx = new LoanCycleCounter();
    LoanCycleCounter y = new LoanCycleCounter();
    LoanCycleCounter z = new LoanCycleCounter();
    x.setOfferingName("Loan1");
    notx.setOfferingName("Loan2");
    y.setOfferingName("Loan1");
    z.setOfferingName("Loan1");
    TestUtils.assertEqualsAndHashContract(x, notx, y, z);
}
Also used : LoanCycleCounter(org.mifos.dto.screen.LoanCycleCounter)

Example 4 with LoanCycleCounter

use of org.mifos.dto.screen.LoanCycleCounter in project head by mifos.

the class ClientServiceFacadeWebTier method assembleClientPerformanceHistoryDto.

private ClientPerformanceHistoryDto assembleClientPerformanceHistoryDto(ClientPerformanceHistoryEntity clientPerformanceHistory, Integer clientId) {
    Integer loanCycleNumber = clientPerformanceHistory.getLoanCycleNumber();
    Money lastLoanAmount = clientPerformanceHistory.getLastLoanAmount();
    Integer noOfActiveLoans = clientPerformanceHistory.getNoOfActiveLoans();
    String delinquentPortfolioAmountString;
    try {
        Money delinquentPortfolioAmount = clientPerformanceHistory.getDelinquentPortfolioAmount();
        delinquentPortfolioAmountString = delinquentPortfolioAmount.toString();
    } catch (CurrencyMismatchException e) {
        delinquentPortfolioAmountString = localizedMessageLookup("errors.multipleCurrencies");
    }
    // TODO currency mismatch check
    Money totalSavingsAmount = clientPerformanceHistory.getTotalSavingsAmount();
    Integer meetingsAttended = this.customerDao.numberOfMeetings(true, clientId).getMeetingsAttended();
    Integer meetingsMissed = customerDao.numberOfMeetings(false, clientId).getMeetingsMissed();
    List<LoanCycleCounter> loanCycleCounters = this.customerDao.fetchLoanCycleCounter(clientId, CustomerLevel.CLIENT.getValue());
    return new ClientPerformanceHistoryDto(loanCycleNumber, lastLoanAmount.toString(), noOfActiveLoans, delinquentPortfolioAmountString, totalSavingsAmount.toString(), meetingsAttended, meetingsMissed, loanCycleCounters);
}
Also used : Money(org.mifos.framework.util.helpers.Money) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) ClientPerformanceHistoryDto(org.mifos.dto.screen.ClientPerformanceHistoryDto) LoanCycleCounter(org.mifos.dto.screen.LoanCycleCounter)

Example 5 with LoanCycleCounter

use of org.mifos.dto.screen.LoanCycleCounter in project head by mifos.

the class CustomerHelpersIntegrationTest method testLoanCycleCounter.

@Test
public void testLoanCycleCounter() {
    LoanCycleCounter loanCycleCounter = new LoanCycleCounter();
    loanCycleCounter.setCounter(1);
    loanCycleCounter.setOfferingName("offeringName");
    Assert.assertEquals("value of counter", 1, loanCycleCounter.getCounter());
    Assert.assertEquals("value of offering name", "offeringName", loanCycleCounter.getOfferingName());
    loanCycleCounter = new LoanCycleCounter("offeringName");
    LoanCycleCounter loanCycleCounter1 = new LoanCycleCounter("offeringName");
    LoanCycleCounter loanCycleCounter2 = new LoanCycleCounter("offeringName1");
    Assert.assertTrue(loanCycleCounter.equals(loanCycleCounter1));
    Assert.assertFalse(loanCycleCounter.equals(loanCycleCounter2));
}
Also used : LoanCycleCounter(org.mifos.dto.screen.LoanCycleCounter) Test(org.junit.Test)

Aggregations

LoanCycleCounter (org.mifos.dto.screen.LoanCycleCounter)5 CurrencyMismatchException (org.mifos.core.CurrencyMismatchException)2 Money (org.mifos.framework.util.helpers.Money)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Test (org.junit.Test)1 ClientPerformanceHistoryDto (org.mifos.dto.screen.ClientPerformanceHistoryDto)1 GroupPerformanceHistoryDto (org.mifos.dto.screen.GroupPerformanceHistoryDto)1