use of org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO in project head by mifos.
the class InstallmentRulesValidatorTest method shouldNotValidateForValidVariableInstallments.
@Test
public void shouldNotValidateForValidVariableInstallments() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withPrincipal(new Money(rupee, "49")).withTotalValue("50").withDueDateValue("01-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).withPrincipal(new Money(rupee, "49")).withTotalValue("50").withDueDateValue("03-Nov-2010").build();
RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withInstallment(3).withPrincipal(new Money(rupee, "49")).withTotalValue("50").withDueDateValue("06-Nov-2010").build();
VariableInstallmentDetailsBO variableInstallmentDetails = getVariableInstallmentDetails(2, 5, 50, rupee);
List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
Date disbursementDate = getDate(installment1, "27-Oct-2010");
List<ErrorEntry> errorEntries = installmentRulesValidator.validateDueDatesForVariableInstallments(installments, variableInstallmentDetails, disbursementDate);
assertThat(errorEntries.isEmpty(), is(true));
}
use of org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO 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);
}
use of org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO in project head by mifos.
the class InstallmentRulesValidatorTest method shouldValidateMaximumGapOfFiveDaysForFirstInstallmentAndDisbursementDate.
@Test
public void shouldValidateMaximumGapOfFiveDaysForFirstInstallmentAndDisbursementDate() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("01-Nov-2010").build();
VariableInstallmentDetailsBO variableInstallmentDetails = getVariableInstallmentDetails(null, 5, 100, rupee);
List<RepaymentScheduleInstallment> installments = asList(installment1);
Date disbursementDate = getDate(installment1, "25-Oct-2010");
List<ErrorEntry> errorEntries = installmentRulesValidator.validateDueDatesForVariableInstallments(installments, variableInstallmentDetails, disbursementDate);
assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_MORE_THAN_MAX_GAP, "1");
}
use of org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO in project head by mifos.
the class InstallmentRulesValidatorTest method getVariableInstallmentDetails.
private VariableInstallmentDetailsBO getVariableInstallmentDetails(Integer minGapInDays, Integer maxGapInDays, Integer minInstAmount, MifosCurrency currency) {
VariableInstallmentDetailsBO variableInstallmentDetails = new VariableInstallmentDetailsBO();
variableInstallmentDetails.setMinGapInDays(minGapInDays);
variableInstallmentDetails.setMaxGapInDays(maxGapInDays);
Money installmentAmount = new Money(currency, String.valueOf(minInstAmount));
variableInstallmentDetails.setMinInstallmentAmount(installmentAmount);
return variableInstallmentDetails;
}
use of org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO in project head by mifos.
the class LoanPrdAction method setVariableInstallmentDetailsOnLoanProductForm.
private void setVariableInstallmentDetailsOnLoanProductForm(LoanPrdActionForm loanPrdActionForm, LoanOfferingBO loanOfferingBO) {
boolean variableInstallmentsAllowed = loanOfferingBO.isVariableInstallmentsAllowed();
loanPrdActionForm.setCanConfigureVariableInstallments(variableInstallmentsAllowed);
if (variableInstallmentsAllowed) {
VariableInstallmentDetailsBO variableInstallmentDetails = loanOfferingBO.getVariableInstallmentDetails();
loanPrdActionForm.setMinimumGapBetweenInstallments(variableInstallmentDetails.getMinGapInDays());
loanPrdActionForm.setMaximumGapBetweenInstallments(variableInstallmentDetails.getMaxGapInDays());
double amount = variableInstallmentDetails.getMinInstallmentAmount().getAmountDoubleValue();
loanPrdActionForm.setMinimumInstallmentAmount(String.valueOf(amount));
}
}
Aggregations