Skip to content

Commit 1082067

Browse files
authored
Revert "FINERACT-2378: Failing integration test: org.apache.fineract.integrat…" (#5064)
This reverts commit 3b58f6a.
1 parent 3b58f6a commit 1082067

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ 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();
5051
final CompoundInterestValues compoundInterestValues = new CompoundInterestValues(compoundedInterest, unCompoundedInterest);
5152
for (final PostingPeriod postingPeriod : allPeriods) {
5253

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

5560
final Money moneyToBePostedForPeriod = Money.of(currency, interestEarnedThisPeriod);
@@ -63,6 +68,7 @@ public Money calculateInterestForAllPostingPeriods(final MonetaryCurrency curren
6368
|| (lockUntil != null && !DateUtils.isAfter(postingPeriod.dateOfPostingTransaction(), lockUntil)))) {
6469
compoundInterestValues.setCompoundedInterest(BigDecimal.ZERO);
6570
}
71+
endDay = postingPeriod.dateOfPostingTransaction();
6672
}
6773

6874
return interestEarned;

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@
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;
5556
import org.junit.jupiter.api.Test;
5657
import org.slf4j.Logger;
5758
import org.slf4j.LoggerFactory;
5859

60+
@Disabled("Disabled till FINERACT-2378 fixed")
5961
public class SavingsInterestPostingTest {
6062

6163
private static final Logger LOG = LoggerFactory.getLogger(SavingsInterestPostingTest.class);
@@ -88,6 +90,11 @@ public void setup() {
8890
@Test
8991
public void testPostInterestWithOverdraftProduct() {
9092
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);
9198
final String amount = "10000";
9299

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

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

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

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

119126
runAccrualsThenPost();
@@ -122,7 +129,9 @@ public void testPostInterestWithOverdraftProduct() {
122129
BigDecimal expected = calcInterestPosting(productHelper, amount, days);
123130

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

127136
long interestCount = countInterestOnDate(accountId, marchDate);
128137
long overdraftCount = countOverdraftOnDate(accountId, marchDate);
@@ -154,7 +163,7 @@ public void testOverdraftInterestWithOverdraftProduct() {
154163
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
155164

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

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

172181
runAccrualsThenPost();
@@ -211,7 +220,7 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceLess
211220
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
212221

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

217226
final Integer accountId = savingsAccountHelper.applyForSavingsApplicationOnDate(clientId, productId,
@@ -220,14 +229,14 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceLess
220229
savingsAccountHelper.activateSavings(accountId, startStr);
221230
savingsAccountHelper.depositToSavingsAccount(accountId, amountDeposit, startStr, CommonConstants.RESPONSE_RESOURCE_ID);
222231

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

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

233242
runAccrualsThenPost();
@@ -281,7 +290,7 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceGrea
281290
interestReceivableAccount.getAccountID().toString(), assetAccount, incomeAccount, expenseAccount, liabilityAccount);
282291

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

287296
final Integer accountId = savingsAccountHelper.applyForSavingsApplicationOnDate(clientId, productId,
@@ -290,13 +299,13 @@ public void testOverdraftAndInterestPosting_WithOverdraftProduct_WhitBalanceGrea
290299
savingsAccountHelper.activateSavings(accountId, startStr);
291300
savingsAccountHelper.withdrawalFromSavingsAccount(accountId, amountWithdrawal, startStr, CommonConstants.RESPONSE_RESOURCE_ID);
292301

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

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

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

348357
public Integer createSavingsProductWithAccrualAccountingWithOutOverdraftAllowed(final String interestPayableAccount,
349358
final String savingsControlAccount, final String interestReceivableAccount, final Account... accounts) {
359+
350360
LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT WITHOUT OVERDRAFT ---------------------------------------");
351361
this.productHelper = new SavingsProductHelper().withOverDraftRate("100000", "21")
352362
.withAccountInterestReceivables(interestReceivableAccount).withSavingsControlAccountId(savingsControlAccount)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
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;
9495
import org.junit.jupiter.api.MethodOrderer.MethodName;
9596
import org.junit.jupiter.api.Order;
9697
import org.junit.jupiter.api.Test;
@@ -1265,6 +1266,7 @@ public void testUpdateOverdueDaysForNPA() throws InterruptedException {
12651266
}
12661267

12671268
@Test
1269+
@Disabled("Disabled due to FINERACT-2378")
12681270
public void testInterestTransferForSavings() throws InterruptedException {
12691271
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
12701272
FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec);

0 commit comments

Comments
 (0)