diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest.java index 38c8843d425..b11fa88ab50 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest.java @@ -245,7 +245,7 @@ public void cantRefundMoreThanOverpaidTest(LoanProductTestBuilder loanProductTes @ParameterizedTest @MethodSource("loanProductFactory") - public void fullRefundChangesStatusToClosedObligationMetTest(LoanProductTestBuilder loanProductTestBuilder) { + public void fullRefundChangesStatusToClosedObligationMetAndSetBackToOverpayAfterReverseTest(LoanProductTestBuilder loanProductTestBuilder) { disburseLoanOfAccountingRule(ACCRUAL_PERIODIC, loanProductTestBuilder); HashMap loanStatusHashMap = makeRepayment("06 January 2022", 20000.00f); // overpayment LoanStatusChecker.verifyLoanAccountIsOverPaid(loanStatusHashMap); @@ -255,7 +255,8 @@ public void fullRefundChangesStatusToClosedObligationMetTest(LoanProductTestBuil final String creditBalanceRefundDate = "09 January 2022"; final String externalId = null; - loanTransactionHelper.creditBalanceRefund(creditBalanceRefundDate, totalOverpaid, externalId, disbursedLoanID, null); + Integer resourceId = (Integer) loanTransactionHelper.creditBalanceRefund(creditBalanceRefundDate, totalOverpaid, externalId, + disbursedLoanID, "resourceId"); loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, disbursedLoanID, "status"); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); @@ -267,6 +268,18 @@ public void fullRefundChangesStatusToClosedObligationMetTest(LoanProductTestBuil totalOverpaidAtEnd = floatZero; } assertEquals(totalOverpaidAtEnd, floatZero); + + loanTransactionHelper.reverseLoanTransaction(disbursedLoanID, resourceId.longValue(), creditBalanceRefundDate, responseSpec); + + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, disbursedLoanID, + "status"); + + LoanStatusChecker.verifyLoanAccountIsOverPaid(loanStatusHashMap); + + Float totalOverpaidAfterReverse = (Float) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + disbursedLoanID, "totalOverpaid"); + + assertEquals(totalOverpaidAfterReverse, totalOverpaid); } @ParameterizedTest