This is an automated email from the ASF dual-hosted git repository.
adamsaghy 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 1ad45759fd FINERACT-2354: Validation of Re-age amount during submission
1ad45759fd is described below
commit 1ad45759fd461572df136862ace23577da7b43f3
Author: Adam Saghy <[email protected]>
AuthorDate: Wed Dec 10 10:21:11 2025 +0100
FINERACT-2354: Validation of Re-age amount during submission
---
.../service/reaging/LoanReAgingService.java | 24 ++++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reaging/LoanReAgingService.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reaging/LoanReAgingService.java
index 1751816a8c..e0f8c2bf5f 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reaging/LoanReAgingService.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reaging/LoanReAgingService.java
@@ -101,9 +101,11 @@ public class LoanReAgingService {
public CommandProcessingResult reAge(final Long loanId, final JsonCommand
command) {
final Loan loan = loanAssembler.assembleFrom(loanId);
reAgingValidator.validateReAge(loan, command);
+ BigDecimal userProvidedTxnAmount =
command.bigDecimalValueOfParameterNamed(LoanReAgingApiConstants.transactionAmountParamName);
final LoanTransaction reAgeTransaction = createReAgeTransaction(loan,
command);
processReAgeTransaction(loan, reAgeTransaction, true);
+ validateUserProvidedTransactionAmount(userProvidedTxnAmount,
reAgeTransaction);
loanTransactionRepository.saveAndFlush(reAgeTransaction);
loan.updateLoanScheduleDependentDerivedFields();
@@ -236,15 +238,7 @@ public class LoanReAgingService {
}
// in case of a reaging transaction, only the outstanding principal
amount until the business date is considered
Money txPrincipal =
loan.getTotalPrincipalOutstandingUntil(transactionDate);
- final BigDecimal txPrincipalAmount = txPrincipal.getAmount();
- if
(command.hasParameter(LoanReAgingApiConstants.transactionAmountParamName)) {
- final BigDecimal transactionAmount = command
-
.bigDecimalValueOfParameterNamed(LoanReAgingApiConstants.transactionAmountParamName);
- if (!MathUtil.isEqualTo(txPrincipalAmount, transactionAmount)) {
- throw new
GeneralPlatformDomainRuleException("error.msg.loan.reage.amount.not.match.with.calculated.reage.amount",
- "re-age amount is not matching with the calculated
re-age amount", txPrincipalAmount);
- }
- }
+ BigDecimal txPrincipalAmount = txPrincipal.getAmount();
final LoanTransaction reAgeTransaction = new LoanTransaction(loan,
loan.getOffice(), LoanTransactionType.REAGE, transactionDate,
txPrincipalAmount, txPrincipalAmount, ZERO, ZERO, ZERO, null,
false, null, txExternalId);
@@ -326,4 +320,16 @@ public class LoanReAgingService {
reAgeInterestHandlingType, null);
}
+ private void validateUserProvidedTransactionAmount(BigDecimal
userProvidedTxnAmount, LoanTransaction reAgeTransaction) {
+ if (userProvidedTxnAmount != null) {
+ final BigDecimal calculatedReageTxnAmount =
reAgeTransaction.getAmount();
+ if (!MathUtil.isEqualTo(calculatedReageTxnAmount,
userProvidedTxnAmount)) {
+ String errorMessage = String.format(
+ "User provided re-age amount (%s) is not matching with
the calculated re-age amount (%s)", userProvidedTxnAmount,
+ calculatedReageTxnAmount);
+ throw new
GeneralPlatformDomainRuleException("error.msg.loan.reage.amount.not.match.with.calculated.reage.amount",
+ errorMessage, userProvidedTxnAmount,
calculatedReageTxnAmount);
+ }
+ }
+ }
}