Skip to content

Commit 3b58f6a

Browse files
authored
FINERACT-2378: Failing integration test: org.apache.fineract.integrationtests.SchedulerJobsTestResults#testInterestTransferForSavings (#5059)
1 parent c694b4a commit 3b58f6a

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/interest/CompoundInterestHelper.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,9 @@ public Money calculateInterestForAllPostingPeriods(final MonetaryCurrency curren
4747
// total interest earned in previous periods but not yet recognised
4848
BigDecimal compoundedInterest = BigDecimal.ZERO;
4949
BigDecimal unCompoundedInterest = BigDecimal.ZERO;
50-
LocalDate endDay = DateUtils.getBusinessLocalDate();
5150
final CompoundInterestValues compoundInterestValues = new CompoundInterestValues(compoundedInterest, unCompoundedInterest);
5251
for (final PostingPeriod postingPeriod : allPeriods) {
5352

54-
if (postingPeriod.dateOfPostingTransaction().getMonth() != endDay.getMonth()) {
55-
compoundInterestValues.setCompoundedInterest(interestEarned.getAmount());
56-
}
57-
5853
final BigDecimal interestEarnedThisPeriod = postingPeriod.calculateInterest(compoundInterestValues);
5954

6055
final Money moneyToBePostedForPeriod = Money.of(currency, interestEarnedThisPeriod);
@@ -68,7 +63,6 @@ public Money calculateInterestForAllPostingPeriods(final MonetaryCurrency curren
6863
|| (lockUntil != null && !DateUtils.isAfter(postingPeriod.dateOfPostingTransaction(), lockUntil)))) {
6964
compoundInterestValues.setCompoundedInterest(BigDecimal.ZERO);
7065
}
71-
endDay = postingPeriod.dateOfPostingTransaction();
7266
}
7367

7468
return interestEarned;

integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingTest.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@
5252
import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType;
5353
import org.junit.jupiter.api.Assertions;
5454
import org.junit.jupiter.api.BeforeEach;
55-
import org.junit.jupiter.api.Disabled;
5655
import org.junit.jupiter.api.Test;
5756
import org.slf4j.Logger;
5857
import org.slf4j.LoggerFactory;
5958

60-
@Disabled("Disabled till FINERACT-2378 fixed")
6159
public class SavingsInterestPostingTest {
6260

6361
private static final Logger LOG = LoggerFactory.getLogger(SavingsInterestPostingTest.class);
@@ -90,11 +88,6 @@ public void setup() {
9088
@Test
9189
public void testPostInterestWithOverdraftProduct() {
9290
try {
93-
final LocalDate startDate = LocalDate.of(LocalDate.now(Utils.getZoneIdOfTenant()).getYear(), 2, 1);
94-
// Simulate time passing - update business date to February
95-
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
96-
new PutGlobalConfigurationsRequest().enabled(true));
97-
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, startDate);
9891
final String amount = "10000";
9992

10093
final Account assetAccount = accountHelper.createAssetAccount();
@@ -110,7 +103,7 @@ public void testPostInterestWithOverdraftProduct() {
110103
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
111104

112105
final Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2025");
113-
106+
final LocalDate startDate = LocalDate.of(2025, 2, 1);
114107
final String startDateString = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US).format(startDate);
115108

116109
final Integer accountId = savingsAccountHelper.applyForSavingsApplicationOnDate(clientId, productId,
@@ -120,7 +113,7 @@ public void testPostInterestWithOverdraftProduct() {
120113
savingsAccountHelper.depositToSavingsAccount(accountId, amount, startDateString, CommonConstants.RESPONSE_RESOURCE_ID);
121114

122115
// Simulate time passing - update business date to March
123-
LocalDate marchDate = LocalDate.of(startDate.getYear(), 3, 1);
116+
LocalDate marchDate = LocalDate.of(2025, 3, 2);
124117
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, marchDate);
125118

126119
runAccrualsThenPost();
@@ -129,9 +122,7 @@ public void testPostInterestWithOverdraftProduct() {
129122
BigDecimal expected = calcInterestPosting(productHelper, amount, days);
130123

131124
List<HashMap> txs = getInterestTransactions(accountId);
132-
for (HashMap tx : txs) {
133-
Assertions.assertEquals(expected, BigDecimal.valueOf(((Double) tx.get("amount"))));
134-
}
125+
Assertions.assertEquals(expected, BigDecimal.valueOf(((Double) txs.get(0).get("amount"))), "ERROR in expected");
135126

136127
long interestCount = countInterestOnDate(accountId, marchDate);
137128
long overdraftCount = countOverdraftOnDate(accountId, marchDate);
@@ -163,7 +154,7 @@ public void testOverdraftInterestWithOverdraftProduct() {
163154
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
164155

165156
final Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2025");
166-
final LocalDate startDate = LocalDate.of(LocalDate.now(Utils.getZoneIdOfTenant()).getYear(), 2, 1);
157+
final LocalDate startDate = LocalDate.of(2025, 2, 1);
167158
final String startDateString = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US).format(startDate);
168159

169160
final Integer accountId = savingsAccountHelper.applyForSavingsApplicationOnDate(clientId, productId,
@@ -175,7 +166,7 @@ public void testOverdraftInterestWithOverdraftProduct() {
175166
// Simulate time passing - update business date to March
176167
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
177168
new PutGlobalConfigurationsRequest().enabled(true));
178-
LocalDate marchDate = LocalDate.of(startDate.getYear(), 3, 1);
169+
LocalDate marchDate = LocalDate.of(2025, 3, 1);
179170
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, marchDate);
180171

181172
runAccrualsThenPost();
@@ -220,7 +211,7 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceLess
220211
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
221212

222213
final Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2025");
223-
final LocalDate startDate = LocalDate.of(LocalDate.now(Utils.getZoneIdOfTenant()).getYear(), 2, 1);
214+
final LocalDate startDate = LocalDate.of(2025, 2, 1);
224215
final String startStr = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US).format(startDate);
225216

226217
final Integer accountId = savingsAccountHelper.applyForSavingsApplicationOnDate(clientId, productId,
@@ -229,14 +220,14 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceLess
229220
savingsAccountHelper.activateSavings(accountId, startStr);
230221
savingsAccountHelper.depositToSavingsAccount(accountId, amountDeposit, startStr, CommonConstants.RESPONSE_RESOURCE_ID);
231222

232-
final LocalDate withdrawalDate = LocalDate.of(startDate.getYear(), 2, 16);
223+
final LocalDate withdrawalDate = LocalDate.of(2025, 2, 16);
233224
final String withdrawalStr = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US).format(withdrawalDate);
234225
savingsAccountHelper.withdrawalFromSavingsAccount(accountId, amountWithdrawal, withdrawalStr,
235226
CommonConstants.RESPONSE_RESOURCE_ID);
236227

237228
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
238229
new PutGlobalConfigurationsRequest().enabled(true));
239-
LocalDate marchDate = LocalDate.of(startDate.getYear(), 3, 1);
230+
LocalDate marchDate = LocalDate.of(2025, 3, 1);
240231
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, marchDate);
241232

242233
runAccrualsThenPost();
@@ -290,7 +281,7 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceGrea
290281
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
291282

292283
final Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2025");
293-
final LocalDate startDate = LocalDate.of(LocalDate.now(Utils.getZoneIdOfTenant()).getYear(), 2, 1);
284+
final LocalDate startDate = LocalDate.of(2025, 2, 1);
294285
final String startStr = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US).format(startDate);
295286

296287
final Integer accountId = savingsAccountHelper.applyForSavingsApplicationOnDate(clientId, productId,
@@ -299,13 +290,13 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceGrea
299290
savingsAccountHelper.activateSavings(accountId, startStr);
300291
savingsAccountHelper.withdrawalFromSavingsAccount(accountId, amountWithdrawal, startStr, CommonConstants.RESPONSE_RESOURCE_ID);
301292

302-
final LocalDate depositDate = LocalDate.of(startDate.getYear(), 2, 16);
293+
final LocalDate depositDate = LocalDate.of(2025, 2, 16);
303294
final String depositStr = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US).format(depositDate);
304295
savingsAccountHelper.depositToSavingsAccount(accountId, amountDeposit, depositStr, CommonConstants.RESPONSE_RESOURCE_ID);
305296

306297
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
307298
new PutGlobalConfigurationsRequest().enabled(true));
308-
LocalDate marchDate = LocalDate.of(startDate.getYear(), 3, 1);
299+
LocalDate marchDate = LocalDate.of(2025, 3, 1);
309300
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, marchDate);
310301

311302
runAccrualsThenPost();
@@ -356,7 +347,6 @@ private List<HashMap> getInterestTransactions(Integer savingsAccountId) {
356347

357348
public Integer createSavingsProductWithAccrualAccountingWithOutOverdraftAllowed(final String interestPayableAccount,
358349
final String savingsControlAccount, final String interestReceivableAccount, final Account... accounts) {
359-
360350
LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT WITHOUT OVERDRAFT ---------------------------------------");
361351
this.productHelper = new SavingsProductHelper().withOverDraftRate("100000", "21")
362352
.withAccountInterestReceivables(interestReceivableAccount).withSavingsControlAccountId(savingsControlAccount)

integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
import org.junit.jupiter.api.Assertions;
9292
import org.junit.jupiter.api.BeforeAll;
9393
import org.junit.jupiter.api.BeforeEach;
94-
import org.junit.jupiter.api.Disabled;
9594
import org.junit.jupiter.api.MethodOrderer.MethodName;
9695
import org.junit.jupiter.api.Order;
9796
import org.junit.jupiter.api.Test;
@@ -1266,7 +1265,6 @@ public void testUpdateOverdueDaysForNPA() throws InterruptedException {
12661265
}
12671266

12681267
@Test
1269-
@Disabled("Disabled due to FINERACT-2378")
12701268
public void testInterestTransferForSavings() throws InterruptedException {
12711269
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
12721270
FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec);

0 commit comments

Comments
 (0)