This is an automated email from the ASF dual-hosted git repository.
taskain 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 5f713be7e FINERACT-1724 - Fraud set error when status is 100 or 200.
5f713be7e is described below
commit 5f713be7ec775aea538d35f681d47fa6d611e19e
Author: Janos Haber <[email protected]>
AuthorDate: Tue Apr 25 12:12:28 2023 +0200
FINERACT-1724 - Fraud set error when status is 100 or 200.
---
.../service/LoanWritePlatformServiceJpaRepositoryImpl.java | 4 ++++
.../fineract/integrationtests/LoanAccountFraudTest.java | 14 ++++++--------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
index fa0cee287..ac24bc47d 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
@@ -2521,6 +2521,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl
implements LoanWritePlatf
Loan loan = this.loanAssembler.assembleFrom(loanId);
final Map<String, Object> changes = new LinkedHashMap<>();
+ if (loan.isApproved() || loan.isSubmittedAndPendingApproval()) {
+ throw new
GeneralPlatformDomainRuleException("error.msg.loan.mark.as.fraud.not.allowed",
+ "Loan Id: " + loanId + " mark as fraud is not allowed as
loan status is not active", loan.getStatus().getCode());
+ }
final boolean fraud =
command.booleanPrimitiveValueOfParameterNamed(LoanApiConstants.FRAUD_ATTRIBUTE_NAME);
if (loan.isFraud() != fraud) {
loan.markAsFraud(fraud);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountFraudTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountFraudTest.java
index 5ddb0972e..771dafe2d 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountFraudTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountFraudTest.java
@@ -89,22 +89,25 @@ public class LoanAccountFraudTest {
String payload =
loanTransactionHelper.getLoanFraudPayloadAsJSON("fraud", "true");
// Send the request, not expecting any errors (because only open
loan restriction removed)
PutLoansLoanIdResponse putLoansLoanIdResponse =
loanTransactionHelper.modifyLoanCommand(loanId, command, payload,
- this.responseSpec);
+ this.responseSpecError);
String statusCode = getLoansLoanIdResponse.getStatus().getCode();
log.info("Loan with Id {} is with Status {}",
getLoansLoanIdResponse.getId(), statusCode);
// Approve the Loan active
- approveAndDisburseLoan(loanId, this.operationDate, this.amountVal);
+ loanTransactionHelper.approveLoan(operationDate, this.amountVal,
loanId, null);
+ putLoansLoanIdResponse =
loanTransactionHelper.modifyLoanCommand(loanId, command, payload,
this.responseSpecError);
// Default values Not Null and False
getLoansLoanIdResponse =
loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
assertNotNull(getLoansLoanIdResponse);
assertNotNull(getLoansLoanIdResponse.getFraud());
- assertEquals(Boolean.TRUE, getLoansLoanIdResponse.getFraud());
+ assertEquals(Boolean.FALSE, getLoansLoanIdResponse.getFraud());
statusCode = getLoansLoanIdResponse.getStatus().getCode();
log.info("Loan with Id {} is with Status {}",
getLoansLoanIdResponse.getId(), statusCode);
+
loanTransactionHelper.disburseLoanWithNetDisbursalAmount(operationDate, loanId,
this.amountVal);
+
// Mark On the Fraud
putLoansLoanIdResponse =
loanTransactionHelper.modifyLoanCommand(loanId, command, payload,
this.responseSpec);
assertNotNull(putLoansLoanIdResponse);
@@ -161,9 +164,4 @@ public class LoanAccountFraudTest {
return loanTransactionHelper.getLoanId(loanApplicationJSON);
}
- private void approveAndDisburseLoan(final Integer loanId, final String
operationDate, final String principalAmount) {
- loanTransactionHelper.approveLoan(operationDate, principalAmount,
loanId, null);
-
loanTransactionHelper.disburseLoanWithNetDisbursalAmount(operationDate, loanId,
principalAmount);
- }
-
}