FINERACT-1109-rework-with-fixed-emi
This commit is contained in:
+26
-5
@@ -337,6 +337,11 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
||||
loanRepaymentScheduleTransactionProcessor, loanApplicationTerms.getTotalInterestDue(), lastRestDate, scheduledDueDate,
|
||||
periodStartDateApplicableForInterest, applicableTransactions, currentPeriodParams,
|
||||
lastTotalOutstandingInterestPaymentDueToGrace, installment, loanCharges);
|
||||
|
||||
if (loanApplicationTerms.getCurrentPeriodFixedEmiAmount() != null) {
|
||||
installment.setEMIFixedSpecificToInstallmentTrue();
|
||||
}
|
||||
|
||||
periods.add(installment);
|
||||
|
||||
// Updates principal paid map with efective date for reducing
|
||||
@@ -373,15 +378,30 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
||||
if (loanApplicationTerms.isInterestToBeAppropriatedEquallyWhenGreaterThanEMIEnabled()
|
||||
&& loanApplicationTerms.getInterestTobeApproppriated() != null
|
||||
&& loanApplicationTerms.getInterestTobeApproppriated().isGreaterThanZero()) {
|
||||
Money interestFraction = loanApplicationTerms.getInterestTobeApproppriated().dividedBy(periods.size(), mc.getRoundingMode());
|
||||
int emisTobeChanged = 1;
|
||||
for (LoanScheduleModelPeriod installment : (List<LoanScheduleModelPeriod>) periods) {
|
||||
if (!installment.isEMIFixedSpecificToInstallment()) {
|
||||
emisTobeChanged++;
|
||||
}
|
||||
}
|
||||
if (emisTobeChanged > 1) {
|
||||
emisTobeChanged--;
|
||||
}
|
||||
Money interestTobeApproppriated = loanApplicationTerms.getInterestTobeApproppriated();
|
||||
Money interestFraction = interestTobeApproppriated.dividedBy(emisTobeChanged, mc.getRoundingMode());
|
||||
BigDecimal roundFraction = interestFraction.getAmount().remainder(BigDecimal.ONE);
|
||||
interestFraction = interestFraction.minus(roundFraction);
|
||||
roundFraction = roundFraction.multiply(new BigDecimal(periods.size()));
|
||||
for (LoanScheduleModelPeriod installment : (List<LoanScheduleModelPeriod>) periods) {
|
||||
installment.addInterestAmount(interestFraction);
|
||||
if (!installment.isEMIFixedSpecificToInstallment()) {
|
||||
installment.addInterestAmount(interestFraction);
|
||||
interestTobeApproppriated = interestTobeApproppriated.minus(interestFraction);
|
||||
}
|
||||
}
|
||||
LoanScheduleModelPeriod lastInstallment = ((List<LoanScheduleModelPeriod>) periods).get(periods.size() - 1);
|
||||
|
||||
if (interestTobeApproppriated.isGreaterThanZero()) {
|
||||
lastInstallment.addInterestAmount(interestTobeApproppriated);
|
||||
}
|
||||
LoanScheduleModelPeriod installment = ((List<LoanScheduleModelPeriod>) periods).get(periods.size() - 1);
|
||||
installment.addInterestAmount(Money.of(currency, roundFraction));
|
||||
scheduleParams.addTotalRepaymentExpected(loanApplicationTerms.getInterestTobeApproppriated());
|
||||
scheduleParams.addTotalCumulativeInterest(loanApplicationTerms.getInterestTobeApproppriated());
|
||||
loanApplicationTerms.setInterestTobeApproppriated(Money.zero(currency));
|
||||
@@ -1079,6 +1099,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
||||
if (loanTermVariationsData.isSpecificToInstallment()) {
|
||||
loanApplicationTerms.setCurrentPeriodFixedEmiAmount(loanTermVariationsData.getDecimalValue());
|
||||
recalculateAmounts = true;
|
||||
|
||||
} else {
|
||||
loanApplicationTerms.setFixedEmiAmount(loanTermVariationsData.getDecimalValue());
|
||||
}
|
||||
|
||||
+11
@@ -35,6 +35,7 @@ public final class LoanScheduleModelDisbursementPeriod implements LoanScheduleMo
|
||||
private final LocalDate disbursementDate;
|
||||
private final Money principalDisbursed;
|
||||
private final BigDecimal chargesDueAtTimeOfDisbursement;
|
||||
private boolean isEMIFixedSpecificToInstallment = false;
|
||||
|
||||
public static LoanScheduleModelDisbursementPeriod disbursement(final LoanApplicationTerms loanApplicationTerms,
|
||||
final BigDecimal chargesDueAtTimeOfDisbursement) {
|
||||
@@ -127,4 +128,14 @@ public final class LoanScheduleModelDisbursementPeriod implements LoanScheduleMo
|
||||
public Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEMIFixedSpecificToInstallmentTrue() {
|
||||
this.isEMIFixedSpecificToInstallment = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEMIFixedSpecificToInstallment() {
|
||||
return isEMIFixedSpecificToInstallment;
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -54,4 +54,8 @@ public interface LoanScheduleModelPeriod {
|
||||
void addInterestAmount(Money interestDue);
|
||||
|
||||
Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails();
|
||||
|
||||
void setEMIFixedSpecificToInstallmentTrue();
|
||||
|
||||
boolean isEMIFixedSpecificToInstallment();
|
||||
}
|
||||
|
||||
+11
@@ -42,6 +42,7 @@ public final class LoanScheduleModelRepaymentPeriod implements LoanScheduleModel
|
||||
private Money totalDue;
|
||||
private final boolean recalculatedInterestComponent;
|
||||
private final Set<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new HashSet<>();
|
||||
private boolean isEMIFixedSpecificToInstallment = false;
|
||||
|
||||
public static LoanScheduleModelRepaymentPeriod repayment(final int periodNumber, final LocalDate startDate,
|
||||
final LocalDate scheduledDueDate, final Money principalDue, final Money outstandingLoanBalance, final Money interestDue,
|
||||
@@ -161,4 +162,14 @@ public final class LoanScheduleModelRepaymentPeriod implements LoanScheduleModel
|
||||
public Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
||||
return this.loanCompoundingDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEMIFixedSpecificToInstallment() {
|
||||
return this.isEMIFixedSpecificToInstallment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEMIFixedSpecificToInstallmentTrue() {
|
||||
this.isEMIFixedSpecificToInstallment = true;
|
||||
}
|
||||
}
|
||||
|
||||
-5
@@ -202,11 +202,6 @@ public class LoanRescheduleRequestDataValidator {
|
||||
"Loan rescheduling is not supported for multidisbursement loans");
|
||||
}
|
||||
|
||||
if (loan.isInterestRecalculationEnabledForProduct()) {
|
||||
dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(
|
||||
RescheduleLoansApiConstants.resheduleWithInterestRecalculationNotSupportedErrorCode,
|
||||
"Loan rescheduling is not supported for the loan product with interest recalculation enabled");
|
||||
}
|
||||
validateForOverdueCharges(dataValidatorBuilder, loan, installment);
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
|
||||
Reference in New Issue
Block a user