use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment 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.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanServiceFacadeWebTierTest method retrieveOriginalLoanSchedule.
@Test
public void retrieveOriginalLoanSchedule() throws PersistenceException {
Integer accountId = new Integer(1);
List<OriginalLoanScheduleEntity> loanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
OriginalLoanScheduleEntity originalLoanScheduleEntity1 = mock(OriginalLoanScheduleEntity.class);
OriginalLoanScheduleEntity originalLoanScheduleEntity2 = mock(OriginalLoanScheduleEntity.class);
loanScheduleEntities.add(originalLoanScheduleEntity1);
loanScheduleEntities.add(originalLoanScheduleEntity2);
RepaymentScheduleInstallment installment1 = new RepaymentScheduleInstallment();
RepaymentScheduleInstallment installment2 = new RepaymentScheduleInstallment();
when(originalLoanScheduleEntity1.toDto()).thenReturn(installment1);
when(originalLoanScheduleEntity2.toDto()).thenReturn(installment2);
List<RepaymentScheduleInstallment> expected = new ArrayList<RepaymentScheduleInstallment>();
expected.add(installment1);
expected.add(installment2);
Date date = new Date();
when(loanBO.getDisbursementDate()).thenReturn(date);
Money money = new Money(rupee, "4.9");
when(loanBO.getLoanAmount()).thenReturn(money);
when(loanBusinessService.retrieveOriginalLoanSchedule(accountId)).thenReturn(loanScheduleEntities);
when(loanDao.findById(accountId)).thenReturn(loanBO);
OriginalScheduleInfoDto expectedOriginalScheduleInfoDto = new OriginalScheduleInfoDto(money.toString(), date, expected);
OriginalScheduleInfoDto originalScheduleInfoDto = loanServiceFacade.retrieveOriginalLoanSchedule(accountId);
assertThat(originalScheduleInfoDto, is(new OriginalScheduleInfoDtoMatcher(expectedOriginalScheduleInfoDto)));
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class InstallmentsValidatorImpl method validateInstallmentFormat.
private void validateInstallmentFormat(List<RepaymentScheduleInstallment> installments, Errors errors) {
for (RepaymentScheduleInstallment installment : installments) {
errors.addErrors(installmentFormatValidator.validateTotalAmountFormat(installment));
errors.addErrors(installmentFormatValidator.validateDueDateFormat(installment));
}
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class ListOfInstallmentsValidatorImpl method getDueDateInstallmentsLookup.
private Map<Date, List<String>> getDueDateInstallmentsLookup(List<RepaymentScheduleInstallment> installments) {
Map<Date, List<String>> dateInstallmentsLookup = new LinkedHashMap<Date, List<String>>();
for (RepaymentScheduleInstallment installment : installments) {
Date key = installment.getDueDateValue();
String value = installment.getInstallmentNumberAsString();
CollectionUtils.addKeyValue(dateInstallmentsLookup, key, value);
}
return dateInstallmentsLookup;
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBO method updateInstallmentSchedule.
public void updateInstallmentSchedule(List<RepaymentScheduleInstallment> installments) {
Map<Integer, LoanScheduleEntity> loanScheduleEntityLookUp = getLoanScheduleEntityMap();
for (RepaymentScheduleInstallment installment : installments) {
LoanScheduleEntity loanScheduleEntity = loanScheduleEntityLookUp.get(installment.getInstallment());
loanScheduleEntity.setPrincipal(installment.getPrincipal());
loanScheduleEntity.setInterest(installment.getInterest());
loanScheduleEntity.setActionDate(new java.sql.Date(installment.getDueDateValue().getTime()));
}
updateLoanSummary();
}
Aggregations