FINERACT-1971: Down payment (auto) transaction using installment multiples of setting

This commit is contained in:
Jose Alberto Hernandez
2024-05-07 11:45:10 +02:00
committed by Adam Saghy
parent 7499859d39
commit 849790ea46
18 changed files with 582 additions and 371 deletions
@@ -2968,7 +2968,9 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
}
Money downPaymentMoney = Money.of(getCurrency(),
MathUtil.percentageOf(disbursementTransaction.getAmount(), disbursedAmountPercentageForDownPayment, 19));
if (getLoanProduct().getInstallmentAmountInMultiplesOf() != null) {
downPaymentMoney = Money.roundToMultiplesOf(downPaymentMoney, getLoanProduct().getInstallmentAmountInMultiplesOf());
}
Money adjustedDownPaymentMoney = switch (getLoanProductRelatedDetail().getLoanScheduleType()) {
// For Cumulative loan: To check whether the loan was overpaid when the disbursement happened and to get the
// proper amount after the disbursement we are using two balances:
@@ -1206,10 +1206,11 @@ public final class LoanApplicationTerms {
double installmentAmount = FinanicalFunctions.pmt(periodicInterestRate.doubleValue(), periodsRemaining.doubleValue(),
principalDouble, futureValue, false);
BigDecimal fixedEmiAmount = BigDecimal.valueOf(installmentAmount);
if (this.installmentAmountInMultiplesOf != null) {
installmentAmount = Money.roundToMultiplesOf(installmentAmount, this.installmentAmountInMultiplesOf);
fixedEmiAmount = Money.roundToMultiplesOf(fixedEmiAmount, this.installmentAmountInMultiplesOf);
}
setFixedEmiAmount(BigDecimal.valueOf(installmentAmount));
setFixedEmiAmount(fixedEmiAmount);
}
return getFixedEmiAmount().doubleValue();
}