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

avikg 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 a716dbb  FINERACT-1429:FD Interest Transfer on a backdated account 
(#1956)
a716dbb is described below

commit a716dbb6f9de97842bcd0f8f6efe5abca62835ee
Author: Shreyas S Kumar <[email protected]>
AuthorDate: Fri Nov 5 12:34:16 2021 +0530

    FINERACT-1429:FD Interest Transfer on a backdated account (#1956)
---
 .../domain/ConfigurationDomainService.java         |  2 ++
 .../domain/ConfigurationDomainServiceJpa.java      |  7 +++++++
 .../AccountTransfersWritePlatformServiceImpl.java  | 16 +++++++++++++---
 ...it_interest_next_day_for_period_end_posting.sql | 22 ++++++++++++++++++++++
 .../common/GlobalConfigurationHelper.java          | 13 +++++++++++--
 5 files changed, 55 insertions(+), 5 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
index b35611c..85a6547 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
@@ -102,4 +102,6 @@ public interface ConfigurationDomainService {
     String getAccountMappingForPaymentType();
 
     String getAccountMappingForCharge();
+
+    boolean isNextDayFixedDepositInterestTransferEnabledForPeriodEnd();
 }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
index 1f485f5..4db4d93 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
@@ -393,4 +393,11 @@ public class ConfigurationDomainServiceJpa implements 
ConfigurationDomainService
         return defaultValue;
     }
 
+    @Override
+    public boolean isNextDayFixedDepositInterestTransferEnabledForPeriodEnd() {
+        final String propertyName = 
"fixed-deposit-transfer-interest-next-day-for-period-end-posting";
+        final GlobalConfigurationPropertyData property = 
getGlobalConfigurationPropertyData(propertyName);
+        return property.isEnabled();
+    }
+
 }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
index 664d772..dd7ad42 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
@@ -31,6 +31,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
+import 
org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
 import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
 import 
org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
@@ -80,6 +81,7 @@ public class AccountTransfersWritePlatformServiceImpl 
implements AccountTransfer
     private final AccountTransferDetailRepository 
accountTransferDetailRepository;
     private final LoanReadPlatformService loanReadPlatformService;
     private final GSIMRepositoy gsimRepository;
+    private final ConfigurationDomainService configurationDomainService;
 
     @Autowired
     public AccountTransfersWritePlatformServiceImpl(final 
AccountTransfersDataValidator accountTransfersDataValidator,
@@ -88,7 +90,7 @@ public class AccountTransfersWritePlatformServiceImpl 
implements AccountTransfer
             final LoanAssembler loanAssembler, final LoanAccountDomainService 
loanAccountDomainService,
             final SavingsAccountWritePlatformService 
savingsAccountWritePlatformService,
             final AccountTransferDetailRepository 
accountTransferDetailRepository, final LoanReadPlatformService 
loanReadPlatformService,
-            final GSIMRepositoy gsimRepository) {
+            final GSIMRepositoy gsimRepository, ConfigurationDomainService 
configurationDomainService) {
         this.accountTransfersDataValidator = accountTransfersDataValidator;
         this.accountTransferAssembler = accountTransferAssembler;
         this.accountTransferRepository = accountTransferRepository;
@@ -100,6 +102,7 @@ public class AccountTransfersWritePlatformServiceImpl 
implements AccountTransfer
         this.accountTransferDetailRepository = accountTransferDetailRepository;
         this.loanReadPlatformService = loanReadPlatformService;
         this.gsimRepository = gsimRepository;
+        this.configurationDomainService = configurationDomainService;
     }
 
     @Transactional
@@ -371,12 +374,19 @@ public class AccountTransfersWritePlatformServiceImpl 
implements AccountTransfer
                     
AccountTransferType.fromInt(accountTransferDTO.getTransferType()).isInterestTransfer(),
                     accountTransferDTO.isExceptionForBalanceCheck());
 
+            LocalDate transactionDate = 
accountTransferDTO.getTransactionDate();
+            if 
(configurationDomainService.isSavingsInterestPostingAtCurrentPeriodEnd()
+                    && 
configurationDomainService.isNextDayFixedDepositInterestTransferEnabledForPeriodEnd()
+                    && 
AccountTransferType.fromInt(accountTransferDTO.getTransferType()).isInterestTransfer())
 {
+                transactionDate = transactionDate.plusDays(1);
+            }
+
             final SavingsAccountTransaction withdrawal = 
this.savingsAccountDomainService.handleWithdrawal(fromSavingsAccount,
-                    accountTransferDTO.getFmt(), 
accountTransferDTO.getTransactionDate(), 
accountTransferDTO.getTransactionAmount(),
+                    accountTransferDTO.getFmt(), transactionDate, 
accountTransferDTO.getTransactionAmount(),
                     accountTransferDTO.getPaymentDetail(), 
transactionBooleanValues);
 
             final SavingsAccountTransaction deposit = 
this.savingsAccountDomainService.handleDeposit(toSavingsAccount,
-                    accountTransferDTO.getFmt(), 
accountTransferDTO.getTransactionDate(), 
accountTransferDTO.getTransactionAmount(),
+                    accountTransferDTO.getFmt(), transactionDate, 
accountTransferDTO.getTransactionAmount(),
                     accountTransferDTO.getPaymentDetail(), isAccountTransfer, 
isRegularTransaction);
 
             accountTransferDetails = 
this.accountTransferAssembler.assembleSavingsToSavingsTransfer(accountTransferDTO,
 fromSavingsAccount,
diff --git 
a/fineract-provider/src/main/resources/sql/migrations/core_db/V375__transfer_fixed_deposit_interest_next_day_for_period_end_posting.sql
 
b/fineract-provider/src/main/resources/sql/migrations/core_db/V375__transfer_fixed_deposit_interest_next_day_for_period_end_posting.sql
new file mode 100644
index 0000000..acc20cf
--- /dev/null
+++ 
b/fineract-provider/src/main/resources/sql/migrations/core_db/V375__transfer_fixed_deposit_interest_next_day_for_period_end_posting.sql
@@ -0,0 +1,22 @@
+--
+-- 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.
+--
+
+
+INSERT INTO `c_configuration` (`id`, `name`, `enabled`, `description`)
+VALUES (NULL, 
'fixed-deposit-transfer-interest-next-day-for-period-end-posting', '0', 
"Transfer fixed transfer interest next day(t+1) for period end posting");
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
index 6721857..3945539 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
@@ -89,8 +89,8 @@ public class GlobalConfigurationHelper {
         ArrayList<HashMap> actualGlobalConfigurations = 
getAllGlobalConfigurations(requestSpec, responseSpec);
 
         // There are currently 32 global configurations.
-        Assertions.assertEquals(32, expectedGlobalConfigurations.size());
-        Assertions.assertEquals(32, actualGlobalConfigurations.size());
+        Assertions.assertEquals(33, expectedGlobalConfigurations.size());
+        Assertions.assertEquals(33, actualGlobalConfigurations.size());
 
         for (int i = 0; i < expectedGlobalConfigurations.size(); i++) {
 
@@ -380,6 +380,15 @@ public class GlobalConfigurationHelper {
         isAccountMappedForCharge.put("string_value", "Income");
         defaults.add(isAccountMappedForCharge);
 
+        HashMap<String, Object> 
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd = new HashMap<>();
+        isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("id", 37);
+        isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("name",
+                
"fixed-deposit-transfer-interest-next-day-for-period-end-posting");
+        isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("value", 
0);
+        
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("enabled", false);
+        
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("trapDoor", false);
+        defaults.add(isNextDayFixedDepositInterestTransferEnabledForPeriodEnd);
+
         return defaults;
     }
 

Reply via email to