use of org.mifos.platform.cashflow.service.CashFlowDetail 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.service.CashFlowDetail in project head by mifos.
the class CashFlowFormTest method testGetMonthlyCashFlows.
@Test
public void testGetMonthlyCashFlows() throws Exception {
MonthlyCashFlowDetail cashFlowDetail1 = new MonthlyCashFlowDetail(new DateTime(), new BigDecimal(12), new BigDecimal(12), "notes");
MonthlyCashFlowDetail cashFlowDetail2 = new MonthlyCashFlowDetail(new DateTime(), new BigDecimal(23), new BigDecimal(34), "notes");
ArrayList<MonthlyCashFlowDetail> monthlyCashFlowDetails = new ArrayList<MonthlyCashFlowDetail>();
monthlyCashFlowDetails.add(cashFlowDetail1);
monthlyCashFlowDetails.add(cashFlowDetail2);
CashFlowDetail cashFlowDetail = new CashFlowDetail(monthlyCashFlowDetails);
CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, false, null, 0d);
List<MonthlyCashFlowForm> actual = cashFlowForm.getMonthlyCashFlows();
List<MonthlyCashFlowForm> expected = new ArrayList<MonthlyCashFlowForm>();
expected.add(new MonthlyCashFlowForm(cashFlowDetail1));
expected.add(new MonthlyCashFlowForm(cashFlowDetail2));
assertThat(actual.get(0), new MonthlyCashFlowFormMatcher(expected.get(0)));
assertThat(actual.get(1), new MonthlyCashFlowFormMatcher(expected.get(1)));
}
use of org.mifos.platform.cashflow.service.CashFlowDetail in project head by mifos.
the class CashFlowFormTest method shouldForValidateIndebtednessRate.
@Test
public void shouldForValidateIndebtednessRate() {
CashFlowDetail cashFlowDetail = new CashFlowDetail(Collections.EMPTY_LIST);
cashFlowDetail.setTotalCapital(BigDecimal.TEN);
cashFlowDetail.setTotalLiability(BigDecimal.TEN);
CashFlowForm cashFlowForm;
cashFlowForm = new CashFlowForm(cashFlowDetail, true, new BigDecimal(123), null);
assertThat(cashFlowForm.shouldForValidateIndebtednessRate(), is(false));
cashFlowForm = new CashFlowForm(cashFlowDetail, true, new BigDecimal(123), 0d);
assertThat(cashFlowForm.shouldForValidateIndebtednessRate(), is(false));
cashFlowForm = new CashFlowForm(cashFlowDetail, true, null, 123d);
assertThat(cashFlowForm.shouldForValidateIndebtednessRate(), is(false));
cashFlowForm = new CashFlowForm(null, true, new BigDecimal(123), 123d);
assertThat(cashFlowForm.shouldForValidateIndebtednessRate(), is(false));
cashFlowForm = new CashFlowForm(cashFlowDetail, false, new BigDecimal(123), 123d);
assertThat(cashFlowForm.shouldForValidateIndebtednessRate(), is(false));
cashFlowForm = new CashFlowForm(cashFlowDetail, true, new BigDecimal(123), 123d);
assertThat(cashFlowForm.shouldForValidateIndebtednessRate(), is(true));
}
use of org.mifos.platform.cashflow.service.CashFlowDetail in project head by mifos.
the class CashFlowFormTest method shouldComputeRepaymentCapacity.
@Test
public void shouldComputeRepaymentCapacity() {
CashFlowDetail cashFlowDetail = new CashFlowDetail(Collections.EMPTY_LIST);
CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, false, new BigDecimal(1000), 10d);
cashFlowForm.setTotalExpenses(BigDecimal.valueOf(76));
cashFlowForm.setTotalRevenues(BigDecimal.valueOf(55));
BigDecimal repaymentCapacity = cashFlowForm.computeRepaymentCapacity(BigDecimal.valueOf(60));
assertThat(repaymentCapacity, is(notNullValue()));
assertThat(repaymentCapacity.doubleValue(), is(1631.67));
}
use of org.mifos.platform.cashflow.service.CashFlowDetail in project head by mifos.
the class CashFlowValidatorTest method validateForCalculatedIndebtednessRateGreaterThanOrEqualToIndebtednessRate.
@Test
public void validateForCalculatedIndebtednessRateGreaterThanOrEqualToIndebtednessRate() {
when(validationContext.getMessageContext()).thenReturn(messageContext);
CashFlowDetail cashFlowDetail = new CashFlowDetail(EMPTY_LIST);
cashFlowDetail.setTotalCapital(new BigDecimal(100d));
cashFlowDetail.setTotalLiability(new BigDecimal(5d));
CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, true, new BigDecimal(1000d), 1000d);
cashFlowValidator.validateCaptureCashFlow(cashFlowForm, validationContext);
verify(validationContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher(CashFlowConstants.INDEBTEDNESS_RATIO_MORE_THAN_ALLOWED)));
}
Aggregations