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);
}
Aggregations