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 552494974 Fineract-1649: Error for Journal entry table
     new 0d5bace36 Merge pull request #2382 from logoutdhaval/fineract-1649
552494974 is described below

commit 55249497419c12cc03978393628a7c39488df4bf
Author: Dhaval Maniyar <[email protected]>
AuthorDate: Mon Jun 27 18:57:29 2022 +0530

    Fineract-1649: Error for Journal entry table
---
 .../service/SavingsSchedularInterestPoster.java    | 63 +++++++++++-----------
 .../SavingsInterestPostingJobIntegrationTest.java  | 48 ++++++++++++++++-
 .../common/accounting/JournalEntryHelper.java      |  2 +-
 3 files changed, 79 insertions(+), 34 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java
index f70b6456f..9c23fc322 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java
@@ -230,37 +230,38 @@ public class SavingsSchedularInterestPoster implements 
Callable<Void> {
                         LocalDate currentDate = 
DateUtils.getLocalDateOfTenant();
                         final SavingsAccountTransactionData dataFromFetch = 
savingsAccountTransactionDataHashMap.get(key);
                         
savingsAccountTransactionData.setId(dataFromFetch.getId());
-
-                        paramsForGLInsertion.add(
-                                new Object[] { 
savingsAccountData.getGlAccountIdForSavingsControl(), 
savingsAccountData.getOfficeId(), null,
-                                        currencyCode, 
SAVINGS_TRANSACTION_IDENTIFIER + 
savingsAccountTransactionData.getId().toString(),
-                                        savingsAccountTransactionData.getId(), 
null, false, null, false,
-                                        
Date.from(savingsAccountTransactionData.getTransactionDate()
-                                                
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
-                                        
JournalEntryType.CREDIT.getValue().longValue(), 
savingsAccountTransactionData.getAmount(), null,
-                                        
JournalEntryType.CREDIT.getValue().longValue(), savingsAccountData.getId(),
-                                        
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
-                                        
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
 false,
-                                        BigDecimal.ZERO, BigDecimal.ZERO, null,
-                                        
Date.from(savingsAccountTransactionData.getTransactionDate()
-                                                
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
-                                        null, Integer.valueOf(1), 
Integer.valueOf(1) });
-
-                        paramsForGLInsertion.add(new Object[] { 
savingsAccountData.getGlAccountIdForInterestOnSavings(),
-                                savingsAccountData.getOfficeId(), null, 
currencyCode,
-                                SAVINGS_TRANSACTION_IDENTIFIER + 
savingsAccountTransactionData.getId().toString(),
-                                savingsAccountTransactionData.getId(), null, 
false, null, false,
-                                
Date.from(savingsAccountTransactionData.getTransactionDate()
-                                        
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
-                                JournalEntryType.DEBIT.getValue().longValue(), 
savingsAccountTransactionData.getAmount(), null,
-                                JournalEntryType.DEBIT.getValue().longValue(), 
savingsAccountData.getId(),
-                                
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
-                                
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
 false,
-                                BigDecimal.ZERO, BigDecimal.ZERO, null,
-                                
Date.from(savingsAccountTransactionData.getTransactionDate()
-                                        
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
-                                null, Integer.valueOf(1), Integer.valueOf(1) 
});
-
+                        if 
(savingsAccountData.getGlAccountIdForSavingsControl() != 0
+                                && 
savingsAccountData.getGlAccountIdForInterestOnSavings() != 0) {
+                            paramsForGLInsertion.add(new Object[] { 
savingsAccountData.getGlAccountIdForSavingsControl(),
+                                    savingsAccountData.getOfficeId(), null, 
currencyCode,
+                                    SAVINGS_TRANSACTION_IDENTIFIER + 
savingsAccountTransactionData.getId().toString(),
+                                    savingsAccountTransactionData.getId(), 
null, false, null, false,
+                                    
Date.from(savingsAccountTransactionData.getTransactionDate()
+                                            
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
+                                    
JournalEntryType.CREDIT.getValue().longValue(), 
savingsAccountTransactionData.getAmount(), null,
+                                    
JournalEntryType.CREDIT.getValue().longValue(), savingsAccountData.getId(),
+                                    
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
+                                    
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
 false,
+                                    BigDecimal.ZERO, BigDecimal.ZERO, null,
+                                    
Date.from(savingsAccountTransactionData.getTransactionDate()
+                                            
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
+                                    null, Integer.valueOf(1), 
Integer.valueOf(1) });
+
+                            paramsForGLInsertion.add(new Object[] { 
savingsAccountData.getGlAccountIdForInterestOnSavings(),
+                                    savingsAccountData.getOfficeId(), null, 
currencyCode,
+                                    SAVINGS_TRANSACTION_IDENTIFIER + 
savingsAccountTransactionData.getId().toString(),
+                                    savingsAccountTransactionData.getId(), 
null, false, null, false,
+                                    
Date.from(savingsAccountTransactionData.getTransactionDate()
+                                            
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
+                                    
JournalEntryType.DEBIT.getValue().longValue(), 
savingsAccountTransactionData.getAmount(), null,
+                                    
JournalEntryType.DEBIT.getValue().longValue(), savingsAccountData.getId(),
+                                    
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
+                                    
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
 false,
+                                    BigDecimal.ZERO, BigDecimal.ZERO, null,
+                                    
Date.from(savingsAccountTransactionData.getTransactionDate()
+                                            
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
+                                    null, Integer.valueOf(1), 
Integer.valueOf(1) });
+                        }
                     }
                 }
             }
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 31ddc620f..a5667f19f 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
@@ -33,6 +33,8 @@ import 
org.apache.fineract.integrationtests.common.CommonConstants;
 import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
 import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
 import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.accounting.AccountHelper;
+import 
org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper;
 import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
 import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
@@ -49,11 +51,13 @@ public class SavingsInterestPostingJobIntegrationTest {
     private static final Logger LOG = 
LoggerFactory.getLogger(SavingsInterestPostingJobIntegrationTest.class);
     public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
 
-    private ResponseSpecification responseSpec;
-    private RequestSpecification requestSpec;
+    private static ResponseSpecification responseSpec;
+    private static RequestSpecification requestSpec;
     private SavingsProductHelper savingsProductHelper;
     private SavingsAccountHelper savingsAccountHelper;
     private SchedulerJobHelper scheduleJobHelper;
+    private JournalEntryHelper journalEntryHelper;
+    private AccountHelper accountHelper;
 
     @BeforeEach
     public void setup() {
@@ -92,6 +96,23 @@ public class SavingsInterestPostingJobIntegrationTest {
         assertEquals("10129.582", 
interestPostingTransaction.get("runningBalance").toString(), "Equality check 
for Balance");
     }
 
+    @Test
+    public void testSavingsDailyInterestPostingJobWithAccountingNone() {
+        final String startDate = "10 April 2022";
+        final String jobName = "Post Interest For Savings";
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, 
this.responseSpec, startDate);
+        Assertions.assertNotNull(clientID);
+        this.accountHelper = new AccountHelper(requestSpec, responseSpec);
+        this.journalEntryHelper = new JournalEntryHelper(requestSpec, 
responseSpec);
+
+        final Integer savingsId = 
createSavingsAccountDailyPostingWithAccounting(clientID, startDate);
+
+        Integer transactionId = (Integer) 
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate,
+                CommonConstants.RESPONSE_RESOURCE_ID);
+        ArrayList<HashMap> journalEntries = 
this.journalEntryHelper.getJournalEntriesByTransactionId(String.valueOf(transactionId));
+        assertEquals(0, journalEntries.size());
+    }
+
     @Test
     public void testSavingsDailyInterestPostingJob() {
         // client activation, savings activation and 1st transaction date
@@ -185,6 +206,19 @@ public class SavingsInterestPostingJobIntegrationTest {
         return savingsId;
     }
 
+    private Integer createSavingsAccountDailyPostingWithAccounting(final 
Integer clientID, final String startDate) {
+        final Integer savingsProductID = createSavingsProduct("1000");
+        Assertions.assertNotNull(savingsProductID);
+        final Integer savingsId = 
this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID, 
savingsProductID,
+                ACCOUNT_TYPE_INDIVIDUAL, startDate);
+        Assertions.assertNotNull(savingsId);
+        HashMap savingsStatusHashMap = 
this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+        savingsStatusHashMap = 
this.savingsAccountHelper.activateSavingsAccount(savingsId, startDate);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+        return savingsId;
+    }
+
     private Integer createSavingsAccountDailyPostingWithCharge(final Integer 
clientID, final String startDate) {
         final Integer savingsProductID = createSavingsProductDailyPosting();
         Assertions.assertNotNull(savingsProductID);
@@ -232,6 +266,16 @@ public class SavingsInterestPostingJobIntegrationTest {
         return SavingsProductHelper.createSavingsProduct(savingsProductJSON, 
requestSpec, responseSpec);
     }
 
+    // Accounting None
+    public static Integer createSavingsProduct(final String 
minOpenningBalance) {
+        LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT 
---------------------------------------");
+        final String savingsProductJSON = new 
SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() //
+                .withInterestCompoundingPeriodTypeAsDaily() //
+                .withInterestCalculationPeriodTypeAsDailyBalance() //
+                
.withMinimumOpenningBalance(minOpenningBalance).withAccountingRuleAsNone().build();
+        return SavingsProductHelper.createSavingsProduct(savingsProductJSON, 
requestSpec, responseSpec);
+    }
+
     // Reset configuration fields
     @AfterEach
     public void tearDown() {
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/accounting/JournalEntryHelper.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/accounting/JournalEntryHelper.java
index a02a7af95..838afcd39 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/accounting/JournalEntryHelper.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/accounting/JournalEntryHelper.java
@@ -93,7 +93,7 @@ public class JournalEntryHelper {
         return url;
     }
 
-    private ArrayList<HashMap> getJournalEntriesByTransactionId(final String 
transactionId) {
+    public ArrayList<HashMap> getJournalEntriesByTransactionId(final String 
transactionId) {
         final String url = 
createURLForGettingAccountEntriesByTransactionId(transactionId);
         final ArrayList<HashMap> response = 
Utils.performServerGet(this.requestSpec, this.responseSpec, url, "pageItems");
         return response;

Reply via email to