diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java index 59ed4656e..dfeecd667 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java @@ -1898,20 +1898,6 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener // This will create the recalculation details by applying the // transactions for (LoanRepaymentScheduleInstallment installment : repaymentScheduleInstallments) { - for (Map.Entry disburseDetail : disburseDetailMap.entrySet()) { - if (disburseDetail.getKey().isAfter(installment.getFromDate()) - && !disburseDetail.getKey().isAfter(installment.getDueDate())) { - // creates and add disbursement detail to the repayments - // period - final LoanScheduleModelDisbursementPeriod disbursementPeriod = LoanScheduleModelDisbursementPeriod.disbursement( - disburseDetail.getKey(), disburseDetail.getValue(), chargesDueAtTimeOfDisbursement); - periods.add(disbursementPeriod); - // updates actual outstanding balance with new - // disbursement detail - outstandingBalance = outstandingBalance.plus(disburseDetail.getValue()); - } - } - // this will generate the next schedule due date and allows to // process the installment only if recalculate from date is // greater than due date @@ -1928,6 +1914,20 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener } periodNumber++; } + + for (Map.Entry disburseDetail : disburseDetailMap.entrySet()) { + if (disburseDetail.getKey().isAfter(installment.getFromDate()) + && !disburseDetail.getKey().isAfter(installment.getDueDate())) { + // creates and add disbursement detail to the repayments + // period + final LoanScheduleModelDisbursementPeriod disbursementPeriod = LoanScheduleModelDisbursementPeriod.disbursement( + disburseDetail.getKey(), disburseDetail.getValue(), chargesDueAtTimeOfDisbursement); + periods.add(disbursementPeriod); + // updates actual outstanding balance with new + // disbursement detail + outstandingBalance = outstandingBalance.plus(disburseDetail.getValue()); + } + } // calculation of basic fields to start the schedule generation // from the middle