added support to accept interest charged from before disburse date

This commit is contained in:
pramod
2015-12-29 10:21:32 +05:30
parent 09df00c078
commit 9901fc0d3f
2 changed files with 15 additions and 13 deletions
@@ -172,7 +172,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
// calculated interest start date for the period // calculated interest start date for the period
LocalDate periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms, LocalDate periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms,
scheduleParams.getPeriodStartDate(), idealDisbursementDate); scheduleParams.getPeriodStartDate(), idealDisbursementDate, firstRepaymentdate);
// Loan Schedule Exceptions that need to be applied for Loan Account // Loan Schedule Exceptions that need to be applied for Loan Account
LoanTermVariationParams termVariationParams = applyLoanTermVariations(loanApplicationTerms, scheduleParams, LoanTermVariationParams termVariationParams = applyLoanTermVariations(loanApplicationTerms, scheduleParams,
@@ -229,14 +229,14 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
// for a loan repayment which falls between the // for a loan repayment which falls between the
// two periods for interest first repayment strategies // two periods for interest first repayment strategies
handleRecalculationForNonDueDateTransactions(mc, loanApplicationTerms, loanCharges, holidayDetailDTO, scheduleParams, periods, handleRecalculationForNonDueDateTransactions(mc, loanApplicationTerms, loanCharges, holidayDetailDTO, scheduleParams, periods,
totalInterestChargedForFullLoanTerm, idealDisbursementDate, lastRestDate, scheduledDueDate, totalInterestChargedForFullLoanTerm, idealDisbursementDate, firstRepaymentdate, lastRestDate, scheduledDueDate,
periodStartDateApplicableForInterest, applicableTransactions, currentPeriodParams); periodStartDateApplicableForInterest, applicableTransactions, currentPeriodParams);
if (currentPeriodParams.isSkipCurrentLoop()) { if (currentPeriodParams.isSkipCurrentLoop()) {
continue; continue;
} }
periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms, periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms,
scheduleParams.getPeriodStartDate(), idealDisbursementDate); scheduleParams.getPeriodStartDate(), idealDisbursementDate, firstRepaymentdate);
// backup for pre-close transaction // backup for pre-close transaction
updateCompoundingDetails(scheduleParams, periodStartDateApplicableForInterest); updateCompoundingDetails(scheduleParams, periodStartDateApplicableForInterest);
@@ -581,9 +581,9 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
private void handleRecalculationForNonDueDateTransactions(final MathContext mc, final LoanApplicationTerms loanApplicationTerms, private void handleRecalculationForNonDueDateTransactions(final MathContext mc, final LoanApplicationTerms loanApplicationTerms,
final Set<LoanCharge> loanCharges, final HolidayDetailDTO holidayDetailDTO, LoanScheduleParams scheduleParams, final Set<LoanCharge> loanCharges, final HolidayDetailDTO holidayDetailDTO, LoanScheduleParams scheduleParams,
final Collection<LoanScheduleModelPeriod> periods, final Money totalInterestChargedForFullLoanTerm, final Collection<LoanScheduleModelPeriod> periods, final Money totalInterestChargedForFullLoanTerm,
final LocalDate idealDisbursementDate, final LocalDate lastRestDate, final LocalDate scheduledDueDate, final LocalDate idealDisbursementDate, LocalDate firstRepaymentdate, final LocalDate lastRestDate,
final LocalDate periodStartDateForInterest, final Collection<RecalculationDetail> applicableTransactions, final LocalDate scheduledDueDate, final LocalDate periodStartDateForInterest,
final ScheduleCurrentPeriodParams currentPeriodParams) { final Collection<RecalculationDetail> applicableTransactions, final ScheduleCurrentPeriodParams currentPeriodParams) {
if (scheduleParams.applyInterestRecalculation()) { if (scheduleParams.applyInterestRecalculation()) {
final MonetaryCurrency currency = scheduleParams.getCurrency(); final MonetaryCurrency currency = scheduleParams.getCurrency();
final Collection<LoanTermVariationsData> interestRates = loanApplicationTerms.getLoanTermVariations().getInterestRateChanges(); final Collection<LoanTermVariationsData> interestRates = loanApplicationTerms.getLoanTermVariations().getInterestRateChanges();
@@ -608,7 +608,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
// calculates period start date for interest // calculates period start date for interest
// calculation as per the configuration // calculation as per the configuration
periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms, periodStartDateApplicableForInterest = calculateInterestStartDateForPeriod(loanApplicationTerms,
scheduleParams.getPeriodStartDate(), idealDisbursementDate); scheduleParams.getPeriodStartDate(), idealDisbursementDate, firstRepaymentdate);
int daysInPeriodApplicable = Days.daysBetween(periodStartDateApplicableForInterest, transactionDate).getDays(); int daysInPeriodApplicable = Days.daysBetween(periodStartDateApplicableForInterest, transactionDate).getDays();
Money interestForThisinstallment = Money.zero(currency); Money interestForThisinstallment = Money.zero(currency);
@@ -1507,15 +1507,17 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
/** /**
* calculates Interest stating date as per the settings * calculates Interest stating date as per the settings
*
* @param firstRepaymentdate
* TODO
*/ */
private LocalDate calculateInterestStartDateForPeriod(final LoanApplicationTerms loanApplicationTerms, LocalDate periodStartDate, private LocalDate calculateInterestStartDateForPeriod(final LoanApplicationTerms loanApplicationTerms, LocalDate periodStartDate,
final LocalDate idealDisbursementDate) { final LocalDate idealDisbursementDate, final LocalDate firstRepaymentdate) {
LocalDate periodStartDateApplicableForInterest = periodStartDate; LocalDate periodStartDateApplicableForInterest = periodStartDate;
if (periodStartDate.isBefore(idealDisbursementDate)) { if (periodStartDate.isBefore(idealDisbursementDate) || firstRepaymentdate.isAfter(periodStartDate)) {
if (loanApplicationTerms.getInterestChargedFromLocalDate() != null) { if (loanApplicationTerms.getInterestChargedFromLocalDate() != null) {
if (periodStartDate.isEqual(loanApplicationTerms.getExpectedDisbursementDate()) if (periodStartDate.isEqual(loanApplicationTerms.getExpectedDisbursementDate())
|| loanApplicationTerms.getCalculatedRepaymentsStartingFromLocalDate().isBefore( || loanApplicationTerms.getInterestChargedFromLocalDate().isAfter(periodStartDate)) {
loanApplicationTerms.getInterestChargedFromLocalDate())) {
periodStartDateApplicableForInterest = loanApplicationTerms.getInterestChargedFromLocalDate(); periodStartDateApplicableForInterest = loanApplicationTerms.getInterestChargedFromLocalDate();
} }
} else { } else {
@@ -146,13 +146,13 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
dataValidationErrors.add(error); dataValidationErrors.add(error);
} else if (repaymentsStartingFromDate == null && interestChargedFromDate != null) { } else if (repaymentsStartingFromDate == null && interestChargedFromDate != null) {
if (expectedDisbursementDate != null && expectedDisbursementDate.isAfter(interestChargedFromDate)) { /* if (expectedDisbursementDate != null && expectedDisbursementDate.isAfter(interestChargedFromDate)) {
final ApiParameterError error = ApiParameterError.parameterError( final ApiParameterError error = ApiParameterError.parameterError(
"validation.msg.loan.interestChargedFromDate.cannot.be.before.disbursement.date", "validation.msg.loan.interestChargedFromDate.cannot.be.before.disbursement.date",
"The parameter interestChargedFromDate cannot be before the date given for expectedDisbursementDate.", "The parameter interestChargedFromDate cannot be before the date given for expectedDisbursementDate.",
"interestChargedFromDate", interestChargedFromDate, expectedDisbursementDate); "interestChargedFromDate", interestChargedFromDate, expectedDisbursementDate);
dataValidationErrors.add(error); dataValidationErrors.add(error);
} }*/
} }
} }