FINERACT-1510-reversal-transaction-posting (#2046)
This commit is contained in:
+55
@@ -2392,4 +2392,59 @@ public class ClientSavingsIntegrationTest {
|
||||
HashMap summaryTwo = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(balanceAfterChargeTwo, summaryTwo.get("accountBalance"), "Verifying Balance after withdrawal charge two ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Transaction reversal feature, here a new reversal transaction is posted when a savings transaction is
|
||||
* reversed
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testAccountBalanceAfterSavingsTransactionReversalPosting() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
// Assertions.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = "0";
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = true;
|
||||
final String MINIMUM_OPENING_BALANCE = "0";
|
||||
|
||||
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(savingsId);
|
||||
|
||||
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "500",
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
|
||||
this.savingsAccountHelper.reverseSavingsAccountTransaction(savingsId, depositTransactionId);
|
||||
|
||||
HashMap reversedDepositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
|
||||
|
||||
Assertions.assertTrue((Boolean) reversedDepositTransaction.get("reversed"));
|
||||
|
||||
List<HashMap> transactions = this.savingsAccountHelper.getSavingsTransactions(savingsId);
|
||||
|
||||
HashMap reversalDepositTransaction = transactions.get(0);
|
||||
|
||||
Assertions.assertTrue((Boolean) reversalDepositTransaction.get("isReversal"));
|
||||
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
Float balance = Float.parseFloat("0.0");
|
||||
|
||||
assertEquals(balance, summary.get("accountBalance"), "Verifying opening Balance is 500");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.integrationtests.common.savings;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
@@ -69,6 +70,7 @@ public class SavingsAccountHelper {
|
||||
private static final String GSIM_DEPOSIT_SAVINGS_COMMAND = "gsimDeposit";
|
||||
private static final String MODIFY_TRASACTION_COMMAND = "modify";
|
||||
private static final String UNDO_TRASACTION_COMMAND = "undo";
|
||||
private static final String REVERSE_TRASACTION_COMMAND = "reverse";
|
||||
|
||||
private static final String BLOCK_SAVINGS_COMMAND = "block";
|
||||
private static final String UNBLOCK_SAVINGS_COMMAND = "unblock";
|
||||
@@ -272,6 +274,12 @@ public class SavingsAccountHelper {
|
||||
getSavingsTransactionJSON("0", LAST_TRANSACTION_DATE), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer reverseSavingsAccountTransaction(final Integer savingsId, final Integer transactionId) {
|
||||
LOG.info("\n--------------------------------- REVERSE SAVINGS TRANSACTION --------------------------------");
|
||||
return (Integer) performSavingActions(createAdjustTransactionURL(REVERSE_TRASACTION_COMMAND, savingsId, transactionId),
|
||||
getSavingsTransactionJSON("0", LAST_TRANSACTION_DATE), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public void calculateInterestForSavings(final Integer savingsId) {
|
||||
LOG.info("--------------------------------- CALCULATING INTEREST FOR SAVINGS --------------------------------");
|
||||
performSavingActions(createSavingsCalculateInterestURL(CALCULATE_INTEREST_SAVINGS_COMMAND, savingsId),
|
||||
@@ -598,6 +606,12 @@ public class SavingsAccountHelper {
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
public List<HashMap> getSavingsTransactions(final Integer savingsID) {
|
||||
final Object get = getSavingsCollectionAttribute(savingsID, "transactions");
|
||||
final String json = new Gson().toJson(get);
|
||||
return new Gson().fromJson(json, new TypeToken<ArrayList<HashMap>>() {}.getType());
|
||||
}
|
||||
|
||||
public Object getSavingsInterest(final Integer savingsID) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?associations=summary&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
|
||||
Reference in New Issue
Block a user