diff --git a/.keystore b/.keystore new file mode 100755 index 000000000..7ed3e8b95 Binary files /dev/null and b/.keystore differ diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SchedulerJobsTestResults.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SchedulerJobsTestResults.java index b8df3bf77..2a9871221 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SchedulerJobsTestResults.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SchedulerJobsTestResults.java @@ -214,7 +214,7 @@ public class SchedulerJobsTestResults { Assert.assertNotNull(specifiedDueDateChargeId); this.loanTransactionHelper.addChargesForLoan(loanID, - LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(specifiedDueDateChargeId.toString())); + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(specifiedDueDateChargeId.toString(), "12 March 2013", "100")); ArrayList chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); Assert.assertEquals(1, chargesPendingState.size()); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java index c24a82f30..dc38daa8a 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java @@ -622,7 +622,7 @@ public class Loan extends AbstractPersistable { final LocalDate lastRepaymentPeriodDueDate) { if (loanCharge.isSpecifiedDueDate() && !loanCharge.isDueForCollectionFromAndUpToAndIncluding(disbursementDate, lastRepaymentPeriodDueDate)) { - final String defaultUserMessage = "This charge which is due at disbursement cannot be added as the loan is already disbursed."; + final String defaultUserMessage = "This charge with specified due date cannot be added as the it is not in schedule range."; throw new LoanChargeCannotBeAddedException("loanCharge", "specified.due.date.outside.range", defaultUserMessage, getDisbursementDate(), getLastRepaymentPeriodDueDate(), loanCharge.name()); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java index 01a80d5fe..c291c7c8c 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java @@ -478,9 +478,9 @@ public class LoanCharge extends AbstractPersistable { } } this.loanInstallmentCharge.removeAll(remove); - /*while (index < loanChargePerInstallmentArray.length - 1) { - chargePerInstallments.add(loanChargePerInstallmentArray[index++]); - }*/ + while (index < loanChargePerInstallmentArray.length - 1) { + this.loanInstallmentCharge.add(loanChargePerInstallmentArray[index++]); + } } } @@ -824,6 +824,7 @@ public class LoanCharge extends AbstractPersistable { this.active = active; if (!active) { this.overdueInstallmentCharge = null; + this.clearLoanInstallmentCharges(); } } 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 ed4278460..9eaba302f 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 @@ -315,7 +315,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener if (diffAmt != null && !diffAmt.isEmpty() && !periodStartDate.isAfter(LocalDate.now())) { Map processDetails = new TreeMap<>(); for (RecalculationDetail detail : diffAmt) { - if (periodStartDate.isBefore(detail.getStartDate()) && detail.isLatePayment()) { + if (!periodStartDate.isAfter(detail.getStartDate()) && detail.isLatePayment()) { if (processDetails.containsKey(detail.getToDate())) { RecalculationDetail recalculationDetail = processDetails.get(detail.getToDate()); RecalculationDetail updatedDetail = new RecalculationDetail(recalculationDetail.isLatePayment(), @@ -604,14 +604,18 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener if (installment.getDueDate().isBefore(LocalDate.now())) { LocalDate startDate = installment.getDueDate(); Money totalOutstanding = installment.getTotalOutstanding(currency); + boolean reduceStartDate = false; while (totalOutstanding.isGreaterThanZero() && startDate.isBefore(LocalDate.now())) { LocalDate recalculateFrom = getNextRestScheduleDate(startDate.minusDays(1), loanApplicationTerms, isHolidayEnabled, holidays, workingDays); LocalDate recalcualteTill = getNextRestScheduleDate(recalculateFrom, loanApplicationTerms, isHolidayEnabled, holidays, workingDays); + if (reduceStartDate) { + startDate = startDate.minusDays(1); + } applyRest(transactions, startDate, recalculateFrom, installment, loanRepaymentScheduleTransactionProcessor, currency, - loanApplicationTerms, isHolidayEnabled, holidays, workingDays); + loanApplicationTerms, isHolidayEnabled, holidays, workingDays, installments); totalOutstanding = installment.getTotalOutstanding(currency); if (totalOutstanding.isGreaterThanZero()) { Money latepaymentoutstanding = installment.getPrincipalOutstanding(currency); @@ -636,14 +640,15 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener latepaymentoutstanding); diffAmt.add(recalculationDetail); } - startDate = recalcualteTill; + startDate = recalculateFrom.plusDays(1); + reduceStartDate = true; } } if (!diffAmt.isEmpty()) { processRecalculate = true; - break; } + break; } if (processRecalculate) { @@ -658,7 +663,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener LoanRepaymentScheduleInstallment installment, final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor, MonetaryCurrency currency, final LoanApplicationTerms loanApplicationTerms, final boolean isHolidayEnabled, final List holidays, - final WorkingDays workingDays) { + final WorkingDays workingDays, final List installments) { List transactions = new ArrayList<>(); Map recalculationDates = new HashMap<>(); for (LoanTransaction transaction : loanTransactions) { @@ -671,8 +676,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener workingDays)); } } - List installments = new ArrayList<>(1); - installments.add(installment); + loanRepaymentScheduleTransactionProcessor.handleRepaymentSchedule(transactions, currency, installments, installment, recalculationDates); }