FINERACT-1724 - Fraud set error when status is 100 or 200.
This commit is contained in:
+4
@@ -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);
|
||||
|
||||
+6
-8
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user