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));
}
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());
}
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));
}
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);
}
Aggregations