use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBO method toRepaymentScheduleDto.
public List<RepaymentScheduleInstallment> toRepaymentScheduleDto(Locale userLocale) {
List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
for (AccountActionDateEntity actionDate : this.getAccountActionDates()) {
LoanScheduleEntity loanSchedule = (LoanScheduleEntity) actionDate;
installments.add(loanSchedule.toDto());
}
Collections.sort(installments, new Comparator<RepaymentScheduleInstallment>() {
@Override
public int compare(final RepaymentScheduleInstallment act1, final RepaymentScheduleInstallment act2) {
return act1.getInstallment().compareTo(act2.getInstallment());
}
});
return installments;
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBusinessService method applyDailyInterestRatesWhereApplicable.
public List<RepaymentScheduleInstallment> applyDailyInterestRatesWhereApplicable(LoanScheduleGenerationDto loanScheduleGenerationDto, Locale locale) {
LoanBO loanBO = loanScheduleGenerationDto.getLoanBO();
List<RepaymentScheduleInstallment> installments = loanBO.toRepaymentScheduleDto(locale);
return applyDailyInterestRatesWhereApplicable(loanScheduleGenerationDto, installments);
}
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;
}
Aggregations