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

manojvm 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 2479dd128 Error with withdraw/deposit transactions after initiating 
hold transaction (#2540)
2479dd128 is described below

commit 2479dd12898839fb4cef701abf438617fcaa5233
Author: logoutdhaval <[email protected]>
AuthorDate: Thu Aug 25 18:04:22 2022 +0530

    Error with withdraw/deposit transactions after initiating hold transaction 
(#2540)
    
    Co-authored-by: Dhaval Maniyar <[email protected]>
---
 .../portfolio/savings/domain/SavingsAccount.java   |  2 +-
 .../ClientSavingsIntegrationTest.java              | 45 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
index 6fac36276..f5ab802ab 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
@@ -1015,7 +1015,7 @@ public class SavingsAccount extends 
AbstractPersistableCustom {
                 if 
(!transaction.getRunningBalance(transactionAmount.getCurrency()).isEqualTo(transactionAmount))
 {
                     transaction.updateRunningBalance(runningBalance);
                 }
-                if (overdraftAmount.isZero() && 
runningBalance.isLessThanZero()) {
+                if (overdraftAmount.isZero() && 
runningBalance.isLessThanZero() && !transaction.isAmountOnHold()) {
                     overdraftAmount = 
overdraftAmount.plus(runningBalance.getAmount().negate());
                 }
                 if (transaction.getId() == null && 
overdraftAmount.isGreaterThanZero()) {
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 5e5b65551..ad1d4d1bb 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
@@ -3114,6 +3114,51 @@ public class ClientSavingsIntegrationTest {
         Assertions.assertFalse(reversalFlag);
     }
 
+    @Test
+    public void testSavingsAccountDepositAfterHoldAmount() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, 
this.responseSpec);
+        final ResponseSpecification errorResponse = new 
ResponseSpecBuilder().expectStatusCode(403).build();
+        final SavingsAccountHelper validationErrorHelper = new 
SavingsAccountHelper(this.requestSpec, errorResponse);
+
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, 
this.responseSpec);
+        ClientHelper.verifyClientCreatedOnServer(this.requestSpec, 
this.responseSpec, clientID);
+
+        final String minBalanceForInterestCalculation = null;
+        final boolean enforceMinRequiredBalance = false;
+        final boolean allowOverdraft = true;
+        final boolean lienAllowed = false;
+
+        final Integer savingsProductID = 
createSavingsProduct(this.requestSpec, this.responseSpec, "0", 
minBalanceForInterestCalculation,
+                enforceMinRequiredBalance, allowOverdraft, lienAllowed);
+        Assertions.assertNotNull(savingsProductID);
+
+        final Integer savingsId = 
this.savingsAccountHelper.applyForSavingsApplication(clientID, 
savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
+        Assertions.assertNotNull(savingsProductID);
+
+        HashMap savingsStatusHashMap = 
SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, 
savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        savingsStatusHashMap = 
this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        savingsStatusHashMap = 
this.savingsAccountHelper.activateSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        this.savingsAccountHelper.holdAmountInSavingsAccount(savingsId, "100", 
lienAllowed, SavingsAccountHelper.TRANSACTION_DATE,
+                CommonConstants.RESPONSE_RESOURCE_ID);
+
+        Integer depositTransactionId = (Integer) 
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "200",
+                SavingsAccountHelper.TRANSACTION_DATE, 
CommonConstants.RESPONSE_RESOURCE_ID);
+
+        Assertions.assertNotNull(depositTransactionId);
+        List<HashMap> error = (List) 
validationErrorHelper.withdrawalFromSavingsAccount(savingsId, "200",
+                SavingsAccountHelper.TRANSACTION_DATE, 
CommonConstants.RESPONSE_ERROR);
+
+        
assertEquals("error.msg.savingsaccount.transaction.insufficient.account.balance",
+                error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+
+    }
+
     private Integer createSavingsAccountDailyPostingOverdraft(final Integer 
clientID, final String startDate) {
         final Integer savingsProductID = 
createSavingsProductDailyPostingOverdraft();
         Assertions.assertNotNull(savingsProductID);

Reply via email to