Repository: incubator-fineract Updated Branches: refs/heads/develop c1af84dd4 -> 9c38078de
center reschedule fix Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/25b66ad1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/25b66ad1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/25b66ad1 Branch: refs/heads/develop Commit: 25b66ad1a1865ab4970d9e31fb0d1e70b76dc713 Parents: 04fe104 Author: sachinkulkarni12 <[email protected]> Authored: Tue Mar 22 15:29:57 2016 +0530 Committer: sachinkulkarni12 <[email protected]> Committed: Tue Mar 22 15:29:57 2016 +0530 ---------------------------------------------------------------------- .../loanaccount/service/LoanUtilService.java | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/25b66ad1/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java index 063bad8..9689baf 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java @@ -191,10 +191,8 @@ public class LoanUtilService { if (calculatedRepaymentsStartingFromDate == null && !calendar.getCalendarHistory().isEmpty() && calendarHistoryDataWrapper != null) { - for (CalendarHistory calendarHistory : calendarHistoryDataWrapper.getCalendarHistoryList()) { - calculatedRepaymentsStartingFromDate = calendarHistory.getStartDateLocalDate(); - break; - } + // generate the first repayment date based on calendar history + calculatedRepaymentsStartingFromDate = generateCalculatedRepaymentStartDate(calendarHistoryDataWrapper, actualDisbursementDate, loan); return calculatedRepaymentsStartingFromDate; } @@ -218,6 +216,26 @@ public class LoanUtilService { } return calculatedRepaymentsStartingFromDate; } + + private LocalDate generateCalculatedRepaymentStartDate(final CalendarHistoryDataWrapper calendarHistoryDataWrapper, + LocalDate actualDisbursementDate, Loan loan) { + final LoanProductRelatedDetail repaymentScheduleDetails = loan.repaymentScheduleDetail(); + final WorkingDays workingDays = this.workingDaysRepository.findOne(); + LocalDate calculatedRepaymentsStartingFromDate = null; + + List<CalendarHistory> historyList = calendarHistoryDataWrapper.getCalendarHistoryList() ; + + if( historyList!=null && historyList.size() > 0) { + if(repaymentScheduleDetails != null){ + final Integer repayEvery = repaymentScheduleDetails.getRepayEvery(); + final String frequency = CalendarUtils.getMeetingFrequencyFromPeriodFrequencyType(repaymentScheduleDetails + .getRepaymentPeriodFrequencyType()); + calculatedRepaymentsStartingFromDate = CalendarUtils.getNextRepaymentMeetingDate(historyList.get(0).getRecurrence(), historyList.get(0).getStartDateLocalDate(), + actualDisbursementDate, repayEvery, frequency, workingDays); + } + } + return calculatedRepaymentsStartingFromDate; + } public Set<LoanDisbursementDetails> fetchDisbursementData(final JsonObject command) { final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(command);
