Search in sources :

Example 1 with InstallmentValidationContext

use of org.mifos.accounts.loan.business.service.validators.InstallmentValidationContext in project head by mifos.

the class LoanAccountServiceFacadeWebTier method validateInputInstallments.

@Override
public Errors validateInputInstallments(Date disbursementDate, Integer minGapInDays, Integer maxGapInDays, BigDecimal minInstallmentAmount, List<LoanCreationInstallmentDto> dtoInstallments, Integer customerId) {
    Short officeId = customerDao.findCustomerById(customerId).getOfficeId();
    VariableInstallmentDetailsBO variableInstallmentDetails = new VariableInstallmentDetailsBO();
    variableInstallmentDetails.setMinGapInDays(minGapInDays);
    variableInstallmentDetails.setMaxGapInDays(maxGapInDays);
    InstallmentValidationContext context = new InstallmentValidationContext(disbursementDate, variableInstallmentDetails, minInstallmentAmount, holidayServiceFacade, officeId);
    MifosCurrency currency = Money.getDefaultCurrency();
    List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
    for (LoanCreationInstallmentDto dto : dtoInstallments) {
        Money principal = new Money(currency, dto.getPrincipal());
        Money interest = new Money(currency, dto.getInterest());
        Money fees = new Money(currency, dto.getFees());
        Money miscFees = new Money(currency);
        Money miscPenalty = new Money(currency);
        RepaymentScheduleInstallment installment = new RepaymentScheduleInstallment(dto.getInstallmentNumber(), dto.getDueDate(), principal, interest, fees, miscFees, miscPenalty);
        installment.setTotalAndTotalValue(new Money(currency, dto.getTotal()));
        installments.add(installment);
    }
    return installmentsValidator.validateInputInstallments(installments, context);
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) VariableInstallmentDetailsBO(org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO) ArrayList(java.util.ArrayList) LoanCreationInstallmentDto(org.mifos.dto.domain.LoanCreationInstallmentDto) InstallmentValidationContext(org.mifos.accounts.loan.business.service.validators.InstallmentValidationContext) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Aggregations

ArrayList (java.util.ArrayList)1 InstallmentValidationContext (org.mifos.accounts.loan.business.service.validators.InstallmentValidationContext)1 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)1 VariableInstallmentDetailsBO (org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)1 MifosCurrency (org.mifos.application.master.business.MifosCurrency)1 LoanCreationInstallmentDto (org.mifos.dto.domain.LoanCreationInstallmentDto)1 Money (org.mifos.framework.util.helpers.Money)1