FINERACT-1330: Pay Charge & withdrawals is violating Overdraft conditions on current and past Transactions

This commit is contained in:
rrpawar96
2022-08-23 11:00:10 +02:00
committed by Arnold Gálovics
parent ed80540a95
commit d75835170a
5 changed files with 99 additions and 6 deletions
@@ -2869,6 +2869,64 @@ public class ClientSavingsIntegrationTest {
assertEquals(balance.toString(), requestedTransaction.get("runningBalance").toString(), "Equality check for Balance");
}
@Test
public void testSavingsAccountChargesBackDate() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
new ResponseSpecBuilder().build());
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, 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, "0", 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 Integer chargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getSavingsSpecifiedDueDateJSON());
Assertions.assertNotNull(chargeId);
ArrayList<HashMap> charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
Assertions.assertTrue(charges == null || charges.size() == 0);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "100", "05 March 2013", CommonConstants.RESPONSE_RESOURCE_ID);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "100", "07 March 2013", CommonConstants.RESPONSE_RESOURCE_ID);
final Integer savingsChargeId = this.savingsAccountHelper.addChargesForSavingsWithDueDate(savingsId, chargeId, "07 March 2013",
200);
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) savingsAccountHelperValidationError
.payChargeToSavingsAccount(savingsId, savingsChargeId, "200", "06 March 2013", CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.savingsaccount.transaction.insufficient.account.balance",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
final Integer payChargeId = this.savingsAccountHelper.payCharge(savingsChargeId, savingsId, "200", "07 March 2013");
Assertions.assertNotNull(payChargeId);
}
@Test
public void testRunningBalanceAfterWithdrawalWithBackdateConfigurationOn() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -263,6 +263,13 @@ public class SavingsAccountHelper {
getSavingsTransactionPaymentTypeJSON(amount, date, paymentType), jsonAttributeToGetback);
}
public Object payChargeToSavingsAccount(final Integer savingsID, final Integer chargeId, final String amount, String date,
String jsonAttributeToGetback) {
LOG.info("--------------------------------- PAY SAVINGS CHARGE --------------------------------");
return performSavingActions(createChargesURL("paycharge", savingsID, chargeId), getSavingsPayChargeJSON(amount, date),
jsonAttributeToGetback);
}
public Integer updateSavingsAccountTransaction(final Integer savingsId, final Integer transactionId, final String amount) {
LOG.info("\n--------------------------------- MODIFY SAVINGS TRANSACTION --------------------------------");
return (Integer) performSavingActions(createAdjustTransactionURL(MODIFY_TRASACTION_COMMAND, savingsId, transactionId),