MIFOSX-1421 : corrected loan charges

This commit is contained in:
Pramod Nuthakki
2014-08-06 11:19:08 +05:30
parent 80146f9565
commit 482b7aa714
3 changed files with 9 additions and 8 deletions
@@ -2387,6 +2387,7 @@ public class Loan extends AbstractPersistable<Long> {
&& (!reprocess || !this.repaymentScheduleDetail().isInterestRecalculationEnabled())) {
loanRepaymentScheduleTransactionProcessor.handleTransaction(loanTransaction, getCurrency(), this.repaymentScheduleInstallments,
charges());
reprocess = false;
if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
if (currentInstallment == null || currentInstallment.isNotFullyPaidOff()) {
reprocess = true;
@@ -698,7 +698,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
amountPaidToDate = amountPaidToDate.plus(amountOutstanding);
this.amountPaid = amountPaidToDate.getAmount();
this.amountOutstanding = BigDecimal.ZERO;
Money waivedAmount = Money.of(processAmount.getCurrency(), this.amountWaived);
Money waivedAmount = getAmountWaived(processAmount.getCurrency());
if (waivedAmount.isGreaterThanZero()) {
this.waived = true;
} else {
@@ -868,13 +868,12 @@ public class LoanCharge extends AbstractPersistable<Long> {
this.paid = false;
this.waived = true;
}
return;
}
return;
}
Money waivedAmount = Money.of(currency, this.amountWaived);
if (waivedAmount.isGreaterThanZero()) {
if (waivedAmount.isGreaterThan(this.getAmount(currency))) {
this.amountWaived = this.getAmount(currency).getAmount();
this.amountOutstanding = BigDecimal.ZERO;
@@ -174,7 +174,8 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
}
this.amountThroughChargePayment = amountFromChargePayment.getAmount();
if (determineIfFullyPaid()) {
if (this.amountWaived.compareTo(BigDecimal.ZERO) == 1) {
Money waivedAmount = getAmountWaived(incrementBy.getCurrency());
if (waivedAmount.isGreaterThanZero()) {
this.waived = true;
} else {
this.paid = true;
@@ -208,14 +209,14 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
}
public Money updateWaivedAmount(final MonetaryCurrency currency) {
if (this.amountWaived.compareTo(BigDecimal.ZERO) == 1) {
int comparedValue = this.amountWaived.compareTo(this.getAmount());
if (comparedValue == 1) {
Money waivedAmount = getAmountWaived(currency);
if (waivedAmount.isGreaterThanZero()) {
if (waivedAmount.isGreaterThan(this.getAmount(currency))) {
this.amountWaived = this.getAmount();
this.amountOutstanding = BigDecimal.ZERO;
this.paid = false;
this.waived = true;
} else if (comparedValue == -1) {
} else if (waivedAmount.isLessThan(this.getAmount(currency))) {
this.paid = false;
this.waived = false;
}