Merge pull request #1200 from pramodn02/MIFOSX-1760

MIFOSX-1760 : corrected start date calculation for approval
This commit is contained in:
Vishwas Babu A J
2014-12-17 06:42:43 -08:00
2 changed files with 6 additions and 3 deletions
@@ -1913,7 +1913,7 @@ public class Loan extends AbstractPersistable<Long> {
// Approved amount has to be less than or equal to principal
// amount demanded
if (approvedLoanAmount.compareTo(this.proposedPrincipal) < 1) {
if (approvedLoanAmount.compareTo(this.proposedPrincipal) == -1) {
this.approvedPrincipal = approvedLoanAmount;
@@ -1928,7 +1928,7 @@ public class Loan extends AbstractPersistable<Long> {
actualChanges.put(LoanApiConstants.approvedLoanAmountParameterName, approvedLoanAmount);
actualChanges.put(LoanApiConstants.disbursementPrincipalParameterName, approvedLoanAmount);
} else {
} else if(approvedLoanAmount.compareTo(this.proposedPrincipal) == 1){
final String errorMessage = "Loan approved amount can't be greater than loan amount demanded.";
throw new InvalidLoanStateTransitionException("approval", "amount.can't.be.greater.than.loan.amount.demanded",
errorMessage, this.proposedPrincipal, approvedLoanAmount);
@@ -523,7 +523,10 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
final MonetaryCurrency currency = loan.getCurrency();
ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
LocalDate calculatedRepaymentsStartingFromDate = loan.getExpectedFirstRepaymentOnDate();
final CalendarInstance calendarInstance = this.calendarInstanceRepository.findCalendarInstaneByEntityId(loan.getId(),
CalendarEntityType.LOANS.getValue());
LocalDate calculatedRepaymentsStartingFromDate = this.getCalculatedRepaymentsStartingFromDate(loan.getDisbursementDate(), loan,
calendarInstance);
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan
.getExpectedDisbursedOnLocalDate().toDate(), HolidayStatusType.ACTIVE.getValue());