FINERACT-2421: Fix undo repayment with linked chargeback error
This commit is contained in:
committed by
Adam Saghy
parent
9ca717ffd2
commit
136a966fc3
+30
@@ -679,6 +679,36 @@ public class LoanRepaymentStepDef extends AbstractStepDef {
|
||||
loanTransactionAdjustmentDataV1 -> loanTransactionAdjustmentDataV1.getNewTransactionDetail().getExternalOwnerId())
|
||||
.isEqualTo(externalOwnerId);
|
||||
}
|
||||
}
|
||||
|
||||
@Then("Customer undo {string}th transaction made on {string} results a {int} error and {string} error message")
|
||||
public void undoTransactionResultsError(final String nthItemStr, final String transactionDate, final int errorCodeExpected,
|
||||
final String errorMessageCode) {
|
||||
eventStore.reset();
|
||||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
||||
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
assert loanResponse != null;
|
||||
final long loanId = loanResponse.getLoanId();
|
||||
final List<GetLoansLoanIdTransactions> transactions = ok(
|
||||
() -> fineractClient.loans().retrieveLoan(loanId, Map.<String, Object>of("associations", "transactions")))
|
||||
.getTransactions();
|
||||
|
||||
final int nthItem = Integer.parseInt(nthItemStr) - 1;
|
||||
assert transactions != null;
|
||||
final GetLoansLoanIdTransactions targetTransaction = transactions.stream().filter(t -> {
|
||||
assert t.getDate() != null;
|
||||
return transactionDate.equals(formatter.format(t.getDate()));
|
||||
}).toList().get(nthItem);
|
||||
|
||||
final PostLoansLoanIdTransactionsTransactionIdRequest transactionUndoRequest = LoanRequestFactory.defaultTransactionUndoRequest()
|
||||
.transactionDate(transactionDate);
|
||||
|
||||
final CallFailedRuntimeException exception = fail(() -> fineractClient.loanTransactions().adjustLoanTransaction(loanId,
|
||||
targetTransaction.getId(), transactionUndoRequest, Map.of()));
|
||||
|
||||
assertThat(exception.getStatus()).as(ErrorMessageHelper.wrongErrorCode(exception.getStatus(), errorCodeExpected))
|
||||
.isEqualTo(errorCodeExpected);
|
||||
assertThat(exception.getDeveloperMessage())
|
||||
.as(ErrorMessageHelper.wrongErrorMessage(exception.getDeveloperMessage(), errorMessageCode)).contains(errorMessageCode);
|
||||
}
|
||||
}
|
||||
|
||||
-20
@@ -3319,26 +3319,6 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
testContext().set(TestContextKey.LOAN_WRITE_OFF_RESPONSE, writeOffResponse);
|
||||
}
|
||||
|
||||
@Then("Admin fails to undo {string}th transaction made on {string}")
|
||||
public void undoTransaction(String nthTransaction, String transactionDate) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
||||
PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
long loanId = loanResponse.getLoanId();
|
||||
List<GetLoansLoanIdTransactions> transactions = ok(() -> fineractClient.loans().retrieveLoan(loanId,
|
||||
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions"))).getTransactions();
|
||||
|
||||
int nthItem = Integer.parseInt(nthTransaction) - 1;
|
||||
GetLoansLoanIdTransactions targetTransaction = transactions.stream()
|
||||
.filter(t -> transactionDate.equals(formatter.format(t.getDate()))).toList().get(nthItem);
|
||||
|
||||
PostLoansLoanIdTransactionsTransactionIdRequest transactionUndoRequest = LoanRequestFactory.defaultTransactionUndoRequest()
|
||||
.transactionDate(transactionDate);
|
||||
|
||||
CallFailedRuntimeException exception = fail(() -> fineractClient.loanTransactions().adjustLoanTransaction(loanId,
|
||||
targetTransaction.getId(), transactionUndoRequest, Map.of()));
|
||||
assertThat(exception.getStatus()).as(ErrorMessageHelper.dateFailureErrorCodeMsg()).isEqualTo(503);
|
||||
}
|
||||
|
||||
@Then("Loan {string} repayment transaction on {string} with {double} EUR transaction amount results in error")
|
||||
public void loanTransactionWithErrorCheck(String repaymentType, String transactionDate, double transactionAmount) {
|
||||
PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
|
||||
Reference in New Issue
Block a user