You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ar...@apache.org on 2023/01/09 22:40:01 UTC
[fineract] branch develop updated: FINERACT-1785: Specified due date charges/fees cannot be applied on disbursement date
This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new dafd4c343 FINERACT-1785: Specified due date charges/fees cannot be applied on disbursement date
dafd4c343 is described below
commit dafd4c3436a15b0d0279a2981ca7ac4eb9307c6d
Author: Jose Alberto Hernandez <al...@MacBook-Pro.local>
AuthorDate: Sat Jan 7 17:08:27 2023 -0600
FINERACT-1785: Specified due date charges/fees cannot be applied on disbursement date
---
.../domain/LoanRepaymentScheduleProcessingWrapper.java | 16 ++++++++++++----
.../integrationtests/LoanChargeSpecificDueDateTest.java | 4 ++--
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java
index fb7f80f20..f65f6c703 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java
@@ -45,14 +45,14 @@ public class LoanRepaymentScheduleProcessingWrapper {
final Money feeChargesDueForRepaymentPeriod = cumulativeFeeChargesDueWithin(startDate, period.getDueDate(), loanCharges,
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
final Money feeChargesWaivedForRepaymentPeriod = cumulativeFeeChargesWaivedWithin(startDate, period.getDueDate(), loanCharges,
- currency, !period.isRecalculatedInterestComponent());
+ currency, !period.isRecalculatedInterestComponent(), period.isFirstPeriod());
final Money feeChargesWrittenOffForRepaymentPeriod = cumulativeFeeChargesWrittenOffWithin(startDate, period.getDueDate(),
loanCharges, currency, !period.isRecalculatedInterestComponent());
final Money penaltyChargesDueForRepaymentPeriod = cumulativePenaltyChargesDueWithin(startDate, period.getDueDate(), loanCharges,
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
final Money penaltyChargesWaivedForRepaymentPeriod = cumulativePenaltyChargesWaivedWithin(startDate, period.getDueDate(),
- loanCharges, currency, !period.isRecalculatedInterestComponent());
+ loanCharges, currency, !period.isRecalculatedInterestComponent(), period.isFirstPeriod());
final Money penaltyChargesWrittenOffForRepaymentPeriod = cumulativePenaltyChargesWrittenOffWithin(startDate,
period.getDueDate(), loanCharges, currency, !period.isRecalculatedInterestComponent());
@@ -129,7 +129,8 @@ public class LoanRepaymentScheduleProcessingWrapper {
}
private Money cumulativeFeeChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
- final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable) {
+ final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable,
+ boolean isFirstPeriod) {
Money cumulative = Money.zero(currency);
@@ -142,6 +143,9 @@ public class LoanRepaymentScheduleProcessingWrapper {
}
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
+ // Special case for Loan Charges (Due Date) added the same disbursement date
+ } else if (isFirstPeriod && periodStart.equals(loanCharge.getDueDate())) {
+ cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
}
}
}
@@ -223,7 +227,8 @@ public class LoanRepaymentScheduleProcessingWrapper {
}
private Money cumulativePenaltyChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
- final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable) {
+ final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable,
+ boolean isFirstPeriod) {
Money cumulative = Money.zero(currency);
@@ -236,6 +241,9 @@ public class LoanRepaymentScheduleProcessingWrapper {
}
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
+ // Special case for Loan Charges (Due Date) added the same disbursement date
+ } else if (isFirstPeriod && periodStart.equals(loanCharge.getDueDate())) {
+ cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
}
}
}
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java
index 1b5df8419..7b8e599ec 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java
@@ -218,10 +218,10 @@ public class LoanChargeSpecificDueDateTest {
// evaluate the outstanding
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
- validateLoanAccount(getLoansLoanIdResponse, Double.valueOf(principalAmount), Double.valueOf("10.00"), true);
+ validateLoanAccount(getLoansLoanIdResponse, Double.valueOf(principalAmount), Double.valueOf("0.00"), true);
// Make a full repayment to close the Loan
- Float amount = Float.valueOf("1010.00");
+ Float amount = Float.valueOf("1000.00");
PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = loanTransactionHelper.makeLoanRepayment(operationDate, amount,
loanId);
assertNotNull(loanIdTransactionsResponse);