Search in sources :

Example 1 with CashFlowForm

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

the class LoanServiceFacadeWebTierTest method shouldValidateForRepaymentCapacity.

@Ignore
@Test
public void shouldValidateForRepaymentCapacity() {
    CashFlowDetail cashFlowDetail = new CashFlowDetail(Collections.EMPTY_LIST);
    BigDecimal loanAmount = new BigDecimal(1000);
    CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, false, loanAmount, 10d);
    cashFlowForm.setTotalExpenses(BigDecimal.valueOf(76));
    cashFlowForm.setTotalRevenues(BigDecimal.valueOf(55).add(loanAmount));
    RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withPrincipal(new Money(rupee, "4.9")).withTotalValue("10").build();
    RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withPrincipal(new Money(rupee, "4.9")).withTotalValue("20").build();
    RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withPrincipal(new Money(rupee, "4.9")).withTotalValue("30").build();
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
    // calcuated repayment capacity is 3298.33
    Errors errors;
//        errors = loanServiceFacade.validateCashFlowForInstallments(installments, cashFlowForm, 1600d);
//        assertThat(errors.hasErrorEntryWithCode(AccountConstants.REPAYMENT_CAPACITY_LESS_THAN_ALLOWED), is(false));
//        errors = loanServiceFacade.validateCashFlowForInstallments(installments, cashFlowForm, 3300d);
//        assertThat(errors.hasErrorEntryWithCode(AccountConstants.REPAYMENT_CAPACITY_LESS_THAN_ALLOWED), is(true));
}
Also used : Money(org.mifos.framework.util.helpers.Money) Errors(org.mifos.platform.validations.Errors) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) CashFlowForm(org.mifos.platform.cashflow.ui.model.CashFlowForm) BigDecimal(java.math.BigDecimal) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with CashFlowForm

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

the class CashFlowController method retrieveCashFlowForm.

public CashFlowForm retrieveCashFlowForm(CashFlowDto cashFlowSettings) {
    CashFlowBoundary cashFlowBoundary = cashFlowService.getCashFlowBoundary(cashFlowSettings.getFirstInstallmentDueDate(), cashFlowSettings.getLastInstallmentDueDate());
    CashFlowDetail cashFlowDetail = cashFlowService.cashFlowFor(cashFlowBoundary.getStartYear(), cashFlowBoundary.getStartMonth(), cashFlowBoundary.getNumberOfMonths());
    return new CashFlowForm(cashFlowDetail, cashFlowSettings.isCaptureCapitalLiabilityInfo(), cashFlowSettings.getLoanAmount(), cashFlowSettings.getIndebtednessRatio());
}
Also used : CashFlowBoundary(org.mifos.platform.cashflow.service.CashFlowBoundary) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) CashFlowForm(org.mifos.platform.cashflow.ui.model.CashFlowForm) MonthlyCashFlowForm(org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm)

Example 3 with CashFlowForm

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

the class LoanServiceFacadeWebTierTest method shouldValidateForInstallmentDateBeyondCashFlowData.

@Ignore
@Test
public void shouldValidateForInstallmentDateBeyondCashFlowData() {
    ArrayList<MonthlyCashFlowDetail> monthlyCashFlows = new ArrayList<MonthlyCashFlowDetail>();
    DateTime dateTime = new DateTime().withDate(2010, 10, 30);
    monthlyCashFlows.add(new MonthlyCashFlowDetail(dateTime, new BigDecimal(123), new BigDecimal(234), ""));
    monthlyCashFlows.add(new MonthlyCashFlowDetail(dateTime.plusMonths(1), new BigDecimal(123), new BigDecimal(234), ""));
    monthlyCashFlows.add(new MonthlyCashFlowDetail(dateTime.plusMonths(2), new BigDecimal(123), new BigDecimal(234), ""));
    CashFlowDetail cashFlowDetail = new CashFlowDetail(monthlyCashFlows);
    CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, false, new BigDecimal(1000), 10d);
    cashFlowForm.setTotalExpenses(BigDecimal.valueOf(76));
    cashFlowForm.setTotalRevenues(BigDecimal.valueOf(55));
    RepaymentScheduleInstallment installment = installmentBuilder.reset(locale).withPrincipal(new Money(rupee, "4.9")).withTotalValue("10").withDueDateValue("30-Nov-2010").build();
    RepaymentScheduleInstallment installmentBeforeCashFlowDate = installmentBuilder.reset(locale).withPrincipal(new Money(rupee, "4.9")).withTotalValue("10").withDueDateValue("30-Nov-2010").build();
    List<RepaymentScheduleInstallment> installments = asList(installment);
    Errors errors;
    //        errors = loanServiceFacade.validateCashFlowForInstallments(installments, cashFlowForm, 1600d);
    //        assertThat(errors.hasErrorEntryWithCode(AccountConstants.INSTALLMENT_BEYOND_CASHFLOW_DATE), is(false));
    RepaymentScheduleInstallment installmentBeyondCashFlowDate = installmentBuilder.reset(locale).withPrincipal(new Money(rupee, "4.9")).withTotalValue("10").withDueDateValue("30-Jan-2011").build();
    installments = asList(installmentBeyondCashFlowDate);
//        errors = loanServiceFacade.validateCashFlowForInstallments(installments, cashFlowForm, 1600d);
//        assertThat(errors.hasErrorEntryWithCode(AccountConstants.INSTALLMENT_BEYOND_CASHFLOW_DATE), is(true));
//        errors = loanServiceFacade.validateCashFlowForInstallments(installments, cashFlowForm, 1700d);
//        assertThat(errors.hasErrorEntryWithCode(AccountConstants.INSTALLMENT_BEYOND_CASHFLOW_DATE), is(true));
}
Also used : Money(org.mifos.framework.util.helpers.Money) Errors(org.mifos.platform.validations.Errors) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ArrayList(java.util.ArrayList) CashFlowForm(org.mifos.platform.cashflow.ui.model.CashFlowForm) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) DateTime(org.joda.time.DateTime) BigDecimal(java.math.BigDecimal) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with CashFlowForm

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

the class CashFlowControllerTest method prepareCashFlowForm.

@Test
public void prepareCashFlowForm() throws Exception {
    CashFlowDetail cashFlowDetail = new CashFlowDetail(new ArrayList<MonthlyCashFlowDetail>());
    Mockito.when(cashFlowService.cashFlowFor(2012, 1, 12)).thenReturn(cashFlowDetail);
    CashFlowController cashFlowController = new CashFlowController(cashFlowService);
    BigDecimal loanAmount = new BigDecimal("1234");
    Double indebtednessRatio = 12d;
    CashFlowForm cashFlowForm = cashFlowController.prepareCashFlowForm(2012, 1, 12, loanAmount, indebtednessRatio, true);
    CashFlowForm expectedCashFlowForm = new CashFlowForm(cashFlowDetail, true, loanAmount, indebtednessRatio);
    assertThat(cashFlowForm, new CashFlowFormMatcher(expectedCashFlowForm));
    Mockito.verify(cashFlowService).cashFlowFor(2012, 1, 12);
}
Also used : MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) CashFlowForm(org.mifos.platform.cashflow.ui.model.CashFlowForm) CashFlowFormMatcher(org.mifos.platform.cashflow.matchers.CashFlowFormMatcher) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

CashFlowDetail (org.mifos.platform.cashflow.service.CashFlowDetail)4 CashFlowForm (org.mifos.platform.cashflow.ui.model.CashFlowForm)4 BigDecimal (java.math.BigDecimal)3 Test (org.junit.Test)3 MonthlyCashFlowDetail (org.mifos.platform.cashflow.service.MonthlyCashFlowDetail)3 Ignore (org.junit.Ignore)2 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)2 Money (org.mifos.framework.util.helpers.Money)2 Errors (org.mifos.platform.validations.Errors)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 CashFlowFormMatcher (org.mifos.platform.cashflow.matchers.CashFlowFormMatcher)1 CashFlowBoundary (org.mifos.platform.cashflow.service.CashFlowBoundary)1 MonthlyCashFlowForm (org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm)1