From 7dabb134b6cc18e5752b8d91fdf97dcd69101175 Mon Sep 17 00:00:00 2001 From: Kristof Jozsa Date: Thu, 8 Aug 2024 18:00:36 +0200 Subject: [PATCH] FINERACT-2081: fix loan status on CBR reverse --- ...ceRefundandRepaymentTypeIntegrationTest.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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