wip retrieve loan schedule/repayment data

This commit is contained in:
John Woodlock
2012-07-20 14:27:50 +10:00
parent 9a92167025
commit 7aeff1f0ac
3 changed files with 19 additions and 7 deletions
@@ -97,11 +97,13 @@ public class LoansApiResource {
.retrieveLoanAccountDetails(loanId);
//LoanAccountData loanAccount = this.loanReadPlatformService.convertToData(loanBasicDetails);
Collection<LoanTransactionDatajpw> loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId);
Collection<LoanRepaymentPeriodDatajpw> repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId);
LoanAccountSummaryData summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule);
LoanAccountSummaryData summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule, loanRepayments);
Collection<LoanTransactionDatajpw> loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId);
LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, summary, repaymentSchedule, loanRepayments, null );
@@ -17,11 +17,12 @@ public interface LoanReadPlatformService {
Collection<LoanRepaymentPeriodDatajpw> retrieveRepaymentSchedule(Long loanId);
LoanAccountSummaryData retrieveSummary(MoneyData principal,
Collection<LoanRepaymentPeriodDatajpw> repaymentSchedule);
Collection<LoanTransactionDatajpw> retrieveLoanPayments(Long loanId);
LoanAccountSummaryData retrieveSummary(MoneyData principal,
Collection<LoanRepaymentPeriodDatajpw> repaymentSchedule,
Collection<LoanTransactionDatajpw> loanRepayments);
NewLoanData retrieveClientAndProductDetails(Long clientId, Long productId);
LoanTransactionData retrieveNewLoanRepaymentDetails(Long loanId);
@@ -115,7 +115,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
@Override
public LoanAccountSummaryData retrieveSummary(MoneyData principal,
Collection<LoanRepaymentPeriodDatajpw> repaymentSchedule) {
Collection<LoanRepaymentPeriodDatajpw> repaymentSchedule, Collection<LoanTransactionDatajpw> 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),