diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java index ceaca5a84..d208bbd5d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java @@ -97,11 +97,13 @@ public class LoansApiResource { .retrieveLoanAccountDetails(loanId); //LoanAccountData loanAccount = this.loanReadPlatformService.convertToData(loanBasicDetails); + + + Collection loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId); Collection repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId); - LoanAccountSummaryData summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule); + LoanAccountSummaryData summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule, loanRepayments); - Collection loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId); LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, summary, repaymentSchedule, loanRepayments, null ); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformService.java index 1ef45f50b..650271b41 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformService.java @@ -17,11 +17,12 @@ public interface LoanReadPlatformService { Collection retrieveRepaymentSchedule(Long loanId); - LoanAccountSummaryData retrieveSummary(MoneyData principal, - Collection repaymentSchedule); - Collection retrieveLoanPayments(Long loanId); + LoanAccountSummaryData retrieveSummary(MoneyData principal, + Collection repaymentSchedule, + Collection loanRepayments); + NewLoanData retrieveClientAndProductDetails(Long clientId, Long productId); LoanTransactionData retrieveNewLoanRepaymentDetails(Long loanId); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java index c7c092729..201c102d6 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java @@ -115,7 +115,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { @Override public LoanAccountSummaryData retrieveSummary(MoneyData principal, - Collection repaymentSchedule) { + Collection repaymentSchedule, Collection loanRepayments) { CurrencyData currencyData = new CurrencyData( principal.getCurrencyCode(), principal.getDefaultName(), @@ -158,7 +158,16 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } totalInArrears = BigDecimal.TEN; - totalWaived = BigDecimal.ONE; + + + Long waiverType = (long) 4; + for (LoanTransactionDatajpw loanRepayment : loanRepayments) { + Long transactionType = loanRepayment.getTransactionType().getId(); + if (transactionType.equals(waiverType)) { + totalWaived = totalWaived.add(loanRepayment.getTotal().getAmount()); + } + + } return new LoanAccountSummaryData(MoneyData.of(currencyData, originalPrincipal), MoneyData.of(currencyData, principalPaid),