FINERACT-2174: Calculate fraction period - In case interestRecognitionFromDisbursementDate is true, we need to include from date and exclude due date

This commit is contained in:
Soma Sörös
2025-02-17 09:48:14 +01:00
committed by Adam Saghy
parent 7dc5dc279b
commit ff21304cac
9 changed files with 179 additions and 16 deletions
@@ -254,6 +254,8 @@ public final class LoanApplicationTerms {
this.seedDate = builder.seedDate;
this.isDownPaymentEnabled = builder.isDownPaymentEnabled;
this.disbursedAmountPercentageForDownPayment = builder.downPaymentPercentage;
this.interestRecognitionOnDisbursementDate = builder.interestRecognitionOnDisbursementDate != null
&& builder.interestRecognitionOnDisbursementDate;
if (isDownPaymentEnabled) {
this.downPaymentAmount = Money.of(getCurrency(),
MathUtil.percentageOf(getPrincipal().getAmount(), getDisbursedAmountPercentageForDownPayment(), builder.mc),
@@ -291,6 +293,7 @@ public final class LoanApplicationTerms {
private LocalDate submittedOnDate;
private LocalDate seedDate;
private MathContext mc;
private Boolean interestRecognitionOnDisbursementDate;
public Builder currency(CurrencyData currency) {
this.currency = currency;
@@ -402,6 +405,11 @@ public final class LoanApplicationTerms {
return this;
}
public Builder interestRecognitionOnDisbursementDate(boolean value) {
this.interestRecognitionOnDisbursementDate = value;
return this;
}
public LoanApplicationTerms build() {
return new LoanApplicationTerms(this);
}
@@ -430,7 +438,8 @@ public final class LoanApplicationTerms {
.daysInMonthType(modelData.daysInMonth()).daysInYearType(modelData.daysInYear()).fixedLength(modelData.fixedLength())
.inArrearsTolerance(Money.zero(modelData.currency(), mc)).disbursementDatas(new ArrayList<>())
.isDownPaymentEnabled(modelData.downPaymentEnabled()).downPaymentPercentage(downPaymentPercentage)
.submittedOnDate(modelData.scheduleGenerationStartDate()).seedDate(seedDate).mc(mc).build();
.submittedOnDate(modelData.scheduleGenerationStartDate()).seedDate(seedDate)
.interestRecognitionOnDisbursementDate(modelData.interestRecognitionOnDisbursementDate()).mc(mc).build();
}
public static LoanApplicationTerms assembleFrom(final CurrencyData currency, final Integer loanTermFrequency,
@@ -1557,7 +1566,8 @@ public final class LoanApplicationTerms {
return new LoanProductRelatedDetailMinimumData(currency, interestRatePerPeriod, annualNominalInterestRate, interestChargingGrace,
interestPaymentGrace, principalGrace, recurringMoratoriumOnPrincipalPeriods, interestMethod,
interestCalculationPeriodMethod, daysInYearType, daysInMonthType, amortizationMethod, repaymentPeriodFrequencyType,
repaymentEvery, numberOfRepayments);
repaymentEvery, numberOfRepayments,
isInterestChargedFromDateSameAsDisbursalDateEnabled != null && isInterestChargedFromDateSameAsDisbursalDateEnabled);
}
public Integer getLoanTermFrequency() {
@@ -30,5 +30,16 @@ public record LoanRepaymentScheduleModelData(@NotNull LocalDate scheduleGenerati
@NotNull BigDecimal disbursementAmount, @NotNull LocalDate disbursementDate, @NotNull int numberOfRepayments,
@NotNull int repaymentFrequency, @NotBlank String repaymentFrequencyType, @NotNull BigDecimal annualNominalInterestRate,
@NotNull boolean downPaymentEnabled, @NotNull DaysInMonthType daysInMonth, @NotNull DaysInYearType daysInYear,
BigDecimal downPaymentPercentage, Integer installmentAmountInMultiplesOf, Integer fixedLength) {
BigDecimal downPaymentPercentage, Integer installmentAmountInMultiplesOf, Integer fixedLength,
@NotNull Boolean interestRecognitionOnDisbursementDate) {
LoanRepaymentScheduleModelData(@NotNull LocalDate scheduleGenerationStartDate, @NotNull CurrencyData currency,
@NotNull BigDecimal disbursementAmount, @NotNull LocalDate disbursementDate, @NotNull int numberOfRepayments,
@NotNull int repaymentFrequency, @NotBlank String repaymentFrequencyType, @NotNull BigDecimal annualNominalInterestRate,
@NotNull boolean downPaymentEnabled, @NotNull DaysInMonthType daysInMonth, @NotNull DaysInYearType daysInYear,
BigDecimal downPaymentPercentage, Integer installmentAmountInMultiplesOf, Integer fixedLength) {
this(scheduleGenerationStartDate, currency, disbursementAmount, disbursementDate, numberOfRepayments, repaymentFrequency,
repaymentFrequencyType, annualNominalInterestRate, downPaymentEnabled, daysInMonth, daysInYear, downPaymentPercentage,
installmentAmountInMultiplesOf, fixedLength, false);
}
}
@@ -45,13 +45,14 @@ public class LoanProductRelatedDetailMinimumData implements LoanProductMinimumRe
private final PeriodFrequencyType repaymentPeriodFrequencyType;
private final Integer repaymentEvery;
private final Integer numberOfRepayments;
private final boolean interestRecognitionOnDisbursementDate;
public LoanProductRelatedDetailMinimumData(CurrencyData currency, BigDecimal interestRatePerPeriod,
BigDecimal annualNominalInterestRate, Integer interestChargingGrace, Integer interestPaymentGrace, Integer principalGrace,
Integer recurringMoratoriumOnPrincipalPeriods, InterestMethod interestMethod,
InterestCalculationPeriodMethod interestCalculationPeriodMethod, DaysInYearType daysInYearType, DaysInMonthType daysInMonthType,
AmortizationMethod amortizationMethod, PeriodFrequencyType repaymentPeriodFrequencyType, Integer repaymentEvery,
Integer numberOfRepayments) {
Integer numberOfRepayments, boolean interestRecognitionOnDisbursementDate) {
this.currency = currency;
this.interestRatePerPeriod = interestRatePerPeriod;
this.annualNominalInterestRate = annualNominalInterestRate;
@@ -67,6 +68,7 @@ public class LoanProductRelatedDetailMinimumData implements LoanProductMinimumRe
this.repaymentPeriodFrequencyType = repaymentPeriodFrequencyType;
this.repaymentEvery = repaymentEvery;
this.numberOfRepayments = numberOfRepayments;
this.interestRecognitionOnDisbursementDate = interestRecognitionOnDisbursementDate;
}
private Integer defaultToNullIfZero(final Integer value) {
@@ -161,4 +163,9 @@ public class LoanProductRelatedDetailMinimumData implements LoanProductMinimumRe
public Integer getDaysInYearType() {
return daysInYearType.getValue();
}
@Override
public boolean isInterestRecognitionOnDisbursementDate() {
return interestRecognitionOnDisbursementDate;
}
}
@@ -60,4 +60,6 @@ public interface LoanProductMinimumRepaymentScheduleRelatedDetail {
Integer getDaysInMonthType();
Integer getDaysInYearType();
boolean isInterestRecognitionOnDisbursementDate();
}