Feat: Filter Transactions from last interest posting date (#1933)
This commit is contained in:
+114
@@ -42,6 +42,7 @@ import java.util.Locale;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.CommonConstants;
|
||||
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||
import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
|
||||
import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
|
||||
import org.apache.fineract.integrationtests.common.TaxComponentHelper;
|
||||
@@ -128,6 +129,115 @@ public class ClientSavingsIntegrationTest {
|
||||
// verifySavingsInterest(savingsInterest);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsLastTransactionAndRunningBalanceUpdate() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
// Assertions.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
|
||||
ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assertions.assertTrue(modifications.containsKey("submittedOnDate"));
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
this.savingsAccountHelper.calculateInterestForSavings(savingsId);
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
|
||||
HashMap summaryAfterPosting = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
Assertions.assertNotNull(summaryAfterPosting.get("interestPostedTillDate"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsBackedDatedTransactionsNotAllowed() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
// Assertions.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assertions.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
|
||||
ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assertions.assertTrue(modifications.containsKey("submittedOnDate"));
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
this.savingsAccountHelper.calculateInterestForSavings(savingsId);
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
|
||||
HashMap summaryAfterPosting = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
Assertions.assertNotNull(summaryAfterPosting.get("interestPostedTillDate"));
|
||||
|
||||
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", false);
|
||||
|
||||
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.DATE_FORMAT, Locale.US);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
List dates = (List) summaryAfterPosting.get("interestPostedTillDate");
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0));
|
||||
cal.set(Calendar.MONTH, (Integer) dates.get(1) - 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, (Integer) dates.get(2) - 1);
|
||||
final String depositDate = sdf.format(cal.getTime());
|
||||
LOG.info("-------------------- BackDated Transaction -----------------------------");
|
||||
List<HashMap> error = (List<HashMap>) validationErrorHelper.depositToSavingsAccount(savingsId, "3000", depositDate,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", true);
|
||||
|
||||
// LOG.info(savingsAccountErrorData.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).toString());
|
||||
assertEquals("error.msg.savings.transaction.is.not.allowed", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsAccountWithMinBalanceForInterestCalculation() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
@@ -166,6 +276,10 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
// These two fields are getting updated after an interest posting
|
||||
summary.remove("interestPostedTillDate");
|
||||
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
|
||||
|
||||
+21
-3
@@ -76,6 +76,7 @@ public class GlobalConfigurationHelper {
|
||||
// the future, it needs to be reset here.
|
||||
final Integer configDefaultId = (Integer) configDefault.get("id");
|
||||
final Integer configDefaultValue = (Integer) configDefault.get("value");
|
||||
|
||||
updateValueForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), configDefaultValue.toString());
|
||||
updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(),
|
||||
(Boolean) configDefault.get("enabled"));
|
||||
@@ -88,9 +89,9 @@ public class GlobalConfigurationHelper {
|
||||
ArrayList<HashMap> expectedGlobalConfigurations = getAllDefaultGlobalConfigurations();
|
||||
ArrayList<HashMap> actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec);
|
||||
|
||||
// There are currently 32 global configurations.
|
||||
Assertions.assertEquals(33, expectedGlobalConfigurations.size());
|
||||
Assertions.assertEquals(33, actualGlobalConfigurations.size());
|
||||
// There are currently 35 global configurations.
|
||||
Assertions.assertEquals(35, expectedGlobalConfigurations.size());
|
||||
Assertions.assertEquals(35, actualGlobalConfigurations.size());
|
||||
|
||||
for (int i = 0; i < expectedGlobalConfigurations.size(); i++) {
|
||||
|
||||
@@ -389,6 +390,23 @@ public class GlobalConfigurationHelper {
|
||||
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("trapDoor", false);
|
||||
defaults.add(isNextDayFixedDepositInterestTransferEnabledForPeriodEnd);
|
||||
|
||||
HashMap<String, Object> isAllowedBackDatedTransactionsBeforeInterestPostingDate = new HashMap<>();
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("id", 38);
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("name", "allow-backdated-transaction-before-interest-posting");
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("value", 0);
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("enabled", true);
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("trapDoor", false);
|
||||
defaults.add(isAllowedBackDatedTransactionsBeforeInterestPostingDate);
|
||||
|
||||
HashMap<String, Object> isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays = new HashMap<>();
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("id", 39);
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("name",
|
||||
"allow-backdated-transaction-before-interest-posting-date-for-days");
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("value", 0);
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("enabled", false);
|
||||
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("trapDoor", false);
|
||||
defaults.add(isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays);
|
||||
|
||||
return defaults;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -147,8 +147,8 @@ public class SchedulerJobHelper {
|
||||
* @author Michael Vorburger.ch
|
||||
*/
|
||||
public void executeAndAwaitJob(String jobName) {
|
||||
final Duration timeout = Duration.ofMinutes(3);
|
||||
final Duration pause = Duration.ofSeconds(1);
|
||||
final Duration timeout = Duration.ofMinutes(4);
|
||||
final Duration pause = Duration.ofSeconds(2);
|
||||
DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926
|
||||
Instant beforeExecuteTime = now().truncatedTo(ChronoUnit.SECONDS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user