Skip to content

Commit

Permalink
FINERACT-1755:withdrawal fee is not considered for interest calculati…
Browse files Browse the repository at this point in the history
…on (#2639)
  • Loading branch information
logoutdhaval authored and vidakovic committed Nov 28, 2022
1 parent 90f854b commit 2a6f479
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ public boolean isChargeTransaction() {
}

public boolean isAnnualFee() {
return this.value.equals(SavingsAccountTransactionType.ANNUAL_FEE.getValue().toString());
return Long.valueOf(SavingsAccountTransactionType.ANNUAL_FEE.getValue()).equals(this.id);
}

public boolean isPayCharge() {
return this.value.equals(SavingsAccountTransactionType.PAY_CHARGE.getValue().toString());
return Long.valueOf(SavingsAccountTransactionType.PAY_CHARGE.getValue()).equals(this.id);
}

public boolean isWithdrawalFee() {
return this.value.equals(SavingsAccountTransactionType.WITHDRAWAL_FEE.getValue().toString());
return Long.valueOf(SavingsAccountTransactionType.WITHDRAWAL_FEE.getValue()).equals(this.id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,31 @@ public void testAccountBalanceWithWithdrawalFeeAfterInterestPostingJob() {
for (Map.Entry<String, Object> entry : interestPostingTransaction.entrySet()) {
LOG.info("{} - {}", entry.getKey(), entry.getValue().toString());
}
assertEquals("800.4932", interestPostingTransaction.get("runningBalance").toString(), "Equality check for Balance");
assertEquals("800.4384", interestPostingTransaction.get("runningBalance").toString(), "Equality check for Balance");
}

@Test
public void testAccountBalanceWithWithdrawalFeeAfterInterestPostingJobInOverdraftAccount() {
final String startDate = "21 June 2022";
final String jobName = "Post Interest For Savings";
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, startDate);
Assertions.assertNotNull(clientID);

final Integer savingsId = createOverdraftSavingsAccountDailyPostingWithCharge(clientID, startDate);

this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, "1000", startDate, CommonConstants.RESPONSE_RESOURCE_ID);
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
Float balance = Float.parseFloat("-1100.0");
assertEquals(balance, summary.get("accountBalance"), "Verifying account balance is -1100");

this.scheduleJobHelper.executeAndAwaitJob(jobName);
Object transactionObj = this.savingsAccountHelper.getSavingsDetails(savingsId, "transactions");
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) transactionObj;
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 3);
for (Map.Entry<String, Object> entry : interestPostingTransaction.entrySet()) {
LOG.info("{} - {}", entry.getKey(), entry.getValue().toString());
}
assertEquals("-1100.3014", interestPostingTransaction.get("runningBalance").toString(), "Equality check for Balance");
}

private Integer createSavingsAccountDailyPosting(final Integer clientID, final String startDate) {
Expand Down Expand Up @@ -263,6 +287,25 @@ private Integer createSavingsAccountDailyPostingWithCharge(final Integer clientI
return savingsId;
}

private Integer createOverdraftSavingsAccountDailyPostingWithCharge(final Integer clientID, final String startDate) {
final Integer savingsProductID = createSavingsProductDailyPostingOverdraft();
Assertions.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID, savingsProductID,
ACCOUNT_TYPE_INDIVIDUAL, startDate);
Assertions.assertNotNull(savingsId);

final Integer withdrawalChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getSavingsWithdrawalFeeJSON());
Assertions.assertNotNull(withdrawalChargeId);

this.savingsAccountHelper.addChargesForSavings(savingsId, withdrawalChargeId, false);
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.activateSavingsAccount(savingsId, startDate);
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
return savingsId;
}

private Integer createSavingsAccountDailyPostingOverdraft(final Integer clientID, final String startDate) {
final Integer savingsProductID = createSavingsProductDailyPostingOverdraft();
Assertions.assertNotNull(savingsProductID);
Expand Down

0 comments on commit 2a6f479

Please sign in to comment.