MIFOSX-2426 : added support for Interest Rate Charts based on Amount
Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/37dfe1a0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/37dfe1a0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/37dfe1a0 Branch: refs/heads/develop Commit: 37dfe1a0bf1fc65d829cc48b57a69fea616cc093 Parents: 14499a2 Author: pramod <[email protected]> Authored: Fri Mar 4 15:57:27 2016 +0530 Committer: pramod <[email protected]> Committed: Fri Mar 4 15:57:27 2016 +0530 ---------------------------------------------------------------------- .../AccountingScenarioIntegrationTest.java | 6 +- .../integrationtests/FixedDepositTest.java | 331 +++++++++++++++---- .../integrationtests/RecurringDepositTest.java | 206 +++++++++++- .../SchedulerJobsTestResults.java | 3 +- .../fixeddeposit/FixedDepositAccountHelper.java | 85 ++--- .../fixeddeposit/FixedDepositProductHelper.java | 264 ++++++++++++--- .../RecurringDepositAccountHelper.java | 74 +---- .../RecurringDepositProductHelper.java | 262 ++++++++++++--- .../portfolio/calendar/domain/Calendar.java | 11 +- .../InterestRateChartApiConstants.java | 10 +- .../data/InterestRateChartData.java | 65 ++-- .../data/InterestRateChartDataValidator.java | 21 +- .../InterestRateChartSlabDataValidator.java | 69 ++-- .../domain/InterestRateChart.java | 83 ++++- .../domain/InterestRateChartFields.java | 34 +- .../domain/InterestRateChartSlabComparator.java | 92 ++++++ .../domain/InterestRateChartSlabFields.java | 148 ++++++++- .../service/InterestRateChartAssembler.java | 30 +- ...nterestRateChartReadPlatformServiceImpl.java | 27 +- .../DepositAccountInterestRateChartData.java | 67 ++-- .../domain/DepositAccountDomainServiceJpa.java | 60 +++- .../domain/DepositAccountInterestRateChart.java | 5 + .../savings/domain/DepositProductAssembler.java | 28 +- .../savings/domain/FixedDepositProduct.java | 2 +- .../savings/domain/RecurringDepositAccount.java | 34 +- ...nterestRateChartReadPlatformServiceImpl.java | 40 ++- ..._interest_rate_chart_support_for_amounts.sql | 13 + 27 files changed, 1642 insertions(+), 428 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java index ef020bc..0e40d74 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java @@ -521,6 +521,7 @@ public class AccountingScenarioIntegrationTest { System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); final String fixedDepositProductJSON = fixedDepositProductHelper // + .withPeriodRangeChart()// .withAccountingRuleAsCashBased(accounts).build(validFrom, validTo); return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); } @@ -529,7 +530,7 @@ public class AccountingScenarioIntegrationTest { 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); + .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); return this.fixedDepositAccountHelper .applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); } @@ -538,6 +539,7 @@ public class AccountingScenarioIntegrationTest { System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); final String recurringDepositProductJSON = recurringDepositProductHelper // + .withPeriodRangeChart()// .withAccountingRuleAsCashBased(accounts).build(validFrom, validTo); return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec); } @@ -548,7 +550,7 @@ public class AccountingScenarioIntegrationTest { final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) - .build(clientID, productID, validFrom, validTo, penalInterestType); + .build(clientID, productID, penalInterestType); return this.recurringDepositAccountHelper.applyRecurringDepositApplication(recurringDepositApplicationJSON, this.requestSpec, this.responseSpec); } http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java index 3d6a4ef..fa638bc 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java @@ -114,8 +114,8 @@ public class FixedDepositTest { } /*** - * Test case for Fixed Deposit Account premature closure with - * transaction type withdrawal and Cash Based accounting enabled + * Test case for Fixed Deposit Account premature closure with transaction + * type withdrawal and Cash Based accounting enabled */ @Test public void testFixedDepositAccountWithPrematureClosureTypeWithdrawal() { @@ -123,7 +123,7 @@ public class FixedDepositTest { this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec); - + /*** * Create GL Accounts for product account mapping */ @@ -170,8 +170,8 @@ public class FixedDepositTest { /*** * Apply for FD account with created product and verify status */ - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -189,11 +189,11 @@ public class FixedDepositTest { */ fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE); FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); - + HashMap accountSummary = this.fixedDepositAccountHelper.getFixedDepositSummary(fixedDepositAccountId); Float depositAmount = (Float) accountSummary.get("totalDeposits"); - + /*** * Verify journal entries posted for initial deposit transaction which * happened at activation time @@ -214,7 +214,7 @@ public class FixedDepositTest { */ Integer transactionIdForPostInterest = this.fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId); Assert.assertNotNull(transactionIdForPostInterest); - + accountSummary = this.fixedDepositAccountHelper.getFixedDepositSummary(fixedDepositAccountId); Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted"); @@ -252,6 +252,165 @@ public class FixedDepositTest { JournalEntry.TransactionType.DEBIT)); } + + @Test + public void testFixedDepositAccountWithPeriodInterestRateChart() { + final String chartToUse = "period"; + final String depositAmount = "10000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithPeriodInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "period"; + final String depositAmount = "2000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithPeriodInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "period"; + final String depositAmount = "10000"; + final String depositPeriod = "18"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithAmountInterestRateChart() { + final String chartToUse = "amount"; + final String depositAmount = "10000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithAmountInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "amount"; + final String depositAmount = "5000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(5.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithAmountInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "amount"; + final String depositAmount = "10000"; + final String depositPeriod = "26"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart() { + final String chartToUse = "period_amount"; + final String depositAmount = "10000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "period_amount"; + final String depositAmount = "5000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithPeriodAndAmountInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "period_amount"; + final String depositAmount = "10000"; + final String depositPeriod = "20"; + final Float interestRate = new Float(9.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart() { + final String chartToUse = "amount_period"; + final String depositAmount = "10000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(8.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "amount_period"; + final String depositAmount = "5000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testFixedDepositAccountWithAmountAndPeriodInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "amount_period"; + final String depositAmount = "10000"; + final String depositPeriod = "6"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + private void testFixedDepositAccountForInterestRate(final String chartToUse, final String depositAmount, final String depositPeriod, + final Float interestRate) { + this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec); + + final String VALID_FROM = "01 March 2014"; + final String VALID_TO = "01 March 2016"; + + final String SUBMITTED_ON_DATE = "01 March 2015"; + final String APPROVED_ON_DATE = "01 March 2015"; + final String ACTIVATION_DATE = "01 March 2015"; + + Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientId); + + /*** + * Create FD product with CashBased accounting enabled + */ + final String accountingRule = NONE; + Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule, chartToUse); + Assert.assertNotNull(fixedDepositProductId); + + /*** + * Apply for FD account with created product and verify status + */ + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM, depositAmount, depositPeriod); + Assert.assertNotNull(fixedDepositAccountId); + + HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, + this.responseSpec, fixedDepositAccountId.toString()); + FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap); + + /*** + * Approve the FD account and verify whether account is approved + */ + fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE); + FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap); + + /*** + * Activate the FD Account and verify whether account is activated + */ + fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE); + FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); + + HashMap accountSummary = this.fixedDepositAccountHelper.getFixedDepositDetails(fixedDepositAccountId); + + Assert.assertEquals(interestRate, accountSummary.get("nominalAnnualInterestRate")); + } /*** * Test case for FD Account premature closure with transaction transfers to @@ -263,7 +422,7 @@ public class FixedDepositTest { this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec); - + /*** * Create GL Accounts for product account mapping */ @@ -295,7 +454,7 @@ public class FixedDepositTest { todaysDate.add(Calendar.DATE, numberOfDaysLeft); final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSED_ON_DATE = dateFormat.format(Calendar.getInstance().getTime()); - + Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); Assert.assertNotNull(clientId); @@ -326,8 +485,8 @@ public class FixedDepositTest { incomeAccount, expenseAccount); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -343,7 +502,7 @@ public class FixedDepositTest { HashMap accountSummary = this.fixedDepositAccountHelper.getFixedDepositSummary(fixedDepositAccountId); Float depositAmount = (Float) accountSummary.get("totalDeposits"); - + /*** * Verify journal entries posted for initial deposit transaction which * happened at activation time @@ -375,10 +534,10 @@ public class FixedDepositTest { 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); - + HashMap savingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); Float balanceBefore = (Float) savingsSummaryBefore.get("accountBalance"); - + /*** * Retrieve mapped financial account for liability transfer */ @@ -412,7 +571,7 @@ public class FixedDepositTest { this.journalEntryHelper.checkJournalEntryForAssetAccount(financialAccount, CLOSED_ON_DATE, new JournalEntry(prematurityAmount, JournalEntry.TransactionType.DEBIT), new JournalEntry(prematurityAmount, JournalEntry.TransactionType.CREDIT)); - + HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance"); Float expectedSavingsBalance = balanceBefore + prematurityAmount; @@ -422,8 +581,8 @@ public class FixedDepositTest { } /*** - * Test case for Fixed Deposit Account premature closure with - * transaction type ReInvest and Cash Based accounting enabled + * Test case for Fixed Deposit Account premature closure with transaction + * type ReInvest and Cash Based accounting enabled */ @Test public void testFixedDepositAccountWithPrematureClosureTypeReinvest() { @@ -459,7 +618,7 @@ public class FixedDepositTest { final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime()); - + Integer currentDate = new Integer(currentDateFormat.format(todaysDate.getTime())); Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); Integer numberOfDaysLeft = (daysInMonth - currentDate) + 1; @@ -478,8 +637,8 @@ public class FixedDepositTest { incomeAccount, expenseAccount); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -491,11 +650,11 @@ public class FixedDepositTest { fixedDepositAccountStatusHashMap = this.fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE); FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); - + HashMap accountSummary = this.fixedDepositAccountHelper.getFixedDepositSummary(fixedDepositAccountId); Float depositAmount = (Float) accountSummary.get("totalDeposits"); - + /*** * Verify journal entries posted for initial deposit transaction which * happened at activation time @@ -564,8 +723,8 @@ public class FixedDepositTest { HashMap fixedDepositProductData = this.fixedDepositProductHelper.retrieveFixedDepositProductById(this.requestSpec, this.responseSpec, fixedDepositProductId.toString()); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); todaysDate.add(Calendar.DATE, -1); @@ -603,8 +762,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -646,8 +805,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -687,8 +846,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -726,8 +885,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -769,8 +928,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -839,8 +998,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -916,8 +1075,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -1020,8 +1179,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1128,8 +1287,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, TILL_PREMATURE_WITHDRAWAL); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + TILL_PREMATURE_WITHDRAWAL); Assert.assertNotNull(fixedDepositAccountId); HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, @@ -1240,8 +1399,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, TILL_PREMATURE_WITHDRAWAL); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + TILL_PREMATURE_WITHDRAWAL); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1352,8 +1511,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1421,7 +1580,7 @@ public class FixedDepositTest { final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime()); - System.out.println("Submitted Date:"+SUBMITTED_ON_DATE); + System.out.println("Submitted Date:" + SUBMITTED_ON_DATE); Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); Assert.assertNotNull(clientId); @@ -1429,8 +1588,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1509,8 +1668,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1593,8 +1752,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1678,8 +1837,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1760,8 +1919,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1842,8 +2001,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1923,8 +2082,8 @@ public class FixedDepositTest { Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule); Assert.assertNotNull(fixedDepositProductId); - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM); + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), SUBMITTED_ON_DATE, + WHOLE_TERM); Assert.assertNotNull(fixedDepositAccountId); HashMap modificationsHashMap = this.fixedDepositAccountHelper.updateInterestCalculationConfigForFixedDeposit(clientId.toString(), @@ -1975,16 +2134,58 @@ public class FixedDepositTest { } else if (accountingRule.equals(NONE)) { fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsNone(); } + final String fixedDepositProductJSON = fixedDepositProductHelper.withPeriodRangeChart() // + .build(validFrom, validTo); + return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); + } + + private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule, + final String chartToBePicked, Account... accounts) { + System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); + FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); + if (accountingRule.equals(CASH_BASED)) { + fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); + } else if (accountingRule.equals(NONE)) { + fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsNone(); + } + switch (chartToBePicked) { + case "period": + fixedDepositProductHelper = fixedDepositProductHelper.withPeriodRangeChart(); + break; + case "amount": + fixedDepositProductHelper = fixedDepositProductHelper.withAmountRangeChart(); + break; + case "period_amount": + fixedDepositProductHelper = fixedDepositProductHelper.withPeriodAndAmountRangeChart(); + break; + case "amount_period": + fixedDepositProductHelper = fixedDepositProductHelper.withAmountAndPeriodRangeChart(); + break; + default: + break; + } + final String fixedDepositProductJSON = fixedDepositProductHelper // .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) { + private Integer applyForFixedDepositApplication(final String clientID, final String productID, 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); + .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); + return this.fixedDepositAccountHelper + .applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); + } + + private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, + final String penalInterestType, final String depositAmount, final String depositPeriod) { + System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); + final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) + // + .withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount) + .build(clientID, productID, penalInterestType); return this.fixedDepositAccountHelper .applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); } http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java index b9fd152..1d52aec 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java @@ -2496,6 +2496,169 @@ public class RecurringDepositTest { } + @Test + public void testRecurringDepositAccountWithPeriodInterestRateChart() { + final String chartToUse = "period"; + final String depositAmount = "1000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithPeriodInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "period"; + final String depositAmount = "10000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithPeriodInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "period"; + final String depositAmount = "1000"; + final String depositPeriod = "18"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithAmountInterestRateChart() { + final String chartToUse = "amount"; + final String depositAmount = "1000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(8.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithAmountInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "amount"; + final String depositAmount = "500"; + final String depositPeriod = "12"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithAmountInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "amount"; + final String depositAmount = "500"; + final String depositPeriod = "10"; + final Float interestRate = new Float(5.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart() { + final String chartToUse = "period_amount"; + final String depositAmount = "1000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "period_amount"; + final String depositAmount = "400"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithPeriodAndAmountInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "period_amount"; + final String depositAmount = "1000"; + final String depositPeriod = "14"; + final Float interestRate = new Float(8.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart() { + final String chartToUse = "amount_period"; + final String depositAmount = "1000"; + final String depositPeriod = "12"; + final Float interestRate = new Float(8.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart_AMOUNT_VARIATION() { + final String chartToUse = "amount_period"; + final String depositAmount = "100"; + final String depositPeriod = "12"; + final Float interestRate = new Float(6.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + @Test + public void testRecurringDepositAccountWithAmountAndPeriodInterestRateChart_PERIOD_VARIATION() { + final String chartToUse = "amount_period"; + final String depositAmount = "1000"; + final String depositPeriod = "6"; + final Float interestRate = new Float(7.0); + testFixedDepositAccountForInterestRate(chartToUse, depositAmount, depositPeriod, interestRate); + } + + private void testFixedDepositAccountForInterestRate(final String chartToUse, final String depositAmount, final String depositPeriod, + final Float interestRate) { + this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); + this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec); + + final String VALID_FROM = "01 March 2014"; + final String VALID_TO = "01 March 2016"; + + final String SUBMITTED_ON_DATE = "01 March 2015"; + final String APPROVED_ON_DATE = "01 March 2015"; + final String ACTIVATION_DATE = "01 March 2015"; + + Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientId); + + /*** + * Create FD product with CashBased accounting enabled + */ + final String accountingRule = NONE; + Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO, accountingRule, chartToUse); + Assert.assertNotNull(recurringDepositProductId); + + /*** + * Apply for FD account with created product and verify status + */ + Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(), + VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, SUBMITTED_ON_DATE, depositAmount, depositPeriod); + Assert.assertNotNull(recurringDepositAccountId); + + HashMap recurringDepositAccountStatusHashMap = RecurringDepositAccountStatusChecker.getStatusOfRecurringDepositAccount( + this.requestSpec, this.responseSpec, recurringDepositAccountId.toString()); + RecurringDepositAccountStatusChecker.verifyRecurringDepositIsPending(recurringDepositAccountStatusHashMap); + + /*** + * Approve the RD account and verify whether account is approved + */ + recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.approveRecurringDeposit(recurringDepositAccountId, + APPROVED_ON_DATE); + RecurringDepositAccountStatusChecker.verifyRecurringDepositIsApproved(recurringDepositAccountStatusHashMap); + + /*** + * Activate the RD Account and verify whether account is activated + */ + recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId, + ACTIVATION_DATE); + RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap); + + HashMap recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, + this.responseSpec, recurringDepositAccountId); + + Assert.assertEquals(interestRate, recurringDepositAccountData.get("nominalAnnualInterestRate")); + } + private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, Account... accounts) { System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); @@ -2505,6 +2668,36 @@ public class RecurringDepositTest { } else if (accountingRule.equals(NONE)) { recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsNone(); } + final String recurringDepositProductJSON = recurringDepositProductHelper.withPeriodRangeChart().build(validFrom, validTo); + return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec); + } + + private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, + final String chartToBePicked, Account... accounts) { + System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); + RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); + if (accountingRule.equals(CASH_BASED)) { + recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); + } else if (accountingRule.equals(NONE)) { + recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsNone(); + } + + switch (chartToBePicked) { + case "period": + recurringDepositProductHelper = recurringDepositProductHelper.withPeriodRangeChart(); + break; + case "amount": + recurringDepositProductHelper = recurringDepositProductHelper.withAmountRangeChart(); + break; + case "period_amount": + recurringDepositProductHelper = recurringDepositProductHelper.withPeriodAndAmountRangeChart(); + break; + case "amount_period": + recurringDepositProductHelper = recurringDepositProductHelper.withAmountAndPeriodRangeChart(); + break; + default: + break; + } final String recurringDepositProductJSON = recurringDepositProductHelper.build(validFrom, validTo); return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec); } @@ -2514,7 +2707,18 @@ public class RecurringDepositTest { 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); + .build(clientID, productID, penalInterestType); + return this.recurringDepositAccountHelper.applyRecurringDepositApplication(recurringDepositApplicationJSON, this.requestSpec, + this.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, + final String depositAmount, final String depositPeriod) { + System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); + final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) + .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) + .withDepositPeriod(depositPeriod).withMandatoryDepositAmount(depositAmount).build(clientID, productID, penalInterestType); return this.recurringDepositAccountHelper.applyRecurringDepositApplication(recurringDepositApplicationJSON, this.requestSpec, this.responseSpec); } http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java index 985889a..cc6b3c8 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java @@ -892,6 +892,7 @@ public class SchedulerJobsTestResults { FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); final String fixedDepositProductJSON = fixedDepositProductHelper // // .withAccountingRuleAsCashBased(accounts) + .withPeriodRangeChart()// .build(validFrom, validTo); return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); } @@ -904,7 +905,7 @@ public class SchedulerJobsTestResults { // .withSubmittedOnDate(submittedOnDate).withSavings(savingsId).transferInterest(true) .withLockinPeriodFrequency("1", FixedDepositAccountHelper.DAYS) - .build(clientID, productID, validFrom, validTo, penalInterestType); + .build(clientID, productID, penalInterestType); return fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); } http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java index fa48717..64bd4c8 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java @@ -72,6 +72,7 @@ public class FixedDepositAccountHelper { private static final String DAYS_360 = "360"; private static final String DAYS_365 = "365"; public final static String depositAmount = "100000"; + private String newDepositAmount = null; private String interestCompoundingPeriodType = MONTHLY; private String interestPostingPeriodType = MONTHLY; @@ -90,64 +91,15 @@ public class FixedDepositAccountHelper { private final boolean isActiveChart = true; private final String currencyCode = USD; - private final String depositPeriod = "14"; + private String depositPeriod = "14"; private final String depositPeriodFrequencyId = MONTHS; private String submittedOnDate = ""; private String savingsId = null; private boolean transferInterest = false; - public String build(final String clientId, final String productId, final String validFrom, final String validTo, - final String penalInterestType) { + public String build(final String clientId, final String productId, final String penalInterestType) { final HashMap<String, Object> map = new HashMap<>(); - List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); - HashMap<String, String> chartSlabsMap1 = new HashMap<>(); - chartSlabsMap1.put("description", "First"); - chartSlabsMap1.put("periodType", MONTHS); - chartSlabsMap1.put("fromPeriod", "1"); - chartSlabsMap1.put("toPeriod", "6"); - chartSlabsMap1.put("annualInterestRate", "5"); - chartSlabsMap1.put("locale", LOCALE); - chartSlabs.add(0, chartSlabsMap1); - - HashMap<String, String> chartSlabsMap2 = new HashMap<>(); - chartSlabsMap2.put("description", "Second"); - chartSlabsMap2.put("periodType", MONTHS); - chartSlabsMap2.put("fromPeriod", "7"); - chartSlabsMap2.put("toPeriod", "12"); - chartSlabsMap2.put("annualInterestRate", "6"); - chartSlabsMap2.put("locale", LOCALE); - chartSlabs.add(1, chartSlabsMap2); - - HashMap<String, String> chartSlabsMap3 = new HashMap<>(); - chartSlabsMap3.put("description", "Third"); - chartSlabsMap3.put("periodType", MONTHS); - chartSlabsMap3.put("fromPeriod", "13"); - chartSlabsMap3.put("toPeriod", "18"); - chartSlabsMap3.put("annualInterestRate", "7"); - chartSlabsMap3.put("locale", LOCALE); - chartSlabs.add(2, chartSlabsMap3); - - HashMap<String, String> chartSlabsMap4 = new HashMap<>(); - chartSlabsMap4.put("description", "Fourth"); - chartSlabsMap4.put("periodType", MONTHS); - chartSlabsMap4.put("fromPeriod", "19"); - chartSlabsMap4.put("toPeriod", "24"); - chartSlabsMap4.put("annualInterestRate", "8"); - chartSlabsMap4.put("locale", LOCALE); - chartSlabs.add(3, chartSlabsMap4); - - List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>(); - HashMap<String, Object> chartsMap = new HashMap<>(); - chartsMap.put("fromDate", validFrom); - chartsMap.put("endDate", validTo); - chartsMap.put("dateFormat", "dd MMMM yyyy"); - chartsMap.put("locale", LOCALE); - chartsMap.put("isActiveChart", this.isActiveChart); - chartsMap.put("chartSlabs", chartSlabs); - charts.add(chartsMap); - - map.put("charts", charts); map.put("productId", productId); map.put("clientId", clientId); map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType); @@ -169,7 +121,7 @@ public class FixedDepositAccountHelper { map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId); map.put("preClosurePenalInterest", this.preClosurePenalInterest); map.put("preClosurePenalInterestOnTypeId", penalInterestType); - map.put("depositAmount", depositAmount); + map.put("depositAmount", getDepositAmount()); map.put("depositPeriod", this.depositPeriod); map.put("depositPeriodFrequencyId", this.depositPeriodFrequencyId); map.put("submittedOnDate", this.submittedOnDate); @@ -196,8 +148,16 @@ public class FixedDepositAccountHelper { } public HashMap getFixedDepositSummary(final Integer accountID) { + return getFixedDepositDetails(accountID, "summary"); + } + + public HashMap getFixedDepositDetails(final Integer accountID) { + return getFixedDepositDetails(accountID, ""); + } + + private HashMap getFixedDepositDetails(final Integer accountID, final String jsonAttributeToGetBack) { final String URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER; - final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary"); + final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack); return response; } @@ -251,7 +211,7 @@ public class FixedDepositAccountHelper { final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate) // - .build(clientID, productID, validFrom, validTo, penalInterestType); + .build(clientID, productID, penalInterestType); return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); @@ -268,7 +228,7 @@ public class FixedDepositAccountHelper { .withInterestCalculationPeriodType(interestCalculationType) // .withInterestCompoundingPeriodType(interestCompoundingPeriodType) // .withInterestPostingPeriodType(interestPostingPeriodType) // - .build(clientID, productID, validFrom, validTo, penalInterestType); + .build(clientID, productID, penalInterestType); return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); @@ -487,4 +447,19 @@ public class FixedDepositAccountHelper { this.lockinPeriodFrequency = lockinPeriodFrequency; return this; } + + public FixedDepositAccountHelper withDepositPeriod(final String depositPeriod) { + this.depositPeriod = depositPeriod; + return this; + } + + public FixedDepositAccountHelper withDepositAmount(final String depositAmount) { + this.newDepositAmount = depositAmount; + return this; + } + + private String getDepositAmount() { + if (this.newDepositAmount == null) { return depositAmount; } + return this.newDepositAmount; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java index 2703340..b20b6f9 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java @@ -97,54 +97,20 @@ public class FixedDepositProductHelper { private final String currencyCode = USD; private final String interestCalculationDaysInYearType = DAYS_365; private Account[] accountList = null; + private List<HashMap<String, String>> chartSlabs = null; + private boolean isPrimaryGroupingByAmount = false; public String build(final String validFrom, final String validTo) { final HashMap<String, Object> map = new HashMap<>(); - List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); - HashMap<String, String> chartSlabsMap1 = new HashMap<>(); - chartSlabsMap1.put("description", "First"); - chartSlabsMap1.put("periodType", MONTHS); - chartSlabsMap1.put("fromPeriod", "1"); - chartSlabsMap1.put("toPeriod", "6"); - chartSlabsMap1.put("annualInterestRate", "5"); - chartSlabsMap1.put("locale", LOCALE); - chartSlabs.add(0, chartSlabsMap1); - - HashMap<String, String> chartSlabsMap2 = new HashMap<>(); - chartSlabsMap2.put("description", "Second"); - chartSlabsMap2.put("periodType", MONTHS); - chartSlabsMap2.put("fromPeriod", "7"); - chartSlabsMap2.put("toPeriod", "12"); - chartSlabsMap2.put("annualInterestRate", "6"); - chartSlabsMap2.put("locale", LOCALE); - chartSlabs.add(1, chartSlabsMap2); - - HashMap<String, String> chartSlabsMap3 = new HashMap<>(); - chartSlabsMap3.put("description", "Third"); - chartSlabsMap3.put("periodType", MONTHS); - chartSlabsMap3.put("fromPeriod", "13"); - chartSlabsMap3.put("toPeriod", "18"); - chartSlabsMap3.put("annualInterestRate", "7"); - chartSlabsMap3.put("locale", LOCALE); - chartSlabs.add(2, chartSlabsMap3); - - HashMap<String, String> chartSlabsMap4 = new HashMap<>(); - chartSlabsMap4.put("description", "Fourth"); - chartSlabsMap4.put("periodType", MONTHS); - chartSlabsMap4.put("fromPeriod", "19"); - chartSlabsMap4.put("toPeriod", "24"); - chartSlabsMap4.put("annualInterestRate", "8"); - chartSlabsMap4.put("locale", LOCALE); - chartSlabs.add(3, chartSlabsMap4); - List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> chartsMap = new HashMap<>(); chartsMap.put("fromDate", validFrom); chartsMap.put("endDate", validTo); chartsMap.put("dateFormat", "dd MMMM yyyy"); chartsMap.put("locale", LOCALE); - chartsMap.put("chartSlabs", chartSlabs); + chartsMap.put("chartSlabs", this.chartSlabs); + chartsMap.put("isPrimaryGroupingByAmount", this.isPrimaryGroupingByAmount); charts.add(chartsMap); map.put("charts", charts); @@ -173,6 +139,7 @@ public class FixedDepositProductHelper { map.put("inMultiplesOfDepositTermTypeId", this.inMultiplesOfDepositTermTypeId); map.put("preClosurePenalInterest", this.preClosurePenalInterest); map.put("preClosurePenalInterestOnTypeId", this.preClosurePenalInterestOnTypeId); + if (this.accountingRule.equals(CASH_BASED)) { map.putAll(getAccountMappingForCashBased()); @@ -183,6 +150,207 @@ public class FixedDepositProductHelper { return FixedDepositProductCreateJson; } + public List<HashMap<String, String>> constructChartSlabWithPeriodRange() { + List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); + HashMap<String, String> chartSlabsMap1 = new HashMap<>(); + chartSlabsMap1.put("description", "First"); + chartSlabsMap1.put("periodType", MONTHS); + chartSlabsMap1.put("fromPeriod", "1"); + chartSlabsMap1.put("toPeriod", "6"); + chartSlabsMap1.put("annualInterestRate", "5"); + chartSlabsMap1.put("locale", LOCALE); + chartSlabs.add(0, chartSlabsMap1); + + HashMap<String, String> chartSlabsMap2 = new HashMap<>(); + chartSlabsMap2.put("description", "Second"); + chartSlabsMap2.put("periodType", MONTHS); + chartSlabsMap2.put("fromPeriod", "7"); + chartSlabsMap2.put("toPeriod", "12"); + chartSlabsMap2.put("annualInterestRate", "6"); + chartSlabsMap2.put("locale", LOCALE); + chartSlabs.add(1, chartSlabsMap2); + + HashMap<String, String> chartSlabsMap3 = new HashMap<>(); + chartSlabsMap3.put("description", "Third"); + chartSlabsMap3.put("periodType", MONTHS); + chartSlabsMap3.put("fromPeriod", "13"); + chartSlabsMap3.put("toPeriod", "18"); + chartSlabsMap3.put("annualInterestRate", "7"); + chartSlabsMap3.put("locale", LOCALE); + chartSlabs.add(2, chartSlabsMap3); + + HashMap<String, String> chartSlabsMap4 = new HashMap<>(); + chartSlabsMap4.put("description", "Fourth"); + chartSlabsMap4.put("periodType", MONTHS); + chartSlabsMap4.put("fromPeriod", "19"); + chartSlabsMap4.put("annualInterestRate", "8"); + chartSlabsMap4.put("locale", LOCALE); + chartSlabs.add(3, chartSlabsMap4); + return chartSlabs; + } + + public List<HashMap<String, String>> constructChartSlabWithPeriodAndAmountRange() { + List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); + HashMap<String, String> chartSlabsMap1 = new HashMap<>(); + chartSlabsMap1.put("description", "First"); + chartSlabsMap1.put("periodType", MONTHS); + chartSlabsMap1.put("fromPeriod", "1"); + chartSlabsMap1.put("toPeriod", "6"); + chartSlabsMap1.put("amountRangeFrom", "1"); + chartSlabsMap1.put("amountRangeTo", "5000"); + chartSlabsMap1.put("annualInterestRate", "5"); + chartSlabsMap1.put("locale", LOCALE); + chartSlabs.add(0, chartSlabsMap1); + + HashMap<String, String> chartSlabsMap1_1 = new HashMap<>(); + chartSlabsMap1_1.put("description", "First"); + chartSlabsMap1_1.put("periodType", MONTHS); + chartSlabsMap1_1.put("fromPeriod", "1"); + chartSlabsMap1_1.put("toPeriod", "6"); + chartSlabsMap1_1.put("amountRangeFrom", "5001"); + chartSlabsMap1_1.put("annualInterestRate", "6"); + chartSlabsMap1_1.put("locale", LOCALE); + chartSlabs.add(0, chartSlabsMap1_1); + + HashMap<String, String> chartSlabsMap2 = new HashMap<>(); + chartSlabsMap2.put("description", "Second"); + chartSlabsMap2.put("periodType", MONTHS); + chartSlabsMap2.put("fromPeriod", "7"); + chartSlabsMap2.put("toPeriod", "12"); + chartSlabsMap2.put("amountRangeFrom", "1"); + chartSlabsMap2.put("amountRangeTo", "5000"); + chartSlabsMap2.put("annualInterestRate", "6"); + chartSlabsMap2.put("locale", LOCALE); + chartSlabs.add(1, chartSlabsMap2); + + HashMap<String, String> chartSlabsMap2_2 = new HashMap<>(); + chartSlabsMap2_2.put("description", "Second"); + chartSlabsMap2_2.put("periodType", MONTHS); + chartSlabsMap2_2.put("fromPeriod", "7"); + chartSlabsMap2_2.put("toPeriod", "12"); + chartSlabsMap2_2.put("amountRangeFrom", "5001"); + chartSlabsMap2_2.put("annualInterestRate", "7"); + chartSlabsMap2_2.put("locale", LOCALE); + chartSlabs.add(1, chartSlabsMap2_2); + + HashMap<String, String> chartSlabsMap3 = new HashMap<>(); + chartSlabsMap3.put("description", "Third"); + chartSlabsMap3.put("periodType", MONTHS); + chartSlabsMap3.put("fromPeriod", "13"); + chartSlabsMap3.put("toPeriod", "18"); + chartSlabsMap3.put("amountRangeFrom", "1"); + chartSlabsMap3.put("amountRangeTo", "5000"); + chartSlabsMap3.put("annualInterestRate", "7"); + chartSlabsMap3.put("locale", LOCALE); + chartSlabs.add(2, chartSlabsMap3); + + HashMap<String, String> chartSlabsMap3_1 = new HashMap<>(); + chartSlabsMap3_1.put("description", "Third"); + chartSlabsMap3_1.put("periodType", MONTHS); + chartSlabsMap3_1.put("fromPeriod", "13"); + chartSlabsMap3_1.put("toPeriod", "18"); + chartSlabsMap3_1.put("amountRangeFrom", "5001"); + chartSlabsMap3_1.put("annualInterestRate", "8"); + chartSlabsMap3_1.put("locale", LOCALE); + chartSlabs.add(2, chartSlabsMap3_1); + + HashMap<String, String> chartSlabsMap4 = new HashMap<>(); + chartSlabsMap4.put("description", "Fourth"); + chartSlabsMap4.put("periodType", MONTHS); + chartSlabsMap4.put("fromPeriod", "19"); + chartSlabsMap4.put("amountRangeFrom", "1"); + chartSlabsMap4.put("amountRangeTo", "5000"); + chartSlabsMap4.put("annualInterestRate", "8"); + chartSlabsMap4.put("locale", LOCALE); + chartSlabs.add(3, chartSlabsMap4); + + HashMap<String, String> chartSlabsMap4_1 = new HashMap<>(); + chartSlabsMap4_1.put("description", "Fourth"); + chartSlabsMap4_1.put("periodType", MONTHS); + chartSlabsMap4_1.put("fromPeriod", "19"); + chartSlabsMap4_1.put("amountRangeFrom", "5001"); + chartSlabsMap4_1.put("annualInterestRate", "9"); + chartSlabsMap4_1.put("locale", LOCALE); + chartSlabs.add(3, chartSlabsMap4_1); + + return chartSlabs; + } + + public List<HashMap<String, String>> constructChartSlabWithAmountAndPeriodRange() { + this.isPrimaryGroupingByAmount = true; + List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); + HashMap<String, String> chartSlabsMap1 = new HashMap<>(); + chartSlabsMap1.put("description", "First"); + chartSlabsMap1.put("periodType", MONTHS); + chartSlabsMap1.put("amountRangeFrom", "1"); + chartSlabsMap1.put("amountRangeTo", "5000"); + chartSlabsMap1.put("fromPeriod", "1"); + chartSlabsMap1.put("toPeriod", "6"); + chartSlabsMap1.put("annualInterestRate", "5"); + chartSlabsMap1.put("locale", LOCALE); + chartSlabs.add(0, chartSlabsMap1); + + HashMap<String, String> chartSlabsMap2 = new HashMap<>(); + chartSlabsMap2.put("description", "Second"); + chartSlabsMap2.put("periodType", MONTHS); + chartSlabsMap2.put("fromPeriod", "7"); + chartSlabsMap2.put("amountRangeFrom", "1"); + chartSlabsMap2.put("amountRangeTo", "5000"); + chartSlabsMap2.put("annualInterestRate", "6"); + chartSlabsMap2.put("locale", LOCALE); + chartSlabs.add(1, chartSlabsMap2); + + HashMap<String, String> chartSlabsMap3 = new HashMap<>(); + chartSlabsMap3.put("description", "Third"); + chartSlabsMap3.put("periodType", MONTHS); + chartSlabsMap3.put("fromPeriod", "1"); + chartSlabsMap3.put("toPeriod", "6"); + chartSlabsMap3.put("amountRangeFrom", "5001"); + chartSlabsMap3.put("annualInterestRate", "7"); + chartSlabsMap3.put("locale", LOCALE); + chartSlabs.add(2, chartSlabsMap3); + + HashMap<String, String> chartSlabsMap4 = new HashMap<>(); + chartSlabsMap4.put("description", "Fourth"); + chartSlabsMap4.put("periodType", MONTHS); + chartSlabsMap4.put("fromPeriod", "7"); + chartSlabsMap4.put("amountRangeFrom", "5001"); + chartSlabsMap4.put("annualInterestRate", "8"); + chartSlabsMap4.put("locale", LOCALE); + chartSlabs.add(3, chartSlabsMap4); + + return chartSlabs; + } + + public List<HashMap<String, String>> constructChartSlabWithAmountRange() { + this.isPrimaryGroupingByAmount = true; + List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); + HashMap<String, String> chartSlabsMap1 = new HashMap<>(); + chartSlabsMap1.put("description", "First"); + chartSlabsMap1.put("amountRangeFrom", "1"); + chartSlabsMap1.put("amountRangeTo", "5000"); + chartSlabsMap1.put("annualInterestRate", "5"); + chartSlabsMap1.put("locale", LOCALE); + chartSlabs.add(0, chartSlabsMap1); + + HashMap<String, String> chartSlabsMap3 = new HashMap<>(); + chartSlabsMap3.put("description", "Third"); + chartSlabsMap3.put("amountRangeFrom", "5001"); + chartSlabsMap3.put("amountRangeTo", "10000"); + chartSlabsMap3.put("annualInterestRate", "7"); + chartSlabsMap3.put("locale", LOCALE); + chartSlabs.add(1, chartSlabsMap3); + + HashMap<String, String> chartSlabsMap4 = new HashMap<>(); + chartSlabsMap4.put("description", "Fourth"); + chartSlabsMap4.put("amountRangeFrom", "10001"); + chartSlabsMap4.put("annualInterestRate", "8"); + chartSlabsMap4.put("locale", LOCALE); + chartSlabs.add(2, chartSlabsMap4); + + return chartSlabs; + } + public FixedDepositProductHelper withAccountingRuleAsNone() { this.accountingRule = NONE; return this; @@ -194,6 +362,26 @@ public class FixedDepositProductHelper { return this; } + public FixedDepositProductHelper withPeriodRangeChart() { + this.chartSlabs = constructChartSlabWithPeriodRange(); + return this; + } + + public FixedDepositProductHelper withPeriodAndAmountRangeChart() { + this.chartSlabs = constructChartSlabWithPeriodAndAmountRange(); + return this; + } + + public FixedDepositProductHelper withAmountRangeChart() { + this.chartSlabs = constructChartSlabWithAmountRange(); + return this; + } + + public FixedDepositProductHelper withAmountAndPeriodRangeChart() { + this.chartSlabs = constructChartSlabWithAmountAndPeriodRange(); + return this; + } + private Map<String, String> getAccountMappingForCashBased() { final Map<String, String> map = new HashMap<>(); if (accountList != null) { http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/37dfe1a0/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java index 5ec7cfd..d556cd8 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java @@ -28,6 +28,7 @@ import java.util.Locale; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.Utils; +import org.apache.fineract.integrationtests.common.fixeddeposit.FixedDepositAccountHelper; import com.google.gson.Gson; import com.jayway.restassured.specification.RequestSpecification; @@ -99,67 +100,18 @@ public class RecurringDepositAccountHelper { private final String currencyCode = USD; private String interestCalculationDaysInYearType = DAYS_365; private final String depositAmount = "2000"; - private final String depositPeriod = "14"; + private String depositPeriod = "14"; private final String depositPeriodFrequencyId = MONTHS; private final String recurringFrequency = "1"; private final String recurringFrequencyType = MONTHS; - private final String mandatoryRecommendedDepositAmount = "2000"; + private String mandatoryRecommendedDepositAmount = "2000"; private String submittedOnDate = ""; private String expectedFirstDepositOnDate = ""; private boolean isCalendarInherited = false; - public String build(final String clientId, final String productId, final String validFrom, final String validTo, - final String penalInterestType) { + public String build(final String clientId, final String productId, final String penalInterestType) { final HashMap<String, Object> map = new HashMap<>(); - List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>(); - HashMap<String, String> chartSlabsMap1 = new HashMap<>(); - chartSlabsMap1.put("description", "First"); - chartSlabsMap1.put("periodType", MONTHS); - chartSlabsMap1.put("fromPeriod", "1"); - chartSlabsMap1.put("toPeriod", "6"); - chartSlabsMap1.put("annualInterestRate", "5"); - chartSlabsMap1.put("locale", LOCALE); - chartSlabs.add(0, chartSlabsMap1); - - HashMap<String, String> chartSlabsMap2 = new HashMap<>(); - chartSlabsMap2.put("description", "Second"); - chartSlabsMap2.put("periodType", MONTHS); - chartSlabsMap2.put("fromPeriod", "7"); - chartSlabsMap2.put("toPeriod", "12"); - chartSlabsMap2.put("annualInterestRate", "6"); - chartSlabsMap2.put("locale", LOCALE); - chartSlabs.add(1, chartSlabsMap2); - - HashMap<String, String> chartSlabsMap3 = new HashMap<>(); - chartSlabsMap3.put("description", "Third"); - chartSlabsMap3.put("periodType", MONTHS); - chartSlabsMap3.put("fromPeriod", "13"); - chartSlabsMap3.put("toPeriod", "18"); - chartSlabsMap3.put("annualInterestRate", "7"); - chartSlabsMap3.put("locale", LOCALE); - chartSlabs.add(2, chartSlabsMap3); - - HashMap<String, String> chartSlabsMap4 = new HashMap<>(); - chartSlabsMap4.put("description", "Fourth"); - chartSlabsMap4.put("periodType", MONTHS); - chartSlabsMap4.put("fromPeriod", "19"); - chartSlabsMap4.put("toPeriod", "24"); - chartSlabsMap4.put("annualInterestRate", "8"); - chartSlabsMap4.put("locale", LOCALE); - chartSlabs.add(3, chartSlabsMap4); - - List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>(); - HashMap<String, Object> chartsMap = new HashMap<>(); - chartsMap.put("fromDate", validFrom); - chartsMap.put("endDate", validTo); - chartsMap.put("dateFormat", "dd MMMM yyyy"); - chartsMap.put("locale", LOCALE); - chartsMap.put("isActiveChart", this.isActiveChart); - chartsMap.put("chartSlabs", chartSlabs); - charts.add(chartsMap); - - map.put("charts", charts); map.put("productId", productId); map.put("clientId", clientId); map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType); @@ -231,8 +183,8 @@ public class RecurringDepositAccountHelper { return annualInterestRate; } - public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Float depositAmount, Integer depositPeriod, - double interestPerDay, Integer compoundingInterval, Integer postingInterval) { + 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; @@ -274,7 +226,7 @@ public class RecurringDepositAccountHelper { final String EXPECTED_FIRST_DEPOSIT_ON_ON_DATE = SUBMITTED_ON_DATE; final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) .withSubmittedOnDate(SUBMITTED_ON_DATE).withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE) - .build(clientID, productID, validFrom, validTo, penalInterestType); + .build(clientID, productID, penalInterestType); return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); @@ -292,7 +244,7 @@ public class RecurringDepositAccountHelper { .withInterestCompoundingPeriodType(interestCompoundingPeriodType) // .withInterestPostingPeriodType(interestPostingPeriodType) // .withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) // - .build(clientID, productID, validFrom, validTo, penalInterestType); + .build(clientID, productID, penalInterestType); return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); @@ -552,5 +504,15 @@ public class RecurringDepositAccountHelper { this.interestPostingPeriodType = interestPostingPeriodTypeId; return this; } + + public RecurringDepositAccountHelper withDepositPeriod(final String depositPeriod) { + this.depositPeriod = depositPeriod; + return this; + } + + public RecurringDepositAccountHelper withMandatoryDepositAmount(final String depositAmount) { + this.mandatoryRecommendedDepositAmount = depositAmount; + return this; + } } \ No newline at end of file
