Merge pull request #1309 from pramodn02/develop

MIFOSX-1884 : corrected principal moratorium
This commit is contained in:
Vishwas Babu A J
2015-03-20 19:16:08 +05:30
4 changed files with 11 additions and 13 deletions
@@ -350,13 +350,9 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
totalOutstandingInterestPaymentDueToGrace = principalInterestForThisPeriod.interestPaymentDueToGrace(); totalOutstandingInterestPaymentDueToGrace = principalInterestForThisPeriod.interestPaymentDueToGrace();
Money principalForThisPeriod = principalInterestForThisPeriod.principal(); Money principalForThisPeriod = principalInterestForThisPeriod.principal();
if (loanApplicationTerms.getAmortizationMethod().isEqualInstallment() && loanApplicationTerms.getFixedEmiAmount() != null) { if(principalForThisPeriod.isZero()){
Money principalToBeAdjust = Money.of(currency, loanApplicationTerms.getFixedEmiAmount()).minus(principalForThisPeriod) loanApplicationTerms.resetFixedEmiAmount();
.minus(interestForThisinstallment);
principalForThisPeriod = principalForThisPeriod.plus(principalToBeAdjust);
} }
principalForThisPeriod = loanApplicationTerms.adjustPrincipalIfLastRepaymentPeriod(principalForThisPeriod,
totalCumulativePrincipal.plus(principalForThisPeriod), periodNumber);
// applies early payments on principal portion // applies early payments on principal portion
if (principalForThisPeriod.isGreaterThan(reducePrincipal)) { if (principalForThisPeriod.isGreaterThan(reducePrincipal)) {
@@ -349,7 +349,7 @@ public final class LoanApplicationTerms {
// paid too much principal, subtract amount that overpays from // paid too much principal, subtract amount that overpays from
// principal paid for period. // principal paid for period.
adjusted = principalForPeriod.minus(totalPrincipalRemaining.abs()); adjusted = principalForPeriod.minus(totalPrincipalRemaining.abs());
} else if (this.fixedEmiAmount != null) { } else if (this.actualFixedEmiAmount != null) {
final Money difference = this.principal.minus(totalCumulativePrincipalToDate); final Money difference = this.principal.minus(totalCumulativePrincipalToDate);
final Money principalThreshold = principalForPeriod.multipliedBy(this.principalThresholdForLastInstalment).dividedBy(100, final Money principalThreshold = principalForPeriod.multipliedBy(this.principalThresholdForLastInstalment).dividedBy(100,
RoundingMode.HALF_EVEN); RoundingMode.HALF_EVEN);
@@ -1016,8 +1016,10 @@ public final class LoanApplicationTerms {
for (LoanTermVariationsData loanVariationTermsData : this.emiAmountVariations) { for (LoanTermVariationsData loanVariationTermsData : this.emiAmountVariations) {
if (!periodDate.isBefore(loanVariationTermsData.getTermApplicableFrom()) if (!periodDate.isBefore(loanVariationTermsData.getTermApplicableFrom())
&& !startDate.isAfter(loanVariationTermsData.getTermApplicableFrom())) { && !startDate.isAfter(loanVariationTermsData.getTermApplicableFrom())) {
this.fixedEmiAmount = loanVariationTermsData.getTermValue(); if (loanVariationTermsData.getTermValue() != null) {
startDate = loanVariationTermsData.getTermApplicableFrom(); this.fixedEmiAmount = loanVariationTermsData.getTermValue();
startDate = loanVariationTermsData.getTermApplicableFrom();
}
} }
} }
} }
@@ -783,7 +783,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
* a fixed EMI, ensure the number of repayments is within the * a fixed EMI, ensure the number of repayments is within the
* permissible range defined by the loan product * permissible range defined by the loan product
**/ **/
if (loan.loanProduct().isMultiDisburseLoan() && loan.getFixedEmiAmount() != null) { if (loan.getFixedEmiAmount() != null) {
Integer minimumNoOfRepayments = loan.loanProduct().getMinNumberOfRepayments(); Integer minimumNoOfRepayments = loan.loanProduct().getMinNumberOfRepayments();
Integer maximumNoOfRepayments = loan.loanProduct().getMaxNumberOfRepayments(); Integer maximumNoOfRepayments = loan.loanProduct().getMaxNumberOfRepayments();
Integer actualNumberOfRepayments = loan.getRepaymentScheduleInstallments().size(); Integer actualNumberOfRepayments = loan.getRepaymentScheduleInstallments().size();