Search in sources :

Example 6 with VariableInstallmentDetailsBO

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));
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) VariableInstallmentDetailsBO(org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date) Test(org.junit.Test)

Example 7 with VariableInstallmentDetailsBO

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

Example 8 with VariableInstallmentDetailsBO

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

Example 9 with VariableInstallmentDetailsBO

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;
}
Also used : Money(org.mifos.framework.util.helpers.Money) VariableInstallmentDetailsBO(org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)

Example 10 with VariableInstallmentDetailsBO

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));
    }
}
Also used : VariableInstallmentDetailsBO(org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)

Aggregations

VariableInstallmentDetailsBO (org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)10 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)6 Date (java.util.Date)5 Test (org.junit.Test)5 ErrorEntry (org.mifos.platform.validations.ErrorEntry)5 Money (org.mifos.framework.util.helpers.Money)4 ArrayList (java.util.ArrayList)2 BigDecimal (java.math.BigDecimal)1 LinkedHashMap (java.util.LinkedHashMap)1 LocalDate (org.joda.time.LocalDate)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)1 FeePaymentEntity (org.mifos.accounts.fees.business.FeePaymentEntity)1 FeeFrequencyType (org.mifos.accounts.fees.util.helpers.FeeFrequencyType)1 FeePayment (org.mifos.accounts.fees.util.helpers.FeePayment)1 FundBO (org.mifos.accounts.fund.business.FundBO)1 FundDto (org.mifos.accounts.fund.servicefacade.FundDto)1 InstallmentValidationContext (org.mifos.accounts.loan.business.service.validators.InstallmentValidationContext)1