FINERACT-1958: Fix down-payment for loan reschedule and for interest bearing loans
This commit is contained in:
+4
-7
@@ -41,7 +41,6 @@ import jakarta.persistence.Version;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -2823,8 +2822,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
|
||||
public LoanScheduleModel regenerateScheduleModel(final ScheduleGeneratorDTO scheduleGeneratorDTO) {
|
||||
|
||||
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||
final MathContext mc = new MathContext(8, roundingMode);
|
||||
final MathContext mc = MoneyHelper.getMathContext();
|
||||
|
||||
final LoanApplicationTerms loanApplicationTerms = constructLoanApplicationTerms(scheduleGeneratorDTO);
|
||||
LoanScheduleGenerator loanScheduleGenerator;
|
||||
@@ -5762,8 +5760,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
final LoanScheduleGenerator loanScheduleGenerator = generatorDTO.getLoanScheduleFactory()
|
||||
.create(this.loanRepaymentScheduleDetail.getLoanScheduleType(), interestMethod);
|
||||
|
||||
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||
final MathContext mc = new MathContext(19, roundingMode);
|
||||
final MathContext mc = MoneyHelper.getMathContext();
|
||||
|
||||
final LoanApplicationTerms loanApplicationTerms = constructLoanApplicationTerms(generatorDTO);
|
||||
|
||||
@@ -5778,8 +5775,8 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
LoanRepaymentScheduleInstallment installment = null;
|
||||
|
||||
if (this.loanRepaymentScheduleDetail.isInterestRecalculationEnabled()) {
|
||||
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||
final MathContext mc = new MathContext(8, roundingMode);
|
||||
|
||||
final MathContext mc = MoneyHelper.getMathContext();
|
||||
|
||||
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
||||
final LoanApplicationTerms loanApplicationTerms = constructLoanApplicationTerms(scheduleGeneratorDTO);
|
||||
|
||||
+1
-1
@@ -565,7 +565,7 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
BigDecimal percentageOf = BigDecimal.ZERO;
|
||||
|
||||
if (isGreaterThanZero(value)) {
|
||||
final MathContext mc = new MathContext(8, MoneyHelper.getRoundingMode());
|
||||
final MathContext mc = MoneyHelper.getMathContext();
|
||||
final BigDecimal multiplicand = percentage.divide(BigDecimal.valueOf(100L), mc);
|
||||
percentageOf = value.multiply(multiplicand, mc);
|
||||
}
|
||||
|
||||
+15
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.infrastructure.core.service.MathUtil;
|
||||
import org.apache.fineract.organisation.monetary.domain.ApplicationCurrency;
|
||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||
@@ -212,6 +213,7 @@ public final class LoanApplicationTerms {
|
||||
private LocalDate newScheduledDueDateStart;
|
||||
private boolean isDownPaymentEnabled;
|
||||
private BigDecimal disbursedAmountPercentageForDownPayment;
|
||||
private Money downPaymentAmount;
|
||||
private boolean isAutoRepaymentForDownPaymentEnabled;
|
||||
|
||||
private RepaymentStartDateType repaymentStartDateType;
|
||||
@@ -450,6 +452,15 @@ public final class LoanApplicationTerms {
|
||||
this.isPrincipalCompoundingDisabledForOverdueLoans = isPrincipalCompoundingDisabledForOverdueLoans;
|
||||
this.isDownPaymentEnabled = isDownPaymentEnabled;
|
||||
this.disbursedAmountPercentageForDownPayment = disbursedAmountPercentageForDownPayment;
|
||||
this.downPaymentAmount = Money.zero(getCurrency());
|
||||
if (isDownPaymentEnabled) {
|
||||
this.downPaymentAmount = Money.of(getCurrency(),
|
||||
MathUtil.percentageOf(getPrincipal().getAmount(), getDisbursedAmountPercentageForDownPayment(), 19));
|
||||
if (getInstallmentAmountInMultiplesOf() != null) {
|
||||
downPaymentAmount = Money.roundToMultiplesOf(downPaymentAmount, getInstallmentAmountInMultiplesOf());
|
||||
}
|
||||
}
|
||||
|
||||
this.isAutoRepaymentForDownPaymentEnabled = isAutoRepaymentForDownPaymentEnabled;
|
||||
this.repaymentStartDateType = repaymentStartDateType;
|
||||
this.submittedOnDate = submittedOnDate;
|
||||
@@ -1817,4 +1828,8 @@ public final class LoanApplicationTerms {
|
||||
public LoanScheduleType getLoanScheduleType() {
|
||||
return loanScheduleType;
|
||||
}
|
||||
|
||||
public Money getDownPaymentAmount() {
|
||||
return downPaymentAmount;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user