5252import org .apache .fineract .portfolio .savings .SavingsAccountTransactionType ;
5353import org .junit .jupiter .api .Assertions ;
5454import org .junit .jupiter .api .BeforeEach ;
55- import org .junit .jupiter .api .Disabled ;
5655import org .junit .jupiter .api .Test ;
5756import org .slf4j .Logger ;
5857import org .slf4j .LoggerFactory ;
5958
60- @ Disabled ("Disabled till FINERACT-2378 fixed" )
6159public 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 )
0 commit comments