From 482b7aa714f6282700ca0509c5d7e9f9bd571722 Mon Sep 17 00:00:00 2001 From: Pramod Nuthakki Date: Wed, 6 Aug 2014 11:19:08 +0530 Subject: [PATCH] MIFOSX-1421 : corrected loan charges --- .../portfolio/loanaccount/domain/Loan.java | 1 + .../portfolio/loanaccount/domain/LoanCharge.java | 5 ++--- .../loanaccount/domain/LoanInstallmentCharge.java | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java index baf154a64..6598be3c8 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java @@ -2387,6 +2387,7 @@ public class Loan extends AbstractPersistable { && (!reprocess || !this.repaymentScheduleDetail().isInterestRecalculationEnabled())) { loanRepaymentScheduleTransactionProcessor.handleTransaction(loanTransaction, getCurrency(), this.repaymentScheduleInstallments, charges()); + reprocess = false; if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()) { if (currentInstallment == null || currentInstallment.isNotFullyPaidOff()) { reprocess = true; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java index fd137e02c..34ee233d7 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java @@ -698,7 +698,7 @@ public class LoanCharge extends AbstractPersistable { 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 { 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; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java index 18590c8cc..38c462481 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java @@ -174,7 +174,8 @@ public class LoanInstallmentCharge extends AbstractPersistable { } 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 { } 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; }