Merge pull request #898 from Vishwa1311/NEW-ONE-MIFOSX-1117
[MIFOSX-1117] JUnit Test Cases for FD and RD accounts
This commit is contained in:
+211
-1
@@ -2,7 +2,10 @@ package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -16,10 +19,16 @@ import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntry;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
|
||||
import org.mifosplatform.integrationtests.common.charges.ChargesHelper;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositAccountStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.recurringdeposit.RecurringDepositAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.recurringdeposit.RecurringDepositAccountStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.recurringdeposit.RecurringDepositProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
@@ -30,7 +39,7 @@ import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
|
||||
@SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" })
|
||||
public class AccountingScenarioIntegrationTest {
|
||||
|
||||
private static RequestSpecification requestSpec;
|
||||
@@ -66,6 +75,10 @@ public class AccountingScenarioIntegrationTest {
|
||||
private AccountHelper accountHelper;
|
||||
private JournalEntryHelper journalEntryHelper;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
private FixedDepositProductHelper fixedDepositProductHelper;
|
||||
private FixedDepositAccountHelper fixedDepositAccountHelper;
|
||||
private RecurringDepositProductHelper recurringDepositProductHelper;
|
||||
private RecurringDepositAccountHelper recurringDepositAccountHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -300,6 +313,166 @@ public class AccountingScenarioIntegrationTest {
|
||||
assertEquals("Verifying Balance", balance, summary.get("accountBalance"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedDepositAccountingFlow() {
|
||||
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat currentDateFormat = new SimpleDateFormat("dd");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer currentDate = new Integer(currentDateFormat.format(todaysDate.getTime()));
|
||||
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
|
||||
Integer numberOfDaysLeft = (daysInMonth - currentDate) + 1;
|
||||
todaysDate.add(Calendar.DATE, numberOfDaysLeft);
|
||||
final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, assetAccount, incomeAccount, expenseAccount,
|
||||
liabilityAccount);
|
||||
Assert.assertNotNull(fixedDepositProductId);
|
||||
|
||||
Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM,
|
||||
VALID_TO, SUBMITTED_ON_DATE, FixedDepositTest.WHOLE_TERM);
|
||||
Assert.assertNotNull(fixedDepositAccountId);
|
||||
|
||||
HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec,
|
||||
this.responseSpec, fixedDepositAccountId.toString());
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap);
|
||||
|
||||
fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE);
|
||||
FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap);
|
||||
|
||||
HashMap accountSummary = this.fixedDepositAccountHelper.getFixedDepositSummary(fixedDepositAccountId);
|
||||
|
||||
Float depositAmount = (Float) accountSummary.get("totalDeposits");
|
||||
|
||||
// Checking initial Journal entries after Activation.
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT) };
|
||||
final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, ACTIVATION_DATE, assetAccountInitialEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, ACTIVATION_DATE, liablilityAccountInitialEntry);
|
||||
|
||||
Integer transactionIdForPostInterest = this.fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId);
|
||||
Assert.assertNotNull(transactionIdForPostInterest);
|
||||
|
||||
accountSummary = this.fixedDepositAccountHelper.getFixedDepositSummary(fixedDepositAccountId);
|
||||
Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted");
|
||||
|
||||
// Checking initial Journal entries after Interest Posting.
|
||||
final JournalEntry[] expenseAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.DEBIT) };
|
||||
final JournalEntry[] liablilityAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecurringDepositAccountingFlow() {
|
||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat currentDateFormat = new SimpleDateFormat("dd");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer currentDate = new Integer(currentDateFormat.format(todaysDate.getTime()));
|
||||
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
|
||||
Integer numberOfDaysLeft = (daysInMonth - currentDate) + 1;
|
||||
todaysDate.add(Calendar.DATE, numberOfDaysLeft);
|
||||
final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO, assetAccount, liabilityAccount, incomeAccount, expenseAccount);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, RecurringDepositTest.WHOLE_TERM, EXPECTED_FIRST_DEPOSIT_ON_DATE);
|
||||
Assert.assertNotNull(recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount(
|
||||
this.requestSpec, this.responseSpec, recurringDepositAccountId.toString());
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId,
|
||||
APPROVED_ON_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap);
|
||||
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId,
|
||||
ACTIVATION_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap);
|
||||
|
||||
HashMap recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountId);
|
||||
Float depositAmount = (Float) recurringDepositAccountData.get("recurringDepositAmount");
|
||||
|
||||
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE);
|
||||
Assert.assertNotNull(depositTransactionId);
|
||||
|
||||
// Checking initial Journal entries after Activation.
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT) };
|
||||
final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, assetAccountInitialEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, liablilityAccountInitialEntry);
|
||||
|
||||
Integer interestPostingTransactionId = this.recurringDepositAccountHelper
|
||||
.postInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(interestPostingTransactionId);
|
||||
|
||||
HashMap accountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
|
||||
Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted");
|
||||
|
||||
// Checking initial Journal entries after Interest Posting.
|
||||
final JournalEntry[] expenseAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.DEBIT) };
|
||||
final JournalEntry[] liablilityAccountEntry = { new JournalEntry(totalInterestPosted, JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(expenseAccount, INTEREST_POSTED_DATE, expenseAccountEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, INTEREST_POSTED_DATE, liablilityAccountEntry);
|
||||
|
||||
}
|
||||
|
||||
public static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() //
|
||||
@@ -308,4 +481,41 @@ public class AccountingScenarioIntegrationTest {
|
||||
.withMinimumOpenningBalance(minOpenningBalance).withAccountingRuleAsCashBased(accounts).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
|
||||
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
final String fixedDepositProductJSON = fixedDepositProductHelper //
|
||||
.withAccountingRuleAsCashBased(accounts).build(validFrom, validTo);
|
||||
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom,
|
||||
final String validTo, final String submittedOnDate, final String penalInterestType) {
|
||||
System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------");
|
||||
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(submittedOnDate).build(clientID, productID, validFrom, validTo, penalInterestType);
|
||||
return this.fixedDepositAccountHelper
|
||||
.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
|
||||
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
final String recurringDepositProductJSON = recurringDepositProductHelper //
|
||||
.withAccountingRuleAsCashBased(accounts)
|
||||
.build(validFrom, validTo);
|
||||
return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom,
|
||||
final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) {
|
||||
System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------");
|
||||
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec)
|
||||
//
|
||||
.withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate)
|
||||
.build(clientID, productID, validFrom, validTo, penalInterestType);
|
||||
return this.recurringDepositAccountHelper.applyRecurringDepositApplication(recurringDepositApplicationJSON, this.requestSpec,
|
||||
this.responseSpec);
|
||||
}
|
||||
}
|
||||
|
||||
+1219
-97
File diff suppressed because it is too large
Load Diff
+1496
-11
File diff suppressed because it is too large
Load Diff
+37
-13
@@ -56,6 +56,7 @@ public class FixedDepositAccountHelper {
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String BI_ANNUALLY = "6";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
@@ -78,11 +79,10 @@ public class FixedDepositAccountHelper {
|
||||
private final boolean preClosurePenalApplicable = true;
|
||||
private final boolean isActiveChart = true;
|
||||
private final String currencyCode = USD;
|
||||
public static final String depositAmount = "100000";
|
||||
private final String depositAmount = "100000";
|
||||
private final String depositPeriod = "14";
|
||||
private final String depositPeriodFrequencyId = MONTHS;
|
||||
private String submittedOnDate = "";
|
||||
private String savingsId = null;
|
||||
|
||||
public String build(final String clientId, final String productId, final String validFrom, final String validTo,
|
||||
final String penalInterestType) {
|
||||
@@ -157,11 +157,10 @@ public class FixedDepositAccountHelper {
|
||||
map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId);
|
||||
map.put("preClosurePenalInterest", this.preClosurePenalInterest);
|
||||
map.put("preClosurePenalInterestOnTypeId", penalInterestType);
|
||||
map.put("depositAmount", depositAmount);
|
||||
map.put("depositAmount", this.depositAmount);
|
||||
map.put("depositPeriod", this.depositPeriod);
|
||||
map.put("depositPeriodFrequencyId", this.depositPeriodFrequencyId);
|
||||
map.put("submittedOnDate", this.submittedOnDate);
|
||||
map.put("linkAccountId", savingsId);
|
||||
|
||||
String fixedDepositAccountJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountJson);
|
||||
@@ -188,8 +187,9 @@ public class FixedDepositAccountHelper {
|
||||
return response;
|
||||
}
|
||||
|
||||
public static Float getInterestRate(ArrayList<ArrayList<HashMap>> interestSlabData, Integer depositPeriod, Float annualInterestRate) {
|
||||
public static Float getInterestRate(ArrayList<ArrayList<HashMap>> interestSlabData, Integer depositPeriod) {
|
||||
|
||||
Float annualInterestRate = 0.0f;
|
||||
for (Integer slabIndex = 0; slabIndex < interestSlabData.get(0).size(); slabIndex++) {
|
||||
Integer fromPeriod = (Integer) interestSlabData.get(0).get(slabIndex).get("fromPeriod");
|
||||
Integer toPeriod = (Integer) interestSlabData.get(0).get(slabIndex).get("toPeriod");
|
||||
@@ -201,6 +201,35 @@ public class FixedDepositAccountHelper {
|
||||
|
||||
return annualInterestRate;
|
||||
}
|
||||
|
||||
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
|
||||
|
||||
Float totalInterest = 0.0f;
|
||||
Float interestEarned = 0.0f;
|
||||
|
||||
for (int i = 1; i <= depositPeriod; i++) {
|
||||
Integer daysInMonth = currentDate.getActualMaximum(Calendar.DATE);
|
||||
for (int j = 0; j < daysInMonth; j++) {
|
||||
|
||||
interestEarned = (float) (principal * interestPerDay);
|
||||
totalInterest += interestEarned;
|
||||
if (compoundingInterval == 0) {
|
||||
principal += interestEarned;
|
||||
}
|
||||
}
|
||||
if ((i % postingInterval) == 0 || i == depositPeriod) {
|
||||
if (compoundingInterval != 0) {
|
||||
principal += totalInterest;
|
||||
}
|
||||
totalInterest = 0.0f;
|
||||
System.out.println(principal);
|
||||
|
||||
}
|
||||
currentDate.add(Calendar.MONTH, 1);
|
||||
interestEarned = 0.0f;
|
||||
}
|
||||
return principal;
|
||||
}
|
||||
|
||||
public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom,
|
||||
final String validTo, final String penalInterestType, final String submittedOnDate) {
|
||||
@@ -213,10 +242,9 @@ public class FixedDepositAccountHelper {
|
||||
+ Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID,
|
||||
final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear,
|
||||
final String penalInterestType, final String interestCalculationType, final String interestCompoundingPeriodType,
|
||||
final String interestPostingPeriodType) {
|
||||
public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID, final String submittedOnDate,
|
||||
final String validFrom, final String validTo, final String numberOfDaysPerYear, final String penalInterestType,
|
||||
final String interestCalculationType, final String interestCompoundingPeriodType, final String interestPostingPeriodType) {
|
||||
|
||||
final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(submittedOnDate) //
|
||||
@@ -428,8 +456,4 @@ public class FixedDepositAccountHelper {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FixedDepositAccountHelper withSavings(final String savingsId) {
|
||||
this.savingsId = savingsId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -44,6 +44,7 @@ public class FixedDepositProductHelper {
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String BI_ANNUALLY = "6";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
@@ -51,6 +52,8 @@ public class FixedDepositProductHelper {
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String ACCRUAL_PERIODIC = "3";
|
||||
private static final String ACCRUAL_UPFRONT = "4";
|
||||
private static final String WHOLE_TERM = "1";
|
||||
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
|
||||
|
||||
@@ -161,7 +164,7 @@ public class FixedDepositProductHelper {
|
||||
System.out.println(FixedDepositProductCreateJson);
|
||||
return FixedDepositProductCreateJson;
|
||||
}
|
||||
|
||||
|
||||
public FixedDepositProductHelper withAccountingRuleAsNone() {
|
||||
this.accountingRule = NONE;
|
||||
return this;
|
||||
|
||||
+2
@@ -243,6 +243,7 @@ public class LoanProductTestBuilder {
|
||||
map.put("interestOnLoanAccountId", ID);
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
map.put("incomeFromRecoveryAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
@@ -274,6 +275,7 @@ public class LoanProductTestBuilder {
|
||||
map.put("interestOnLoanAccountId", ID);
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
map.put("incomeFromRecoveryAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
|
||||
+115
-9
@@ -38,6 +38,8 @@ public class RecurringDepositAccountHelper {
|
||||
private static final String CALCULATE_PREMATURE_AMOUNT_COMMAND = "calculatePrematureAmount";
|
||||
private static final String PREMATURE_CLOSE_COMMAND = "prematureClose";
|
||||
private static final String DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND = "deposit";
|
||||
private static final String MODIFY_TRANSACTION_COMMAND = "modify";
|
||||
private static final String UNDO_TRANSACTION_COMMAND = "undo";
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "4";
|
||||
@@ -50,15 +52,20 @@ public class RecurringDepositAccountHelper {
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String BI_ANNUALLY = "6";
|
||||
private static final String ANNUALLY = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
private static final String DAYS_360 = "360";
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String ACCRUAL_PERIODIC = "3";
|
||||
private static final String ACCRUAL_UPFRONT = "4";
|
||||
|
||||
private final String interestCompoundingPeriodType = MONTHLY;
|
||||
private final String interestPostingPeriodType = MONTHLY;
|
||||
private final String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private String interestCompoundingPeriodType = MONTHLY;
|
||||
private String interestPostingPeriodType = MONTHLY;
|
||||
private String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private final String lockinPeriodFrequency = "6";
|
||||
private final String lockingPeriodFrequencyType = MONTHS;
|
||||
private final String minDepositTerm = "6";
|
||||
@@ -71,7 +78,7 @@ public class RecurringDepositAccountHelper {
|
||||
private final boolean preClosurePenalApplicable = true;
|
||||
private final boolean isActiveChart = true;
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private String interestCalculationDaysInYearType = DAYS_365;
|
||||
private final String depositAmount = "2000";
|
||||
private final String depositPeriod = "14";
|
||||
private final String depositPeriodFrequencyId = MONTHS;
|
||||
@@ -188,8 +195,9 @@ public class RecurringDepositAccountHelper {
|
||||
return response;
|
||||
}
|
||||
|
||||
public static Float getInterestRate(ArrayList<ArrayList<HashMap>> interestSlabData, Integer depositPeriod, Float annualInterestRate) {
|
||||
public static Float getInterestRate(ArrayList<ArrayList<HashMap>> interestSlabData, Integer depositPeriod) {
|
||||
|
||||
Float annualInterestRate = 0.0f;
|
||||
for (Integer slabIndex = 0; slabIndex < interestSlabData.get(0).size(); slabIndex++) {
|
||||
Integer fromPeriod = (Integer) interestSlabData.get(0).get(slabIndex).get("fromPeriod");
|
||||
Integer toPeriod = (Integer) interestSlabData.get(0).get(slabIndex).get("toPeriod");
|
||||
@@ -202,6 +210,38 @@ public class RecurringDepositAccountHelper {
|
||||
return annualInterestRate;
|
||||
}
|
||||
|
||||
public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Float depositAmount, Integer depositPeriod,
|
||||
double interestPerDay, Integer compoundingInterval, Integer postingInterval) {
|
||||
|
||||
Float totalInterest = 0.0f;
|
||||
Float interestEarned = 0.0f;
|
||||
|
||||
for (int i = 1; i <= depositPeriod; i++) {
|
||||
Integer daysInMonth = currentDate.getActualMaximum(Calendar.DATE);
|
||||
principal += depositAmount;
|
||||
for (int j = 0; j < daysInMonth; j++) {
|
||||
|
||||
interestEarned = (float) (principal * interestPerDay);
|
||||
totalInterest += interestEarned;
|
||||
if (compoundingInterval == 0) {
|
||||
principal += interestEarned;
|
||||
}
|
||||
|
||||
}
|
||||
if ((i % postingInterval) == 0 || i == depositPeriod) {
|
||||
if (compoundingInterval != 0) {
|
||||
principal += totalInterest;
|
||||
}
|
||||
totalInterest = 0.0f;
|
||||
System.out.println(principal);
|
||||
|
||||
}
|
||||
currentDate.add(Calendar.MONTH, 1);
|
||||
interestEarned = 0.0f;
|
||||
}
|
||||
return principal;
|
||||
}
|
||||
|
||||
public HashMap updateRecurringDepositAccount(final String clientID, final String productID, final String accountID,
|
||||
final String validFrom, final String validTo, final String penalInterestType, final String submittedOnDate) {
|
||||
|
||||
@@ -219,6 +259,40 @@ public class RecurringDepositAccountHelper {
|
||||
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public HashMap updateInterestCalculationConfigForRecurringDeposit(final String clientID, final String productID,
|
||||
final String accountID, final String submittedOnDate, final String validFrom, final String validTo,
|
||||
final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType,
|
||||
final String interestCompoundingPeriodType, final String interestPostingPeriodType, final String expectedFirstDepositOnDate) {
|
||||
|
||||
final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) //
|
||||
.withSubmittedOnDate(submittedOnDate) //
|
||||
.withNumberOfDaysPerYear(numberOfDaysPerYear) //
|
||||
.withInterestCalculationPeriodType(interestCalculationType) //
|
||||
.withInterestCompoundingPeriodType(interestCompoundingPeriodType) //
|
||||
.withInterestPostingPeriodType(interestPostingPeriodType) //
|
||||
.withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) //
|
||||
.build(clientID, productID, validFrom, validTo, penalInterestType);
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate,
|
||||
final Float transactionAmount) {
|
||||
System.out.println("--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------");
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID
|
||||
+ "/transactions/" + transactionId + "?command=" + MODIFY_TRANSACTION_COMMAND,
|
||||
getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate,
|
||||
final Float transactionAmount) {
|
||||
System.out.println("--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------");
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID
|
||||
+ "/transactions/" + transactionId + "?command=" + UNDO_TRANSACTION_COMMAND,
|
||||
getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public HashMap approveRecurringDeposit(final Integer recurringDepositAccountID, final String approvedOnDate) {
|
||||
System.out
|
||||
.println("--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------");
|
||||
@@ -278,11 +352,12 @@ public class RecurringDepositAccountHelper {
|
||||
getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final String depositedOnDate) {
|
||||
public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final Float depositAmount,
|
||||
final String depositedOnDate) {
|
||||
System.out.println("--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------");
|
||||
return (Integer) performRecurringDepositActions(
|
||||
createDepositToRecurringDepositURL(DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId),
|
||||
getDepositToRecurringDepositAccountAsJSON(depositedOnDate), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
getDepositToRecurringDepositAccountAsJSON(depositAmount, depositedOnDate), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate) {
|
||||
@@ -311,6 +386,17 @@ public class RecurringDepositAccountHelper {
|
||||
return recurringDepositAccountApproveJson;
|
||||
}
|
||||
|
||||
private String getUpdateTransactionAsJSON(final String transactionDate, final Float transactionAmount) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionDate", transactionDate);
|
||||
map.put("transactionAmount", transactionAmount);
|
||||
String updateTransactionJson = new Gson().toJson(map);
|
||||
System.out.println(updateTransactionJson);
|
||||
return updateTransactionJson;
|
||||
}
|
||||
|
||||
private String getRejectedRecurringDepositAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
@@ -360,11 +446,11 @@ public class RecurringDepositAccountHelper {
|
||||
return recurringDepositAccountPrematureClosureJson;
|
||||
}
|
||||
|
||||
private String getDepositToRecurringDepositAccountAsJSON(final String depositedOnDate) {
|
||||
private String getDepositToRecurringDepositAccountAsJSON(final Float depositAmount, final String depositedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionAmount", this.recurringDepositAmount);
|
||||
map.put("transactionAmount", depositAmount);
|
||||
map.put("transactionDate", depositedOnDate);
|
||||
String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountPrematureClosureJson);
|
||||
@@ -426,4 +512,24 @@ public class RecurringDepositAccountHelper {
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecurringDepositAccountHelper withNumberOfDaysPerYear(final String numberOfDaysPerYearTypeId) {
|
||||
this.interestCalculationDaysInYearType = numberOfDaysPerYearTypeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecurringDepositAccountHelper withInterestCalculationPeriodType(final String interestCalculationTypeId) {
|
||||
this.interestCalculationType = interestCalculationTypeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecurringDepositAccountHelper withInterestCompoundingPeriodType(final String interestCompoundingPeriodTypeId) {
|
||||
this.interestCompoundingPeriodType = interestCompoundingPeriodTypeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecurringDepositAccountHelper withInterestPostingPeriodType(final String interestPostingPeriodTypeId) {
|
||||
this.interestPostingPeriodType = interestPostingPeriodTypeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+2
@@ -45,6 +45,8 @@ public class RecurringDepositProductHelper {
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String ACCRUAL_PERIODIC = "3";
|
||||
private static final String ACCRUAL_UPFRONT = "4";
|
||||
private static final String WHOLE_TERM = "1";
|
||||
private static final String TILL_PREMATURE_WITHDRAWAL = "2";
|
||||
private static final String VOLUNTARY = "1";
|
||||
|
||||
+5
-3
@@ -182,9 +182,11 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES.getValue());
|
||||
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST.getValue());
|
||||
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST.getValue());
|
||||
}
|
||||
|
||||
// expenses
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
||||
|
||||
Reference in New Issue
Block a user