FINERACT-2065: Schedule handling for fixed length configuration

This commit is contained in:
Jose Alberto Hernandez
2024-03-27 12:54:26 +01:00
committed by Adam Saghy
parent 6458094a5e
commit b64b4b7105
11 changed files with 453 additions and 32 deletions
@@ -1832,4 +1832,43 @@ public final class LoanApplicationTerms {
public Money getDownPaymentAmount() {
return downPaymentAmount;
}
public Integer getFixedLength() {
return fixedLength;
}
public LocalDate calculateMaxDateForFixedLength() {
final LocalDate startDate = getRepaymentStartDate();
LocalDate maxDateForFixedLength = null;
if (fixedLength == null) {
return maxDateForFixedLength;
}
switch (repaymentPeriodFrequencyType) {
case DAYS:
maxDateForFixedLength = startDate.plusDays(fixedLength);
break;
case WEEKS:
maxDateForFixedLength = startDate.plusWeeks(fixedLength);
break;
case MONTHS:
maxDateForFixedLength = startDate.plusMonths(fixedLength);
break;
case YEARS:
maxDateForFixedLength = startDate.plusYears(fixedLength);
break;
case INVALID:
break;
case WHOLE_TERM:
log.error("TODO Implement repaymentPeriodFrequencyType for WHOLE_TERM");
break;
}
return maxDateForFixedLength;
}
public LocalDate getRepaymentStartDate() {
final RepaymentStartDateType repaymentStartDateType = getRepaymentStartDateType();
return RepaymentStartDateType.DISBURSEMENT_DATE.equals(repaymentStartDateType) ? getExpectedDisbursementDate()
: getSubmittedOnDate();
}
}