Search in sources :

Example 41 with RepaymentScheduleInstallment

use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.

the class LoanBusinessServiceTest method shouldGenerateInstallmentScheduleFromRepaymentScheduleUsingDailyInterest.

@Test
public void shouldGenerateInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
    RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
    RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("15-Oct-2010", 4, "84.9", "14.1", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment5 = getRepaymentScheduleInstallment("25-Oct-2010", 5, "94.9", "4.2", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment6 = getRepaymentScheduleInstallment("01-Nov-2010", 6, "96.5", "2.5", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment7 = getRepaymentScheduleInstallment("18-Nov-2010", 7, "439.2", "4.9", "1", "445.1", "0", "0");
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4, installment5, installment6, installment7);
    Date disbursementDate = TestUtils.getDate(25, 8, 2010);
    final Money loanAmount = new Money(rupee, "1000");
    loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);
    assertInstallment(installment1, "69.4", "4.6");
    assertInstallment(installment2, "94.7", "4.3");
    assertInstallment(installment3, "95.2", "3.8");
    assertInstallment(installment4, "84.4", "14.6");
    assertInstallment(installment5, "94.7", "4.3");
    assertInstallment(installment6, "96.4", "2.6");
    assertInstallment(installment7, "465.2", "5.2");
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) Date(java.util.Date) Test(org.junit.Test)

Example 42 with RepaymentScheduleInstallment

use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.

the class LoanBusinessServiceTest method shouldNotModifyPrincipalEvenIfMiscChargeIsPresent.

//Test for the bug fix
@Test
public void shouldNotModifyPrincipalEvenIfMiscChargeIsPresent() {
    MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("25-Sep-2010", 1, "78.6", "20.4", "1", "200", "100", "0");
    RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("25-Oct-2010", 2, "182.8", "16.2", "1", "200", "0", "0");
    RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("25-Nov-2010", 3, "186.0", "13.0", "1", "200", "0", "0");
    RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("25-Dec-2010", 4, "452.6", "8.9", "1", "462.5", "0", "0");
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
    Date disbursementDate = TestUtils.getDate(25, 8, 2010);
    final Money loanAmount = new Money(rupee, "1000");
    loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);
    assertInstallment(installment1, "78.6", "20.4");
    assertInstallment(installment2, "180.8", "18.2");
    assertInstallment(installment3, "183.9", "15.1");
    assertInstallment(installment4, "556.7", "11.0");
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) MifosCurrency(org.mifos.application.master.business.MifosCurrency) Date(java.util.Date) Test(org.junit.Test)

Example 43 with RepaymentScheduleInstallment

use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.

the class LoanBusinessServiceTest method shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfInterestTypeIsDecliningPrincipalBalance.

@Test
public void shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfInterestTypeIsDecliningPrincipalBalance() throws Exception {
    RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
    RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
    LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
    when(loanAccountActionForm.getLoanAmount()).thenReturn("1000");
    when(loanAccountActionForm.getLoanAmountValue()).thenReturn(new Money(rupee, "1000"));
    when(loanAccountActionForm.getInterestRate()).thenReturn("24");
    when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(false);
    when(legacyLoanDao.findBySystemId(anyString())).thenReturn(loanBO);
    when(loanBO.toRepaymentScheduleDto(locale)).thenReturn(installments);
    when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
    loanBusinessService.applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010), loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(), loanAccountActionForm.getInterestDoubleValue()), locale);
    verify(loanBO).updateInstallmentSchedule(installments);
    verify(loanBO).toRepaymentScheduleDto(locale);
}
Also used : LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) Test(org.junit.Test)

Example 44 with RepaymentScheduleInstallment

use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.

the class InstallmentRulesValidatorTest method shouldValidateInstallmentForDueDateBeforeDisburseDate.

@Test
public void shouldValidateInstallmentForDueDateBeforeDisburseDate() {
    RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDateValue("30-Nov-2010").withPrincipal(new Money(rupee, "499.9")).withInterest(new Money(rupee, "22.1")).withFees(new Money(rupee, "0.0")).withTotal("522.0").build();
    Date dateValue = getDate(installment, "30-Dec-2010");
    List<ErrorEntry> errorEntries = installmentRulesValidator.validateForDisbursementDate(asList(installment), dateValue);
    assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_BEFORE_DISBURSE_DATE, "3");
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date) Test(org.junit.Test)

Example 45 with RepaymentScheduleInstallment

use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment 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)

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