FINERACT-1981: EMI Calculation, Daily, Weekly, Monthly support plug to Repayment Schedule

This commit is contained in:
Janos Meszaros
2024-06-26 09:21:38 +02:00
committed by Adam Saghy
parent 9f5044b358
commit db8000b4f3
15 changed files with 1312 additions and 328 deletions
@@ -38,6 +38,7 @@ import static org.mockito.BDDMockito.given;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.junit.context.WithTenantContext;
import org.apache.fineract.junit.context.WithTenantContextExtension;
@@ -74,6 +75,47 @@ public class DefaultScheduledDateGeneratorTest {
moneyHelper.initialize();
}
@Test
@WithSystemTimeZone(EUROPE_BERLIN_ID)
@WithTenantContext(tenantTimeZoneId = EUROPE_BERLIN_ID)
@WithSystemProperty(key = FLOATING_TIMEZONE_PROPERTY_KEY, value = "true")
public void test_generateRepaymentPeriods() {
// given
HolidayDetailDTO holidayDetailDTO = createHolidayDTO();
ApplicationCurrency dollarCurrency = new ApplicationCurrency("USD", "US Dollar", 2, 0, "currency.USD", "$");
Money principalAmount = Money.of(fromApplicationCurrency(dollarCurrency), BigDecimal.valueOf(100));
LocalDate expectedDisbursementDate = LocalDate.of(2024, 1, 1);
LocalDate dueRepaymentPeriodDate = LocalDate.of(2024, 2, 1);
LocalDate submittedOnDate = LocalDate.of(2024, 1, 1);
LoanApplicationTerms loanApplicationTerms = LoanApplicationTerms.assembleFrom(dollarCurrency, 1, MONTHS, 4, 1, MONTHS, null,
INVALID, EQUAL_PRINCIPAL, FLAT, ZERO, MONTHS, ZERO, SAME_AS_REPAYMENT_PERIOD, false, principalAmount,
expectedDisbursementDate, null, dueRepaymentPeriodDate, null, null, null, null, null,
Money.of(fromApplicationCurrency(dollarCurrency), ZERO), false, null, EMPTY_LIST, BigDecimal.valueOf(36_000L), null,
DaysInMonthType.ACTUAL, DaysInYearType.ACTUAL, false, null, null, null, null, null, ZERO, null, NONE, null, ZERO,
EMPTY_LIST, true, 0, false, holidayDetailDTO, false, false, false, null, false, false, null, false, DISBURSEMENT_DATE,
submittedOnDate, CUMULATIVE, LoanScheduleProcessingType.HORIZONTAL, null);
// when
List<PreGeneratedLoanSchedulePeriod> result = underTest.generateRepaymentPeriods(loanApplicationTerms, holidayDetailDTO);
// then
assertThat(result.size()).isEqualTo(4);
assertThat(result.get(0).periodNumber()).isEqualTo(1);
assertThat(result.get(0).periodFromDate().toString()).isEqualTo("2024-01-01");
assertThat(result.get(0).periodDueDate().toString()).isEqualTo("2024-02-01");
assertThat(result.get(1).periodNumber()).isEqualTo(2);
assertThat(result.get(1).periodFromDate().toString()).isEqualTo("2024-02-01");
assertThat(result.get(1).periodDueDate().toString()).isEqualTo("2024-03-01");
assertThat(result.get(2).periodNumber()).isEqualTo(3);
assertThat(result.get(2).periodFromDate().toString()).isEqualTo("2024-03-01");
assertThat(result.get(2).periodDueDate().toString()).isEqualTo("2024-04-01");
assertThat(result.get(3).periodNumber()).isEqualTo(4);
assertThat(result.get(3).periodFromDate().toString()).isEqualTo("2024-04-01");
assertThat(result.get(3).periodDueDate().toString()).isEqualTo("2024-05-01");
}
@Test
@WithSystemTimeZone(EUROPE_BERLIN_ID)
@WithTenantContext(tenantTimeZoneId = EUROPE_BERLIN_ID)