Workaround for permissions independent of repayment schedule.

This commit is contained in:
Michal Dudzinski
2013-01-05 16:18:07 +01:00
parent 6177e41e70
commit 556f75fcc1
@@ -220,29 +220,36 @@ public class LoansApiResource {
} }
} }
if (associationParameters.contains("repaymentSchedule")) { if (associationParameters.contains("repaymentSchedule") || associationParameters.contains("permissions")) {
DisbursementData singleDisbursement = loanBasicDetails.toDisburementData(); DisbursementData singleDisbursement = loanBasicDetails.toDisburementData();
repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId, loanBasicDetails.getCurrency(), repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId, loanBasicDetails.getCurrency(),
singleDisbursement, loanBasicDetails.getTotalDisbursementCharges(), loanBasicDetails.getInArrearsTolerance()); singleDisbursement, loanBasicDetails.getTotalDisbursementCharges(), loanBasicDetails.getInArrearsTolerance());
convenienceDataRequired = true;
}
if (associationParameters.contains("permissions")) {
// FIXME - KW - Waive feature was changed to waive interest at // FIXME - KW - Waive feature was changed to waive interest at
// anytime so this permission checking is probably not needed - // anytime so this permission checking is probably not needed -
// look into. // look into.
final MonetaryCurrency currency = new MonetaryCurrency(loanBasicDetails.getCurrency().code(), loanBasicDetails final MonetaryCurrency currency = new MonetaryCurrency(loanBasicDetails.getCurrency().code(), loanBasicDetails
.getCurrency().decimalPlaces()); .getCurrency().decimalPlaces());
final Money tolerance = Money.of(currency, loanBasicDetails.getInArrearsTolerance()); final Money tolerance = Money.of(currency, loanBasicDetails.getInArrearsTolerance());
final Money totalOutstandingMoney = Money.of(currency, repaymentSchedule.totalOutstanding()); final Money totalOutstandingMoney = Money.of(currency, repaymentSchedule.totalOutstanding());
boolean isWaiveAllowed = totalOutstandingMoney.isGreaterThanZero() boolean isWaiveAllowed = totalOutstandingMoney.isGreaterThanZero()
&& (tolerance.isGreaterThan(totalOutstandingMoney) || tolerance.isEqualTo(totalOutstandingMoney)); && (tolerance.isGreaterThan(totalOutstandingMoney) || tolerance.isEqualTo(totalOutstandingMoney));
if (associationParameters.contains("permissions")) { loanRepaymentsCount = retrieveNonDisbursementTransactions(loanRepayments);
loanRepaymentsCount = retrieveNonDisbursementTransactions(loanRepayments); permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed,
permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepaymentsCount, existsGuarantor);
loanRepaymentsCount, existsGuarantor);
// clear parent data which wasn't requested
if (!associationParameters.contains("repaymentSchedule")) {
repaymentSchedule = null;
} }
convenienceDataRequired = true;
} }
if (associationParameters.contains("charges")) { if (associationParameters.contains("charges")) {