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 ;
5556import org .junit .jupiter .api .Test ;
5657import org .slf4j .Logger ;
5758import org .slf4j .LoggerFactory ;
5859
60+ @ Disabled ("Disabled till FINERACT-2378 fixed" )
5961public 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 )
0 commit comments