Search in sources :

Example 31 with RepaymentScheduleInstallment

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;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ArrayList(java.util.ArrayList)

Example 32 with RepaymentScheduleInstallment

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);
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) LoanBO(org.mifos.accounts.loan.business.LoanBO)

Example 33 with RepaymentScheduleInstallment

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();
    }
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 34 with RepaymentScheduleInstallment

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;
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ArrayList(java.util.ArrayList) ErrorEntry(org.mifos.platform.validations.ErrorEntry)

Example 35 with RepaymentScheduleInstallment

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;
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ArrayList(java.util.ArrayList) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date)

Aggregations

RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)66 Test (org.junit.Test)44 Money (org.mifos.framework.util.helpers.Money)34 Date (java.util.Date)27 ArrayList (java.util.ArrayList)19 ErrorEntry (org.mifos.platform.validations.ErrorEntry)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)7 VariableInstallmentDetailsBO (org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)7 OriginalScheduleInfoDto (org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto)6 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)6 Errors (org.mifos.platform.validations.Errors)6 MifosCurrency (org.mifos.application.master.business.MifosCurrency)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 BigDecimal (java.math.BigDecimal)4 ActionErrors (org.apache.struts.action.ActionErrors)4 Ignore (org.junit.Ignore)4 HashSet (java.util.HashSet)3 LocalDate (org.joda.time.LocalDate)3 OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)3 MessageLookup (org.mifos.application.master.MessageLookup)3