FINERACT-1931: Savings Account with overdraft - cannot deposit after negative balance

This commit is contained in:
jmarta
2023-09-18 15:19:57 +02:00
committed by Adam Saghy
parent ad3e518291
commit 1f107b4e81
4 changed files with 282 additions and 381 deletions
@@ -3162,7 +3162,56 @@ public class ClientSavingsIntegrationTest {
assertEquals("error.msg.savingsaccount.transaction.insufficient.account.balance",
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
}
@Test
public void testSavingsAccountDepositAfterNegativeHoldAmount() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, "0", null, false, true, false);
Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
this.savingsAccountHelper.approveSavings(savingsId);
HashMap savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
float balance = 0F;
float transactionAmount = 100F;
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId,
String.valueOf(transactionAmount), SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(depositTransactionId);
balance = balance + transactionAmount;
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(balance, summary.get("availableBalance"), "Verifying Balance after deposit");
Integer withdrawalTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId,
String.valueOf(transactionAmount), SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(withdrawalTransactionId);
balance = balance - transactionAmount;
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(balance, summary.get("availableBalance"), "Verifying Balance after withdrawal");
float holdAmount = 50F;
Integer holdTransactionId = (Integer) this.savingsAccountHelper.holdAmountInSavingsAccount(savingsId, String.valueOf(holdAmount),
false, SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(holdTransactionId);
balance = balance - holdAmount;
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(balance, summary.get("availableBalance"), "Verifying Balance after hold amount");
this.savingsAccountHelper.releaseAmount(savingsId, holdTransactionId);
balance = balance + holdAmount;
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(balance, summary.get("availableBalance"), "Verifying Balance after release amount");
depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, String.valueOf(transactionAmount),
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
Assertions.assertNotNull(depositTransactionId);
balance = balance + transactionAmount;
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(balance, summary.get("availableBalance"), "Verifying Balance after hold-release-deposit");
}
private Integer createSavingsAccountDailyPostingOverdraft(final Integer clientID, final String startDate) {