FINERACT-2389: EMI rounding handling
This commit is contained in:
+4
-4
@@ -823,7 +823,7 @@ public class LoanProductsRequestFactory {
|
||||
.inMultiplesOf(0)//
|
||||
.installmentAmountInMultiplesOf(1)//
|
||||
.useBorrowerCycle(false)//
|
||||
.minPrincipal(100.0)//
|
||||
.minPrincipal(1.0)//
|
||||
.principal(1000.0)//
|
||||
.maxPrincipal(10000.0)//
|
||||
.minNumberOfRepayments(1)//
|
||||
@@ -1046,7 +1046,7 @@ public class LoanProductsRequestFactory {
|
||||
.digitsAfterDecimal(2)//
|
||||
.inMultiplesOf(0)//
|
||||
.useBorrowerCycle(false)//
|
||||
.minPrincipal(10.0)//
|
||||
.minPrincipal(1.0)//
|
||||
.principal(1000.0)//
|
||||
.maxPrincipal(10000.0)//
|
||||
.minNumberOfRepayments(1)//
|
||||
@@ -1295,7 +1295,7 @@ public class LoanProductsRequestFactory {
|
||||
.inMultiplesOf(0)//
|
||||
.installmentAmountInMultiplesOf(1)//
|
||||
.useBorrowerCycle(false)//
|
||||
.minPrincipal(100.0)//
|
||||
.minPrincipal(1.0)//
|
||||
.principal(1000.0)//
|
||||
.maxPrincipal(10000.0)//
|
||||
.minNumberOfRepayments(1)//
|
||||
@@ -1534,7 +1534,7 @@ public class LoanProductsRequestFactory {
|
||||
.inMultiplesOf(0)//
|
||||
.installmentAmountInMultiplesOf(1)//
|
||||
.useBorrowerCycle(false)//
|
||||
.minPrincipal(100.0)//
|
||||
.minPrincipal(1.0)//
|
||||
.principal(1000.0)//
|
||||
.maxPrincipal(10000.0)//
|
||||
.minNumberOfRepayments(1)//
|
||||
|
||||
+14
-2
@@ -1398,11 +1398,23 @@ public final class ProgressiveEMICalculator implements EMICalculator {
|
||||
|
||||
private Money applyInstallmentAmountInMultiplesOf(final ProgressiveLoanInterestScheduleModel scheduleModel,
|
||||
final Money equalMonthlyInstallment) {
|
||||
return scheduleModel.installmentAmountInMultiplesOf() != null
|
||||
? Money.roundToMultiplesOf(equalMonthlyInstallment, scheduleModel.installmentAmountInMultiplesOf())
|
||||
return scheduleModel.installmentAmountInMultiplesOf() != null && scheduleModel.installmentAmountInMultiplesOf() > 0
|
||||
? safeRoundingForEMI(equalMonthlyInstallment, scheduleModel.installmentAmountInMultiplesOf())
|
||||
: equalMonthlyInstallment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds the EMI to the nearest multiple of the given number. If the rounded EMI is zero, it adds one multiple of
|
||||
* the given number to it.
|
||||
*/
|
||||
private Money safeRoundingForEMI(Money unRoundedEMI, Integer multiplesOf) {
|
||||
Money roundedEMI = Money.roundToMultiplesOf(unRoundedEMI, multiplesOf);
|
||||
if (roundedEMI.isZero()) {
|
||||
roundedEMI = roundedEMI.add(BigDecimal.ONE.multiply(BigDecimal.valueOf(multiplesOf)));
|
||||
}
|
||||
return roundedEMI;
|
||||
}
|
||||
|
||||
public EmiAdjustment getEmiAdjustment(final List<RepaymentPeriod> repaymentPeriods) {
|
||||
for (int idx = repaymentPeriods.size() - 1; idx > 0; --idx) {
|
||||
RepaymentPeriod lastPeriod = repaymentPeriods.get(idx);
|
||||
|
||||
Reference in New Issue
Block a user