mifosx-58: add interest repayment and total repayment details correctly to new loan schedule been returned.
This commit is contained in:
@@ -188,6 +188,7 @@ public class LoansApiResource {
|
|||||||
boolean convenienceDataRequired = false;
|
boolean convenienceDataRequired = false;
|
||||||
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
if (!associationParameters.isEmpty()) {
|
if (!associationParameters.isEmpty()) {
|
||||||
|
|
||||||
if (associationParameters.contains("all")) {
|
if (associationParameters.contains("all")) {
|
||||||
responseParameters.addAll(Arrays.asList("repaymentSchedule", "loanRepayments", "permissions", "convenienceData", "charges"));
|
responseParameters.addAll(Arrays.asList("repaymentSchedule", "loanRepayments", "permissions", "convenienceData", "charges"));
|
||||||
} else {
|
} else {
|
||||||
@@ -200,16 +201,18 @@ public class LoansApiResource {
|
|||||||
loanRepaymentsCount = loanRepayments.size();
|
loanRepaymentsCount = loanRepayments.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
DisbursementData singleDisbursement = loanBasicDetails.toDisburementData();
|
if (responseParameters.contains("repaymentSchedule")) {
|
||||||
repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId, loanBasicDetails.getCurrency(),
|
DisbursementData singleDisbursement = loanBasicDetails.toDisburementData();
|
||||||
|
repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId, loanBasicDetails.getCurrency(),
|
||||||
singleDisbursement, loanBasicDetails.getTotalDisbursementCharges(), loanBasicDetails.getInArrearsTolerance());
|
singleDisbursement, loanBasicDetails.getTotalDisbursementCharges(), loanBasicDetails.getInArrearsTolerance());
|
||||||
|
|
||||||
MoneyData tolerance = MoneyData.of(loanBasicDetails.getCurrency(), loanBasicDetails.getInArrearsTolerance());
|
MoneyData tolerance = MoneyData.of(loanBasicDetails.getCurrency(), loanBasicDetails.getInArrearsTolerance());
|
||||||
MoneyData totalOutstandingMoney = MoneyData.of(loanBasicDetails.getCurrency(), repaymentSchedule.totalOutstanding());
|
MoneyData totalOutstandingMoney = MoneyData.of(loanBasicDetails.getCurrency(), repaymentSchedule.totalOutstanding());
|
||||||
boolean isWaiveAllowed = totalOutstandingMoney.isGreaterThanZero() && (tolerance.isGreaterThan(totalOutstandingMoney) || tolerance.isEqualTo(totalOutstandingMoney));
|
boolean isWaiveAllowed = totalOutstandingMoney.isGreaterThanZero() && (tolerance.isGreaterThan(totalOutstandingMoney) || tolerance.isEqualTo(totalOutstandingMoney));
|
||||||
|
|
||||||
permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepaymentsCount);
|
permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepaymentsCount);
|
||||||
convenienceDataRequired = true;
|
convenienceDataRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
charges = this.chargeReadPlatformService.retrieveLoanCharges(loanId);
|
charges = this.chargeReadPlatformService.retrieveLoanCharges(loanId);
|
||||||
if (CollectionUtils.isEmpty(charges)) {
|
if (CollectionUtils.isEmpty(charges)) {
|
||||||
|
|||||||
+15
-9
@@ -77,8 +77,8 @@ public class LoanSchedulePeriodData {
|
|||||||
|
|
||||||
return new LoanSchedulePeriodData(periodNumber, fromDate, dueDate,
|
return new LoanSchedulePeriodData(periodNumber, fromDate, dueDate,
|
||||||
principalOriginalDue, principalPaid, principalOutstanding, outstandingPrincipalBalanceOfLoan,
|
principalOriginalDue, principalPaid, principalOutstanding, outstandingPrincipalBalanceOfLoan,
|
||||||
interestDueOnPrincipalOutstanding,
|
interestDueOnPrincipalOutstanding, interestPaid, interestWaived, interestOutstanding,
|
||||||
totalDueForPeriod);
|
totalDueForPeriod, totalPaid, totalWaived, totalOutstanding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -184,7 +184,13 @@ public class LoanSchedulePeriodData {
|
|||||||
final BigDecimal principalOutstanding,
|
final BigDecimal principalOutstanding,
|
||||||
final BigDecimal principalLoanBalanceOutstanding,
|
final BigDecimal principalLoanBalanceOutstanding,
|
||||||
final BigDecimal interestDueOnPrincipalOutstanding,
|
final BigDecimal interestDueOnPrincipalOutstanding,
|
||||||
final BigDecimal totalDueForPeriod) {
|
final BigDecimal interestPaid,
|
||||||
|
final BigDecimal interestWaived,
|
||||||
|
final BigDecimal interestOutstanding,
|
||||||
|
final BigDecimal totalDueForPeriod,
|
||||||
|
final BigDecimal totalPaid,
|
||||||
|
final BigDecimal totalWaived,
|
||||||
|
final BigDecimal totalOutstanding) {
|
||||||
this.period = periodNumber;
|
this.period = periodNumber;
|
||||||
this.fromDate = fromDate;
|
this.fromDate = fromDate;
|
||||||
this.dueDate = dueDate;
|
this.dueDate = dueDate;
|
||||||
@@ -202,9 +208,9 @@ public class LoanSchedulePeriodData {
|
|||||||
|
|
||||||
this.interestOriginalDue = interestDueOnPrincipalOutstanding;
|
this.interestOriginalDue = interestDueOnPrincipalOutstanding;
|
||||||
this.interestDue = interestDueOnPrincipalOutstanding;
|
this.interestDue = interestDueOnPrincipalOutstanding;
|
||||||
this.interestPaid = BigDecimal.ZERO;
|
this.interestPaid = interestPaid;
|
||||||
this.interestWaived = BigDecimal.ZERO;
|
this.interestWaived = interestWaived;
|
||||||
this.interestOutstanding = interestDueOnPrincipalOutstanding;
|
this.interestOutstanding = interestOutstanding;
|
||||||
|
|
||||||
this.chargesDue = BigDecimal.ZERO;
|
this.chargesDue = BigDecimal.ZERO;
|
||||||
this.chargesPaid = BigDecimal.ZERO;
|
this.chargesPaid = BigDecimal.ZERO;
|
||||||
@@ -212,9 +218,9 @@ public class LoanSchedulePeriodData {
|
|||||||
|
|
||||||
this.totalOriginalDueForPeriod = totalDueForPeriod;
|
this.totalOriginalDueForPeriod = totalDueForPeriod;
|
||||||
this.totalDueForPeriod = totalDueForPeriod;
|
this.totalDueForPeriod = totalDueForPeriod;
|
||||||
this.totalPaidForPeriod = BigDecimal.ZERO;
|
this.totalPaidForPeriod = totalPaid;
|
||||||
this.totalWaivedForPeriod = BigDecimal.ZERO;
|
this.totalWaivedForPeriod = totalWaived;
|
||||||
this.totalOutstandingForPeriod = totalDueForPeriod;
|
this.totalOutstandingForPeriod = totalOutstanding;
|
||||||
|
|
||||||
if (dueDate.isBefore(new LocalDate())) {
|
if (dueDate.isBefore(new LocalDate())) {
|
||||||
this.totalOverdue = this.totalOutstandingForPeriod;
|
this.totalOverdue = this.totalOutstandingForPeriod;
|
||||||
|
|||||||
Reference in New Issue
Block a user