Merge pull request #2382 from logoutdhaval/fineract-1649

Fineract-1649: Error for Journal entry table
This commit is contained in:
Manoj
2022-06-28 13:59:23 +05:30
committed by GitHub
3 changed files with 78 additions and 33 deletions
@@ -230,37 +230,38 @@ public class SavingsSchedularInterestPoster implements Callable<Void> {
LocalDate currentDate = DateUtils.getLocalDateOfTenant();
final SavingsAccountTransactionData dataFromFetch = savingsAccountTransactionDataHashMap.get(key);
savingsAccountTransactionData.setId(dataFromFetch.getId());
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.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) });
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) });
}
}
}
}
@@ -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() {
@@ -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;