Search in sources :

Example 1 with MonthlyCashFlowForm

use of org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm in project head by mifos.

the class CashFlowController method retrieveMonthlyCashflowDetails.

@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public List<MonthlyCashFlowDto> retrieveMonthlyCashflowDetails(CashFlowForm cashFlowForm, Date disbursementDate, Double loanAmount) {
    List<MonthlyCashFlowDto> cashflowDtos = new ArrayList<MonthlyCashFlowDto>();
    for (MonthlyCashFlowForm monthlyCashflowform : cashFlowForm.getMonthlyCashFlows()) {
        BigDecimal monthlyRevenue = monthlyCashflowform.getRevenue();
        BigDecimal cumulativeCashflow = monthlyCashflowform.getCumulativeCashFlow();
        if (isSameMonthYear(new LocalDate(monthlyCashflowform.getDate()), new LocalDate(disbursementDate))) {
            if (monthlyRevenue == null) {
                monthlyRevenue = BigDecimal.valueOf(loanAmount);
            } else {
                monthlyRevenue = BigDecimal.valueOf(loanAmount).add(monthlyCashflowform.getRevenue());
            }
        }
        if (isAfterOrOnDisbursementMonthYear(new LocalDate(monthlyCashflowform.getDate()), new LocalDate(disbursementDate))) {
            if (cumulativeCashflow == null) {
                cumulativeCashflow = BigDecimal.valueOf(loanAmount);
            } else {
                cumulativeCashflow = cumulativeCashflow.add(BigDecimal.valueOf(loanAmount));
            }
        }
        MonthlyCashFlowDto monthlyCashFlow = new MonthlyCashFlowDto(monthlyCashflowform.getDateTime(), cumulativeCashflow, monthlyCashflowform.getNotes(), monthlyRevenue, monthlyCashflowform.getExpense());
        cashflowDtos.add(monthlyCashFlow);
    }
    return cashflowDtos;
}
Also used : MonthlyCashFlowDto(org.mifos.dto.domain.MonthlyCashFlowDto) MonthlyCashFlowForm(org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal)

Example 2 with MonthlyCashFlowForm

use of org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm in project head by mifos.

the class CashFlowController method transformCashFlow.

@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public LoanAccountCashFlow transformCashFlow(CashFlowForm cashFlow) {
    BigDecimal totalCapital = cashFlow.getTotalCapital();
    BigDecimal totalLiability = cashFlow.getTotalLiability();
    List<MonthlyCashFlowDto> cashflowDtos = new ArrayList<MonthlyCashFlowDto>();
    for (MonthlyCashFlowForm monthlyCashflowform : cashFlow.getMonthlyCashFlows()) {
        MonthlyCashFlowDto monthlyCashFlow = new MonthlyCashFlowDto(monthlyCashflowform.getDateTime(), monthlyCashflowform.getCumulativeCashFlow(), monthlyCashflowform.getNotes(), monthlyCashflowform.getRevenue(), monthlyCashflowform.getExpense());
        cashflowDtos.add(monthlyCashFlow);
    }
    return new LoanAccountCashFlow(cashflowDtos, totalCapital, totalLiability);
}
Also used : MonthlyCashFlowDto(org.mifos.dto.domain.MonthlyCashFlowDto) MonthlyCashFlowForm(org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm) ArrayList(java.util.ArrayList) LoanAccountCashFlow(org.mifos.clientportfolio.newloan.applicationservice.LoanAccountCashFlow) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 MonthlyCashFlowDto (org.mifos.dto.domain.MonthlyCashFlowDto)2 MonthlyCashFlowForm (org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm)2 LocalDate (org.joda.time.LocalDate)1 LoanAccountCashFlow (org.mifos.clientportfolio.newloan.applicationservice.LoanAccountCashFlow)1