This is an automated email from the ASF dual-hosted git repository.

arnold 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 297fa8e707 FINERACT-2326: Close opened savings account after 
integration test execution
297fa8e707 is described below

commit 297fa8e707712498922855c3d31d35810fd7ef93
Author: Adam Saghy <[email protected]>
AuthorDate: Thu Oct 2 03:09:11 2025 +0200

    FINERACT-2326: Close opened savings account after integration test execution
---
 ...ternalSavingsAccountInformationApiResource.java | 77 +++++++++++++++++++
 .../api/SavingsAccountsApiResourceSwagger.java     |  4 +
 .../savings/domain/SavingsAccountRepository.java   |  3 +
 .../domain/SavingsAccountRepositoryWrapper.java    |  4 +
 .../fineract/integrationtests/BatchApiTest.java    |  5 +-
 .../integrationtests/BatchLoanIntegrationTest.java |  2 +-
 .../ClientSavingsIntegrationTest.java              |  3 +
 ...xibleSavingsInterestPostingIntegrationTest.java |  3 +
 .../GroupSavingsIntegrationTest.java               |  3 +
 ...avingsAccountBalanceCheckAfterReversalTest.java |  3 +
 .../SavingsAccountRecalculateBalanceTest.java      |  3 +
 ...AccountTransactionDatatableIntegrationTest.java |  3 +
 .../SavingsAccountTransactionTest.java             |  3 +
 ...gsAccountTransactionsSearchIntegrationTest.java |  3 +
 .../SavingsAccountsExternalIdTest.java             |  3 +
 .../integrationtests/SavingsAccountsTest.java      |  3 +
 .../SavingsAccrualAccountingIntegrationTest.java   |  3 +
 .../SavingsAccrualIntegrationTest.java             |  3 +
 .../SavingsInterestPostingIntegrationTest.java     |  3 +
 .../SavingsInterestPostingJobIntegrationTest.java  |  3 +
 .../SavingsInterestPostingTest.java                |  3 +
 .../SavingsProductCreationIntegrationTest.java     |  3 +
 .../common/error/ErrorResponse.java                | 53 ++++++++++++-
 .../common/savings/SavingsAccountHelper.java       | 23 ++++++
 .../savings/SavingsTestLifecycleExtension.java     | 89 ++++++++++++++++++++++
 .../savings/SavingsInterestPostingTest.java        |  3 +
 26 files changed, 304 insertions(+), 7 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/InternalSavingsAccountInformationApiResource.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/InternalSavingsAccountInformationApiResource.java
new file mode 100644
index 0000000000..184f59b28a
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/InternalSavingsAccountInformationApiResource.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.portfolio.savings.api;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.UriInfo;
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
+import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepository;
+import 
org.apache.fineract.portfolio.savings.service.SavingsAccountWritePlatformService;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+
+@Profile(FineractProfiles.TEST)
+@Component
+@Path("/v1/internal/savingsaccounts")
+@RequiredArgsConstructor
+@Slf4j
+public class InternalSavingsAccountInformationApiResource implements 
InitializingBean {
+
+    private final SavingsAccountRepository repository;
+    private final SavingsAccountWritePlatformService writePlatformService;
+
+    @Override
+    @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
+    public void afterPropertiesSet() {
+        
log.warn("------------------------------------------------------------");
+        log.warn("                                                            
");
+        log.warn("DO NOT USE THIS IN PRODUCTION!");
+        log.warn("Internal savings account services mode is enabled");
+        log.warn("DO NOT USE THIS IN PRODUCTION!");
+        log.warn("                                                            
");
+        
log.warn("------------------------------------------------------------");
+
+    }
+
+    @GET
+    @Path("status/{statusId}")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
+    public List<Long> getSavingsAccountsByStatus(@Context final UriInfo 
uriInfo, @PathParam("statusId") Integer statusId) {
+        
log.warn("------------------------------------------------------------");
+        log.warn("                                                            
");
+        log.warn("Fetching loans by status {}", statusId);
+        log.warn("                                                            
");
+        
log.warn("------------------------------------------------------------");
+
+        return repository.findSavingsAccountIdsByStatusId(statusId);
+    }
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java
index 302b31c457..75fea1d249 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java
@@ -342,6 +342,10 @@ final class SavingsAccountsApiResourceSwagger {
         public String approvedOnDate;
         @Schema(example = "05 September 2014")
         public String activatedOnDate;
+        @Schema(example = "05 September 2014")
+        public String closedOnDate;
+        @Schema(example = "false")
+        public Boolean withdrawBalance;
     }
 
     @Schema(description = "PostSavingsAccountsAccountIdResponse")
diff --git 
a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepository.java
 
b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepository.java
index 5a41d3ae12..37dd7b949d 100644
--- 
a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepository.java
+++ 
b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepository.java
@@ -94,4 +94,7 @@ public interface SavingsAccountRepository extends 
JpaRepository<SavingsAccount,
             """)
     List<SavingsAccrualData> findAccrualData(@Param("tillDate") LocalDate 
tillDate, @Param("savingsId") Long savingsId,
             @Param("status") Integer status, @Param("accountingRule") Integer 
accountingRule);
+
+    @Query("SELECT sa.id FROM SavingsAccount sa WHERE sa.status = :status")
+    List<Long> findSavingsAccountIdsByStatusId(Integer status);
 }
diff --git 
a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepositoryWrapper.java
 
b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepositoryWrapper.java
index 562a4548ad..0fca0ace8d 100644
--- 
a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepositoryWrapper.java
+++ 
b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountRepositoryWrapper.java
@@ -186,4 +186,8 @@ public class SavingsAccountRepositoryWrapper {
             final Integer accountingRule) {
         return this.repository.findAccrualData(tillDate, savingsId, status, 
accountingRule);
     }
+
+    public List<Long> findLoanIdsByStatusId(Integer status) {
+        return null;
+    }
 }
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java
index a951f6c85f..f6e2c161cf 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.fineract.integrationtests;
 
-import static java.lang.Integer.parseInt;
 import static org.apache.http.HttpStatus.SC_FORBIDDEN;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -2459,7 +2458,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest 
{
         ResponseSpecification conflictResponseSpec = new 
ResponseSpecBuilder().expectStatusCode(409).build();
         ErrorResponse errorResponse = 
BatchHelper.postBatchRequestsWithoutEnclosingTransactionError(requestSpec, 
conflictResponseSpec,
                 jsonifiedRepaymentRequest);
-        assertEquals(409, parseInt(errorResponse.getHttpStatusCode()));
+        assertEquals(409, errorResponse.getHttpStatusCode());
     }
 
     /**
@@ -2541,7 +2540,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest 
{
         ResponseSpecification conflictResponseSpec = new 
ResponseSpecBuilder().expectStatusCode(409).build();
         ErrorResponse errorResponse = 
BatchHelper.postBatchRequestsWithoutEnclosingTransactionError(requestSpec, 
conflictResponseSpec,
                 jsonifiedRepaymentRequest);
-        assertEquals(409, parseInt(errorResponse.getHttpStatusCode()));
+        assertEquals(409, errorResponse.getHttpStatusCode());
     }
 
     @Test
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchLoanIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchLoanIntegrationTest.java
index 0cb26879c7..ab8800e3b3 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchLoanIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchLoanIntegrationTest.java
@@ -157,7 +157,7 @@ public class BatchLoanIntegrationTest extends 
BaseLoanIntegrationTest {
                         .approveRescheduleLoan(2L, 1L, "01 January 2023") //
                         .executeEnclosingTransactionError(new 
ResponseSpecBuilder().expectStatusCode(409).build()); //
 
-                Assertions.assertEquals(HttpStatus.SC_CONFLICT, 
Integer.parseInt(response.getHttpStatusCode()));
+                Assertions.assertEquals(HttpStatus.SC_CONFLICT, 
response.getHttpStatusCode());
             });
         });
     }
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
index b47b218a0c..70f16b3b99 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
@@ -58,12 +58,14 @@ import 
org.apache.fineract.integrationtests.common.charges.ChargesHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -72,6 +74,7 @@ import org.slf4j.LoggerFactory;
  */
 @SuppressWarnings({ "rawtypes" })
 @Order(2)
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class ClientSavingsIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(ClientSavingsIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
index e141459132..b77448e61c 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
@@ -37,14 +37,17 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @SuppressWarnings({ "rawtypes", "unused", "unchecked" })
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class FlexibleSavingsInterestPostingIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
index 0d62177e5b..b2354792d1 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
@@ -46,9 +46,11 @@ import 
org.apache.fineract.integrationtests.common.charges.ChargesHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,6 +58,7 @@ import org.slf4j.LoggerFactory;
  * Group Savings Integration Test for checking Savings Application.
  */
 @SuppressWarnings({ "rawtypes", "unused" })
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class GroupSavingsIntegrationTest {
 
     public static final String DEPOSIT_AMOUNT = "2000";
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountBalanceCheckAfterReversalTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountBalanceCheckAfterReversalTest.java
index 0e6c7e3a2c..065cfe5064 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountBalanceCheckAfterReversalTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountBalanceCheckAfterReversalTest.java
@@ -34,10 +34,13 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountBalanceCheckAfterReversalTest {
 
     public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java
index 5616f3aa22..09f61b7974 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java
@@ -37,11 +37,13 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,6 +52,7 @@ import org.slf4j.LoggerFactory;
  */
 @SuppressWarnings({ "rawtypes" })
 @Order(2)
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountRecalculateBalanceTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsAccountRecalculateBalanceTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java
index 711719a4a5..89ebaa4f96 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java
@@ -46,12 +46,15 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.apache.fineract.integrationtests.common.system.DatatableHelper;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountTransactionDatatableIntegrationTest {
 
     private static final String SAVINGS_TRANSACTION_APP_TABLE_NAME = 
EntityTables.SAVINGS_TRANSACTION.getName();
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java
index 9fd39870c6..935570b15d 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java
@@ -67,15 +67,18 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsTransactionData;
 import org.apache.fineract.integrationtests.common.system.DatatableHelper;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @SuppressWarnings({ "rawtypes" })
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountTransactionTest {
 
     private static final Logger log = 
LoggerFactory.getLogger(SavingsAccountTransactionTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java
index e97a9293af..7fb3fd75c3 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java
@@ -50,16 +50,19 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType;
 import org.apache.fineract.portfolio.search.data.TransactionSearchRequest;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
 
 @SuppressWarnings({ "rawtypes" })
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountTransactionsSearchIntegrationTest {
 
     public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsExternalIdTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsExternalIdTest.java
index ee1639b1d9..e16b3883d0 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsExternalIdTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsExternalIdTest.java
@@ -33,12 +33,15 @@ import 
org.apache.fineract.client.models.PutSavingsAccountsAccountIdResponse;
 import org.apache.fineract.client.models.SavingsAccountData;
 import org.apache.fineract.client.util.Calls;
 import org.apache.fineract.integrationtests.client.IntegrationTest;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import retrofit2.Response;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountsExternalIdTest extends IntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsAccountsExternalIdTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsTest.java
index 4c950700af..4beb876bcc 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsTest.java
@@ -25,8 +25,10 @@ import 
org.apache.fineract.client.models.PostSavingsAccountsRequest;
 import org.apache.fineract.client.models.PostSavingsAccountsResponse;
 import org.apache.fineract.integrationtests.client.IntegrationTest;
 import org.apache.fineract.integrationtests.common.Utils;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import retrofit2.Response;
@@ -37,6 +39,7 @@ import retrofit2.Response;
  * @author Danish Jamal
  *
  */
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccountsTest extends IntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsAccountsTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualAccountingIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualAccountingIntegrationTest.java
index 2ba3dcc25b..309e6abf8e 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualAccountingIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualAccountingIntegrationTest.java
@@ -44,12 +44,15 @@ import 
org.apache.fineract.integrationtests.common.accounting.AccountHelper;
 import 
org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccrualAccountingIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsAccrualAccountingIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualIntegrationTest.java
index cb9044b72a..2383310592 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccrualIntegrationTest.java
@@ -45,12 +45,15 @@ import 
org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsAccrualIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsAccrualIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java
index 9fb187c3f9..c0196d2679 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java
@@ -44,14 +44,17 @@ import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @SuppressWarnings({ "rawtypes", "unused", "unchecked" })
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsInterestPostingIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsInterestPostingIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java
index 93dd71f137..317d17ad31 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java
@@ -48,15 +48,18 @@ import 
org.apache.fineract.integrationtests.common.charges.ChargesHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Order(2)
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsInterestPostingJobIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsInterestPostingJobIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingTest.java
index 0ef98a63c9..2e368f0c65 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingTest.java
@@ -49,13 +49,16 @@ import 
org.apache.fineract.integrationtests.common.accounting.AccountHelper;
 import 
org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsInterestPostingTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsInterestPostingTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsProductCreationIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsProductCreationIntegrationTest.java
index b59f8db0c3..fe3c8b5287 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsProductCreationIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsProductCreationIntegrationTest.java
@@ -29,12 +29,15 @@ import 
org.apache.fineract.integrationtests.common.accounting.Account;
 import org.apache.fineract.integrationtests.common.accounting.AccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsProductCreationIntegrationTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsProductCreationIntegrationTest.class);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/error/ErrorResponse.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/error/ErrorResponse.java
index 66e5465089..f90960dc31 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/error/ErrorResponse.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/error/ErrorResponse.java
@@ -18,10 +18,57 @@
  */
 package org.apache.fineract.integrationtests.common.error;
 
-import lombok.Data;
+import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.List;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.apache.fineract.client.util.JSON;
+import retrofit2.Response;
 
-@Data
+@NoArgsConstructor
+@Getter
+@Setter
 public class ErrorResponse {
 
-    private String httpStatusCode;
+    private static final Gson GSON = new JSON().getGson();
+
+    private String developerMessage;
+    private Integer httpStatusCode;
+    private List<Error> errors;
+
+    public Error getSingleError() {
+        if (errors.size() != 1) {
+            throw new IllegalStateException("Multiple errors found");
+        } else {
+            return errors.iterator().next();
+        }
+    }
+
+    public static ErrorResponse from(Response retrofitResponse) {
+        try {
+            String errorBody = retrofitResponse.errorBody().string();
+            return GSON.fromJson(errorBody, ErrorResponse.class);
+        } catch (IOException e) {
+            throw new RuntimeException("Error while parsing the error body", 
e);
+        }
+    }
+
+    @NoArgsConstructor
+    @Getter
+    @Setter
+    public static class Error {
+
+        private String developerMessage;
+        private List<ErrorMessageArg> args;
+    }
+
+    @NoArgsConstructor
+    @Getter
+    @Setter
+    public static class ErrorMessageArg {
+
+        private Object value;
+    }
 }
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
index 8434b98d23..1fe7e77b82 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
@@ -44,6 +44,10 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import org.apache.fineract.client.models.PagedLocalRequestAdvancedQueryRequest;
+import org.apache.fineract.client.models.PostSavingsAccountTransactionsRequest;
+import 
org.apache.fineract.client.models.PostSavingsAccountTransactionsResponse;
+import org.apache.fineract.client.models.PostSavingsAccountsAccountIdRequest;
+import org.apache.fineract.client.models.PostSavingsAccountsAccountIdResponse;
 import 
org.apache.fineract.client.models.SavingsAccountTransactionsSearchResponse;
 import org.apache.fineract.client.util.Calls;
 import org.apache.fineract.client.util.JSON;
@@ -56,6 +60,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.jupiter.api.Assertions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import retrofit2.Response;
 
 @SuppressWarnings({ "rawtypes" })
 public class SavingsAccountHelper {
@@ -116,6 +121,10 @@ public class SavingsAccountHelper {
         this.responseSpec = responseSpec;
     }
 
+    public static List<Long> getSavingsIdsByStatusId(int status) {
+        return 
Calls.ok(FineractClientHelper.getFineractClient().legacy.getSavingsAccountsByStatus(status));
+    }
+
     public RequestSpecification getRequestSpec() {
         return requestSpec;
     }
@@ -368,6 +377,10 @@ public class SavingsAccountHelper {
                 getCloseAccountJSON(withdrawBalance, LAST_TRANSACTION_DATE), 
IS_BLOCK);
     }
 
+    public PostSavingsAccountsAccountIdResponse closeSavingsAccount(final Long 
savingsId, PostSavingsAccountsAccountIdRequest request) {
+        return 
Calls.ok(FineractClientHelper.getFineractClient().savingsAccounts.handleCommands6(savingsId,
 request, "close"));
+    }
+
     // TODO: Rewrite to use fineract-client instead!
     // Example: 
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
     // org.apache.fineract.client.models.PostLoansLoanIdRequest)
@@ -416,6 +429,16 @@ public class SavingsAccountHelper {
         return withdrawalFromSavingsAccount(savingsId, 
getSavingsTransactionJSON(amount, date), jsonAttributeToGetback);
     }
 
+    public Response<PostSavingsAccountTransactionsResponse> 
withdrawalFromSavingsAccount(final Long savingsId,
+            PostSavingsAccountTransactionsRequest request) {
+        return 
Calls.executeU(FineractClientHelper.getFineractClient().savingsTransactions.transaction2(savingsId,
 request, "withdrawal"));
+    }
+
+    public Response<PostSavingsAccountTransactionsResponse> 
depositIntoSavingsAccount(final Long savingsId,
+            PostSavingsAccountTransactionsRequest request) {
+        return 
Calls.executeU(FineractClientHelper.getFineractClient().savingsTransactions.transaction2(savingsId,
 request, "deposit"));
+    }
+
     // TODO: Rewrite to use fineract-client instead!
     // Example: 
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
     // org.apache.fineract.client.models.PostLoansLoanIdRequest)
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsTestLifecycleExtension.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsTestLifecycleExtension.java
new file mode 100644
index 0000000000..38458df811
--- /dev/null
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/savings/SavingsTestLifecycleExtension.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests.common.savings;
+
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.builder.ResponseSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.specification.RequestSpecification;
+import io.restassured.specification.ResponseSpecification;
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.models.PostSavingsAccountTransactionsRequest;
+import org.apache.fineract.client.models.PostSavingsAccountsAccountIdRequest;
+import org.apache.fineract.client.models.SavingsAccountData;
+import org.apache.fineract.client.util.Calls;
+import org.apache.fineract.infrastructure.core.service.MathUtil;
+import org.apache.fineract.integrationtests.common.BusinessDateHelper;
+import org.apache.fineract.integrationtests.common.FineractClientHelper;
+import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+@Slf4j
+public class SavingsTestLifecycleExtension implements AfterAllCallback {
+
+    private SavingsAccountHelper savingsAccountHelper;
+    private SchedulerJobHelper schedulerJobHelper;
+    public static final String DATE_FORMAT = "dd MMMM yyyy";
+    private final DateTimeFormatter dateFormatter = new 
DateTimeFormatterBuilder().appendPattern(DATE_FORMAT).toFormatter();
+
+    @Override
+    public void afterAll(ExtensionContext context) {
+        
BusinessDateHelper.runAt(DateTimeFormatter.ofPattern(DATE_FORMAT).format(Utils.getLocalDateOfTenant()),
 () -> {
+            RequestSpecification requestSpec = new 
RequestSpecBuilder().setContentType(ContentType.JSON).build();
+            requestSpec.header("Authorization", "Basic " + 
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+            requestSpec.header("Fineract-Platform-TenantId", "default");
+            ResponseSpecification responseSpec = new 
ResponseSpecBuilder().expectStatusCode(200).build();
+            this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, 
responseSpec);
+            this.schedulerJobHelper = new SchedulerJobHelper(requestSpec);
+
+            // Close open savings accounts
+            List<Long> savingsIds = 
SavingsAccountHelper.getSavingsIdsByStatusId(300);
+            savingsIds.forEach(savingsId -> {
+                try {
+                    
this.savingsAccountHelper.postInterestForSavings(savingsId.intValue());
+                    SavingsAccountData savingsAccountData = Calls
+                            
.ok(FineractClientHelper.getFineractClient().savingsAccounts.retrieveOne25(savingsId,
 false, null, "all"));
+                    BigDecimal accountBalance = 
MathUtil.subtract(savingsAccountData.getSummary().getAvailableBalance(),
+                            savingsAccountData.getMinRequiredBalance(), 
MathContext.DECIMAL64);
+                    if (accountBalance.compareTo(BigDecimal.ZERO) > 0) {
+                        savingsAccountHelper.closeSavingsAccount(savingsId,
+                                new 
PostSavingsAccountsAccountIdRequest().locale("en").dateFormat(DATE_FORMAT)
+                                        
.closedOnDate(dateFormatter.format(Utils.getLocalDateOfTenant())).withdrawBalance(true));
+                    } else if (accountBalance.compareTo(BigDecimal.ZERO) < 0) {
+                        
savingsAccountHelper.depositIntoSavingsAccount(savingsId,
+                                new 
PostSavingsAccountTransactionsRequest().locale("en").dateFormat(DATE_FORMAT)
+                                        
.transactionDate(dateFormatter.format(Utils.getLocalDateOfTenant()))
+                                        
.transactionAmount(accountBalance.abs()).paymentTypeId(1));
+                        savingsAccountHelper.closeSavingsAccount(savingsId, 
new PostSavingsAccountsAccountIdRequest().locale("en")
+                                
.dateFormat(DATE_FORMAT).closedOnDate(dateFormatter.format(Utils.getLocalDateOfTenant())));
+                    }
+                } catch (Exception e) {
+                    log.warn("Unable to close savings account: {}, Reason: 
{}", savingsId, e.getMessage());
+                }
+            });
+        });
+    }
+}
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/SavingsInterestPostingTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/SavingsInterestPostingTest.java
index 867195e080..8138d8575d 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/SavingsInterestPostingTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/SavingsInterestPostingTest.java
@@ -29,11 +29,14 @@ import 
org.apache.fineract.client.models.PostSavingsProductsResponse;
 import org.apache.fineract.client.models.SavingsAccountData;
 import org.apache.fineract.client.models.SavingsAccountTransactionData;
 import org.apache.fineract.integrationtests.common.ClientHelper;
+import 
org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
 import 
org.apache.fineract.integrationtests.savings.base.BaseSavingsIntegrationTest;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 @Order(2)
+@ExtendWith({ SavingsTestLifecycleExtension.class })
 public class SavingsInterestPostingTest extends BaseSavingsIntegrationTest {
 
     @Test


Reply via email to