Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public boolean isDebit() {
}

public boolean isWithdrawalFeeAndNotReversed() {
return this.transactionType.isWithdrawalFee() && isNotReversed();
return this.transactionType.isFeeDeduction() && isNotReversed();
}

public boolean isPayCharge() {
Expand Down Expand Up @@ -186,6 +186,10 @@ public Money getRunningBalance(final CurrencyData currency) {
return Money.of(currency, this.runningBalance);
}

public Money getRunningBalance(final MonetaryCurrency currency) {
return Money.of(currency, this.runningBalance);
}

public boolean isDepositAndNotReversed() {
return this.transactionType.isDeposit() && isNotReversed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
Expand Down Expand Up @@ -146,6 +147,31 @@ public void testSavingsDailyOverdraftInterestPostingJob() {

}

@Test
public void testAccountBalanceWithWithdrawalFeeAfterInterestPostingJob() {
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 = createSavingsAccountDailyPostingWithCharge(clientID, startDate);
this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate, CommonConstants.RESPONSE_RESOURCE_ID);

this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, "100", startDate, CommonConstants.RESPONSE_RESOURCE_ID);
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
Float balance = Float.parseFloat("800.0");
assertEquals(balance, summary.get("accountBalance"), "Verifying account balance is 800");

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() - 5);
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");
}

private Integer createSavingsAccountDailyPosting(final Integer clientID, final String startDate) {
final Integer savingsProductID = createSavingsProductDailyPosting();
Assertions.assertNotNull(savingsProductID);
Expand All @@ -159,6 +185,25 @@ private Integer createSavingsAccountDailyPosting(final Integer clientID, final S
return savingsId;
}

private Integer createSavingsAccountDailyPostingWithCharge(final Integer clientID, final String startDate) {
final Integer savingsProductID = createSavingsProductDailyPosting();
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