use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBusinessService method adjustInstallmentGapsPostDisbursal.
public void adjustInstallmentGapsPostDisbursal(List<RepaymentScheduleInstallment> installments, Date oldDisbursementDate, Date newDisbursementDate, Short officeId) {
Date oldPrevDate = oldDisbursementDate, newPrevDate = newDisbursementDate;
for (RepaymentScheduleInstallment installment : installments) {
Date currentDueDate = installment.getDueDateValue();
long delta = DateUtils.getNumberOfDaysBetweenTwoDates(currentDueDate, oldPrevDate);
Date newDueDate = DateUtils.addDays(newPrevDate, (int) delta);
if (holidayService.isFutureRepaymentHoliday(DateUtils.getCalendar(newDueDate), officeId)) {
installment.setDueDateValue(holidayService.getNextWorkingDay(newDueDate, officeId));
} else {
installment.setDueDateValue(newDueDate);
}
oldPrevDate = currentDueDate;
newPrevDate = installment.getDueDateValue();
}
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class InstallmentRulesValidatorImpl method validateForMinimumInstallmentAmount.
@Override
public List<ErrorEntry> validateForMinimumInstallmentAmount(List<RepaymentScheduleInstallment> installments, BigDecimal minInstallmentAmount) {
List<ErrorEntry> errorEntries = new ArrayList<ErrorEntry>();
for (RepaymentScheduleInstallment installment : installments) {
String identifier = installment.getInstallmentNumberAsString();
if (installment.isTotalAmountInValid()) {
ErrorEntry entry = new ErrorEntry(AccountConstants.INSTALLMENT_AMOUNT_LESS_THAN_INTEREST_FEE, identifier);
entry.setArgs(Arrays.asList(identifier));
errorEntries.add(entry);
} else if (installment.isTotalAmountLessThan(minInstallmentAmount)) {
ErrorEntry entry = new ErrorEntry(INSTALLMENT_AMOUNT_LESS_THAN_MIN_AMOUNT, identifier);
entry.setArgs(Arrays.asList(identifier));
errorEntries.add(entry);
}
}
return errorEntries;
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class InstallmentRulesValidatorImpl method validateDueDatesForVariableInstallments.
@Override
public List<ErrorEntry> validateDueDatesForVariableInstallments(List<RepaymentScheduleInstallment> installments, VariableInstallmentDetailsBO variableInstallmentDetailsBO, Date disbursementDate) {
List<ErrorEntry> errorEntries = new ArrayList<ErrorEntry>();
if (CollectionUtils.isNotEmpty(installments)) {
for (int i = 0, installmentsSize = installments.size(); i < installmentsSize; i++) {
Date previousDueDate = getPreviousDueDate(installments, i, disbursementDate);
RepaymentScheduleInstallment installment = installments.get(i);
validateForDifferenceInDays(installment, previousDueDate, variableInstallmentDetailsBO, errorEntries);
}
}
return errorEntries;
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBusinessServiceTest method shouldMaintainInstallmentGapsPostDisbursal.
@Test
public void shouldMaintainInstallmentGapsPostDisbursal() {
RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("15-Oct-2010", 4, "84.9", "14.1", "1", "100", "0", "0");
RepaymentScheduleInstallment installment5 = getRepaymentScheduleInstallment("25-Oct-2010", 5, "94.9", "4.2", "1", "100", "0", "0");
RepaymentScheduleInstallment installment6 = getRepaymentScheduleInstallment("01-Nov-2010", 6, "96.5", "2.5", "1", "100", "0", "0");
RepaymentScheduleInstallment installment7 = getRepaymentScheduleInstallment("18-Nov-2010", 7, "439.2", "4.9", "1", "445.1", "0", "0");
List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4, installment5, installment6, installment7);
Date initialDisbursementDate = TestUtils.getDate(25, 8, 2010);
Date disbursementDate = TestUtils.getDate(30, 8, 2010);
when(holidayService.isFutureRepaymentHoliday(Matchers.<Calendar>any(), eq(officeId))).thenReturn(true);
when(holidayService.getNextWorkingDay(Matchers.<Date>any(), eq(officeId))).thenReturn(TestUtils.getDate(6, 9, 2010), TestUtils.getDate(13, 9, 2010), TestUtils.getDate(20, 9, 2010), TestUtils.getDate(20, 10, 2010), TestUtils.getDate(30, 10, 2010), TestUtils.getDate(6, 11, 2010), TestUtils.getDate(23, 11, 2010));
loanBusinessService.adjustInstallmentGapsPostDisbursal(installments, initialDisbursementDate, disbursementDate, officeId);
assertInstallmentDueDate(installment1, "06-Sep-2010");
assertInstallmentDueDate(installment2, "13-Sep-2010");
assertInstallmentDueDate(installment3, "20-Sep-2010");
assertInstallmentDueDate(installment4, "20-Oct-2010");
assertInstallmentDueDate(installment5, "30-Oct-2010");
assertInstallmentDueDate(installment6, "06-Nov-2010");
assertInstallmentDueDate(installment7, "23-Nov-2010");
verify(holidayService, times(7)).isFutureRepaymentHoliday(Matchers.<Calendar>any(), eq(officeId));
verify(holidayService, times(7)).getNextWorkingDay(Matchers.<Date>any(), eq(officeId));
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBusinessServiceTest method shouldGenerateMonthlyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest.
@Test
public void shouldGenerateMonthlyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("25-Sep-2010", 1, "78.6", "20.4", "1", "100", "0", "0");
RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("25-Oct-2010", 2, "182.8", "16.2", "1", "200", "0", "0");
RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("25-Nov-2010", 3, "186.0", "13.0", "1", "200", "0", "0");
RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("25-Dec-2010", 4, "452.6", "8.9", "1", "462.5", "0", "0");
List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
Date disbursementDate = TestUtils.getDate(25, 8, 2010);
final Money loanAmount = new Money(rupee, "1000");
loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);
assertInstallment(installment1, "78.6", "20.4");
assertInstallment(installment2, "180.8", "18.2");
assertInstallment(installment3, "183.9", "15.1");
assertInstallment(installment4, "556.7", "11.0");
}
Aggregations