From 0e1c55f349c6725d89dcd26afbbb0ef3c66f32d0 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Wed, 4 Sep 2013 13:37:55 +0530 Subject: [PATCH] fix for repayment intervals recalculation --- .../domain/CalendarInstanceRepository.java | 8 +++---- .../portfolio/loanaccount/domain/Loan.java | 24 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarInstanceRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarInstanceRepository.java index baddabbd3..0718ff442 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarInstanceRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarInstanceRepository.java @@ -14,7 +14,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface CalendarInstanceRepository extends JpaRepository, JpaSpecificationExecutor { - + CalendarInstance findByCalendarIdAndEntityIdAndEntityTypeId(Long calendarId, Long entityId, Integer entityTypeId); Collection findByEntityIdAndEntityTypeId(Long entityId, Integer entityTypeId); @@ -26,8 +26,8 @@ public interface CalendarInstanceRepository extends JpaRepository findByCalendarIdAndEntityTypeId(Long calendarId, Integer entityTypeId); - /**Should use in clause, can I do it without creating a new class?**/ + /** Should use in clause, can I do it without creating a new class? **/ @Query("from CalendarInstance ci where ci.entityId in (select id from Loan loan where loan.client.id = :clientId and loan.group.id = :groupId and (loan.loanStatus = 100 or loan.loanStatus = 200 or loan.loanStatus = 300)) and ci.entityTypeId = 3") - List findCalendarInstancesForActiveLoansByGroupIdAndClientId(@Param("clientId") Long clientId, - @Param("groupId") Long groupId); + List findCalendarInstancesForActiveLoansByGroupIdAndClientId(@Param("groupId") Long groupId, + @Param("clientId") Long clientId); } 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 abbd95086..38368cf82 100644 --- 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 @@ -2486,22 +2486,16 @@ public class Loan extends AbstractPersistable { } if (isHolidayEnabled) { - // reset repayment date with new meeting date - newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, meetingStartDate, oldDueDate, - loanRepaymentInterval, frequency, workingDays); - if (isHolidayEnabled) { - newRepaymentDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(newRepaymentDate, holidays); - } - - loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate); - // reset from date to get actual daysInPeriod - loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); - tmpFromDate = newRepaymentDate;// update with new repayment - // date - } else { - tmpFromDate = oldDueDate; + newRepaymentDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(newRepaymentDate, holidays); } - + + loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate); + // reset from date to get actual daysInPeriod + loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); + tmpFromDate = newRepaymentDate;// update with new repayment + // date + }else { + tmpFromDate = oldDueDate; } } }