You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ra...@apache.org on 2016/11/03 13:46:28 UTC

[3/3] incubator-fineract git commit: interest posting on specified date

interest posting on specified date


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/580840c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/580840c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/580840c3

Branch: refs/heads/develop
Commit: 580840c35ed24d4db79748d301fd90d0958ce0eb
Parents: b3c4f75
Author: Koustav Muhuri <ko...@confluxtechnologies.com>
Authored: Thu Nov 3 15:34:18 2016 +0530
Committer: Koustav Muhuri <ko...@confluxtechnologies.com>
Committed: Thu Nov 3 15:39:29 2016 +0530

----------------------------------------------------------------------
 .../ClientSavingsIntegrationTest.java           | 1023 +++++++++++++++++-
 .../common/savings/SavingsAccountHelper.java    |   42 +
 .../commands/service/CommandWrapperBuilder.java |    9 +
 .../portfolio/savings/SavingsApiConstants.java  |    7 +-
 .../SavingsAccountTransactionsApiResource.java  |    9 +-
 .../data/SavingsAccountTransactionData.java     |   36 +-
 .../savings/domain/FixedDepositAccount.java     |   37 +-
 .../savings/domain/RecurringDepositAccount.java |   31 +-
 .../savings/domain/SavingsAccount.java          |   66 +-
 .../domain/SavingsAccountDomainServiceJpa.java  |   12 +-
 .../domain/SavingsAccountTransaction.java       |   92 +-
 .../portfolio/savings/domain/SavingsHelper.java |   46 +-
 .../savings/domain/interest/PostingPeriod.java  |   20 +-
 .../PostInterestAsOnDateException.java          |   61 ++
 .../PostInterestClosingDateException.java       |   28 +
 ...ostInterestSavingsAccountCommandHandler.java |    2 +-
 ...gsAccountInterestAsOnDateCommandHandler.java |   47 +
 .../DepositAccountReadPlatformServiceImpl.java  |    8 +-
 ...ntWritePlatformServiceJpaRepositoryImpl.java |  152 +--
 .../SavingsAccountReadPlatformServiceImpl.java  |    8 +-
 .../SavingsAccountWritePlatformService.java     |    7 +-
 ...ntWritePlatformServiceJpaRepositoryImpl.java |  106 +-
 .../service/SavingsSchedularServiceImpl.java    |    4 +-
 ...V321__boolean_field_As_Interest_PostedOn.sql |   21 +
 24 files changed, 1648 insertions(+), 226 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
index 8ac2227..7a49c76 100755
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
@@ -117,12 +117,11 @@ public class ClientSavingsIntegrationTest {
         this.savingsAccountHelper.postInterestForSavings(savingsId);
         summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
         Assert.assertFalse(summaryBefore.equals(summary));
-
+        
         final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
         // verifySavingsInterest(savingsInterest);
-
     }
-
+    
     @Test
     public void testSavingsAccountWithMinBalanceForInterestCalculation() {
         this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
@@ -796,6 +795,1024 @@ public class ClientSavingsIntegrationTest {
                 savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
     }
     
+	@SuppressWarnings("unchecked")
+	@Test
+	public void testSavingsAccountPostInterestOnLastDayWithOverdraft() {
+		this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec,
+				this.responseSpec);
+
+		/***
+		 * Create a client to apply for savings account (overdraft account).
+		 */
+		final Integer clientID = ClientHelper.createClient(this.requestSpec,
+				this.responseSpec);
+		Assert.assertNotNull(clientID);
+		final String minBalanceForInterestCalculation = null;
+
+		/***
+		 * Create savings product with zero opening balance and overdraft
+		 * enabled
+		 */
+		final String zeroOpeningBalance = "0.0";
+		final String minRequiredBalance = null;
+		final String enforceMinRequiredBalance = "false";
+		final boolean allowOverdraft = true;
+		final Integer savingsProductID = createSavingsProduct(this.requestSpec,
+				this.responseSpec, zeroOpeningBalance,
+				minBalanceForInterestCalculation, minRequiredBalance,
+				enforceMinRequiredBalance, allowOverdraft);
+		Assert.assertNotNull(savingsProductID);
+
+		/***
+		 * Apply for Savings account
+		 */
+		final Integer savingsId = this.savingsAccountHelper
+				.applyForSavingsApplication(clientID, savingsProductID,
+						ACCOUNT_TYPE_INDIVIDUAL);
+		Assert.assertNotNull(savingsProductID);
+
+		HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(
+				clientID, savingsProductID, savingsId, ACCOUNT_TYPE_INDIVIDUAL);
+		Assert.assertTrue(modifications.containsKey("submittedOnDate"));
+
+		HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(
+				this.requestSpec, this.responseSpec, savingsId);
+		SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+		/***
+		 * Approve the savings account
+		 */
+		savingsStatusHashMap = this.savingsAccountHelper
+				.approveSavings(savingsId);
+		SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+		DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
+		Calendar todaysDate = Calendar.getInstance();
+		todaysDate.add(Calendar.MONTH, -1);
+
+		final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
+
+		/***
+		 * Activate the application and verify account status
+		 * 
+		 * @param activationDate
+		 *            this value is every time first day of previous month
+		 */
+		savingsStatusHashMap = activateSavingsAccount(savingsId,
+				ACTIVATION_DATE);
+		SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+		/***
+		 * Verify the account summary
+		 */
+		final HashMap summaryBefore = this.savingsAccountHelper
+				.getSavingsSummary(savingsId);
+		this.savingsAccountHelper.calculateInterestForSavings(savingsId);
+		HashMap summary = this.savingsAccountHelper
+				.getSavingsSummary(savingsId);
+		assertEquals(summaryBefore, summary);
+
+		final Integer lastDayOfMonth = todaysDate
+				.getActualMaximum(Calendar.DAY_OF_MONTH);
+		todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
+		final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime());
+		Float balance = Float.valueOf(zeroOpeningBalance);
+
+		DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM yyyy",
+				Locale.US);
+		Calendar transactionDate = Calendar.getInstance();
+		transactionDate.set(Calendar.DAY_OF_MONTH, 2);
+		String TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+
+		/***
+		 * Perform Deposit transaction on last day of month and verify account
+		 * balance.
+		 * 
+		 * @param transactionDate
+		 *            this value is every time last day of previous month
+		 */
+		Integer depositTransactionId = (Integer) this.savingsAccountHelper
+				.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
+						WITHDRAWAL_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+		HashMap depositTransaction = this.savingsAccountHelper
+				.getSavingsTransaction(savingsId, depositTransactionId);
+		balance += new Float(DEPOSIT_AMOUNT);
+		assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT),
+				depositTransaction.get("amount"));
+		assertEquals("Verifying Balance after Deposit", balance,
+				depositTransaction.get("runningBalance"));
+
+		/***
+		 * Calculate expected interest to be posted, interest should be posted
+		 * for one day only because deposit transaction happened on last day of
+		 * month before this account balance is negative.
+		 */
+		this.savingsAccountHelper.postInterestForSavings(savingsId);
+		HashMap accountDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountDetails.get("summary");
+		Float accountDetailsPostInterestPosted = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		Float nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		HashMap interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		double interestRateInFraction = (nominalAnnualInterest / 100);
+		double perDay = (double) 1 / (daysInYear);
+		double interestPerDay = interestRateInFraction * perDay;
+		Float interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		DecimalFormat decimalFormat = new DecimalFormat("",
+				new DecimalFormatSymbols(Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+
+		this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+				TRANSACTION_DATE);
+		HashMap accountTransactionDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountDetails.get("summary");
+		Float accountDetailsPostInterest = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		interestRateInFraction = (nominalAnnualInterest / 100);
+		perDay = (double) 1 / (daysInYear);
+		interestPerDay = interestRateInFraction * perDay;
+		interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+				Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+		System.out
+				.println("-----Post Interest As on Successfully Worked----------");
+
+		transactionDate.set(Calendar.DAY_OF_MONTH, 3);
+		TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+
+		this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+				TRANSACTION_DATE);
+		accountTransactionDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountDetails.get("summary");
+		accountDetailsPostInterest = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		interestRateInFraction = (nominalAnnualInterest / 100);
+		perDay = (double) 1 / (daysInYear);
+		interestPerDay = interestRateInFraction * perDay;
+		interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+				Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+		System.out
+				.println("-----Post Interest As on Successfully Worked-------");
+
+		DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy",
+				Locale.US);
+		Calendar transactionCalendarDateFormat = Calendar.getInstance();
+		transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0);
+		transactionDate.set(Calendar.DAY_OF_MONTH, 22);
+		TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+		if (Calendar.DAY_OF_MONTH >= 22) {
+			this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+					TRANSACTION_DATE);
+			accountTransactionDetails = this.savingsAccountHelper
+					.getSavingsDetails(savingsId);
+			summary = (HashMap) accountTransactionDetails.get("summary");
+			accountDetailsPostInterest = Float.valueOf(summary.get(
+					"totalInterestPosted").toString());
+
+			nominalAnnualInterest = Float.valueOf(accountDetails.get(
+					"nominalAnnualInterestRate").toString());
+			interestCalculationDaysInYearType = (HashMap) accountDetails
+					.get("interestCalculationDaysInYearType");
+			daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
+					"id").toString());
+			interestRateInFraction = (nominalAnnualInterest / 100);
+			perDay = (double) 1 / (daysInYear);
+			interestPerDay = interestRateInFraction * perDay;
+			interestPosted = (float) (interestPerDay * balance * 19);
+
+			/***
+			 * Apply rounding on interestPosted, actualInterestPosted and verify
+			 * both are same
+			 */
+			decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+					Locale.US));
+			decimalFormat.applyPattern("#.###");
+			interestPosted = new Float(decimalFormat.format(interestPosted));
+			accountDetailsPostInterestPosted = new Float(
+					decimalFormat.format(accountDetailsPostInterestPosted));
+			assertEquals("Verifying interest posted", interestPosted,
+					accountDetailsPostInterestPosted);
+			System.out
+					.println("-----Post Interest As on Successfully Worked----------");
+		}
+		DateFormat lastTransactionDateFormat = new SimpleDateFormat(
+				"dd MMMM yyyy", Locale.US);
+		Calendar postedLastDate = Calendar.getInstance();
+		int numberOfDateOfMonth = postedLastDate
+				.getActualMaximum(Calendar.DAY_OF_MONTH);
+		TRANSACTION_DATE = lastTransactionDateFormat.format(transactionDate
+				.getTime());
+
+		if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) {
+
+			this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+					TRANSACTION_DATE);
+			accountTransactionDetails = this.savingsAccountHelper
+					.getSavingsDetails(savingsId);
+			summary = (HashMap) accountTransactionDetails.get("summary");
+			accountDetailsPostInterest = Float.valueOf(summary.get(
+					"totalInterestPosted").toString());
+
+			nominalAnnualInterest = Float.valueOf(accountDetails.get(
+					"nominalAnnualInterestRate").toString());
+			interestCalculationDaysInYearType = (HashMap) accountDetails
+					.get("interestCalculationDaysInYearType");
+			daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
+					"id").toString());
+			interestRateInFraction = (nominalAnnualInterest / 100);
+			perDay = (double) 1 / (daysInYear);
+			interestPerDay = interestRateInFraction * perDay;
+			interestPosted = (float) (interestPerDay * balance * 8);
+
+			/***
+			 * Apply rounding on interestPosted, actualInterestPosted and verify
+			 * both are same
+			 */
+			decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+					Locale.US));
+			decimalFormat.applyPattern("#.###");
+			interestPosted = new Float(decimalFormat.format(interestPosted));
+			accountDetailsPostInterestPosted = new Float(
+					decimalFormat.format(accountDetailsPostInterestPosted));
+			assertEquals("Verifying interest posted", interestPosted,
+					accountDetailsPostInterestPosted);
+			System.out
+					.println("-----Post Interest As on Successfully Worked----------");
+
+		}
+		transactionDate.set(Calendar.DAY_OF_MONTH, 1);
+		TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+		this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+				TRANSACTION_DATE);
+		accountTransactionDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountTransactionDetails.get("summary");
+		accountDetailsPostInterest = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		interestRateInFraction = (nominalAnnualInterest / 100);
+		perDay = (double) 1 / (daysInYear);
+		interestPerDay = interestRateInFraction * perDay;
+		interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+				Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+		System.out
+				.println("-----Post Interest As on Successfully Worked----------");
+
+	}
+	
+	@SuppressWarnings("unchecked")
+	@Test
+	public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() {
+		this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec,
+				this.responseSpec);
+
+		/***
+		 * Create a client to apply for savings account (overdraft account).
+		 */
+		final Integer clientID = ClientHelper.createClient(this.requestSpec,
+				this.responseSpec);
+		Assert.assertNotNull(clientID);
+		final String minBalanceForInterestCalculation = null;
+
+		/***
+		 * Create savings product with zero opening balance and overdraft
+		 * enabled
+		 */
+		final String zeroOpeningBalance = "0.0";
+		final String minRequiredBalance = null;
+		final String enforceMinRequiredBalance = "false";
+		final boolean allowOverdraft = true;
+		final Integer savingsProductID = createSavingsProduct(this.requestSpec,
+				this.responseSpec, zeroOpeningBalance,
+				minBalanceForInterestCalculation, minRequiredBalance,
+				enforceMinRequiredBalance, allowOverdraft);
+		Assert.assertNotNull(savingsProductID);
+
+		/***
+		 * Apply for Savings account
+		 */
+		final Integer savingsId = this.savingsAccountHelper
+				.applyForSavingsApplication(clientID, savingsProductID,
+						ACCOUNT_TYPE_INDIVIDUAL);
+		Assert.assertNotNull(savingsProductID);
+
+		HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(
+				clientID, savingsProductID, savingsId, ACCOUNT_TYPE_INDIVIDUAL);
+		Assert.assertTrue(modifications.containsKey("submittedOnDate"));
+
+		HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(
+				this.requestSpec, this.responseSpec, savingsId);
+		SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+		/***
+		 * Approve the savings account
+		 */
+		savingsStatusHashMap = this.savingsAccountHelper
+				.approveSavings(savingsId);
+		SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+		DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
+		Calendar todaysDate = Calendar.getInstance();
+		todaysDate.add(Calendar.MONTH, -1);
+
+		final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
+
+		/***
+		 * Activate the application and verify account status
+		 * 
+		 * @param activationDate
+		 *            this value is every time first day of previous month
+		 */
+		savingsStatusHashMap = activateSavingsAccount(savingsId,
+				ACTIVATION_DATE);
+		SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+		/***
+		 * Verify the account summary
+		 */
+		final HashMap summaryBefore = this.savingsAccountHelper
+				.getSavingsSummary(savingsId);
+		this.savingsAccountHelper.calculateInterestForSavings(savingsId);
+		HashMap summary = this.savingsAccountHelper
+				.getSavingsSummary(savingsId);
+		assertEquals(summaryBefore, summary);
+
+		final Integer lastDayOfMonth = todaysDate
+				.getActualMaximum(Calendar.DAY_OF_MONTH);
+		todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
+		final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime());
+		Float balance = Float.valueOf(zeroOpeningBalance);
+
+		DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM yyyy",
+				Locale.US);
+		Calendar transactionDate = Calendar.getInstance();
+		transactionDate.set(Calendar.DAY_OF_MONTH, 2);
+		String TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+
+		 /***
+         * Perform withdraw transaction, verify account balance(account balance
+         * will go to negative as no deposits are there prior to this
+         * transaction)
+         */
+        Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
+        		ACTIVATION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
+        balance -= new Float(WITHDRAW_AMOUNT);
+        assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
+        assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
+        
+        /***
+         * Perform Deposit transaction on last day of month and verify account
+         * balance.
+         * 
+         * @param transactionDate
+         *            this value is every time last day of previous month
+         */
+        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
+        		WITHDRAWAL_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
+        balance += new Float(DEPOSIT_AMOUNT);
+        assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
+        assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
+
+		/***
+		 * Calculate expected interest to be posted, interest should be posted
+		 * for one day only because deposit transaction happened on last day of
+		 * month before this account balance is negative.
+		 */
+		this.savingsAccountHelper.postInterestForSavings(savingsId);
+		HashMap accountDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountDetails.get("summary");
+		Float accountDetailsPostInterestPosted = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		Float nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		HashMap interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		double interestRateInFraction = (nominalAnnualInterest / 100);
+		double perDay = (double) 1 / (daysInYear);
+		double interestPerDay = interestRateInFraction * perDay;
+		Float interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		DecimalFormat decimalFormat = new DecimalFormat("",
+				new DecimalFormatSymbols(Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+
+		this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+				TRANSACTION_DATE);
+		HashMap accountTransactionDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountDetails.get("summary");
+		Float accountDetailsPostInterest = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		interestRateInFraction = (nominalAnnualInterest / 100);
+		perDay = (double) 1 / (daysInYear);
+		interestPerDay = interestRateInFraction * perDay;
+		interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+				Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+		System.out
+				.println("-----Post Interest As on Successfully Worked----------");
+
+		transactionDate.set(Calendar.DAY_OF_MONTH, 3);
+		TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+
+		this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+				TRANSACTION_DATE);
+		accountTransactionDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountDetails.get("summary");
+		accountDetailsPostInterest = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		interestRateInFraction = (nominalAnnualInterest / 100);
+		perDay = (double) 1 / (daysInYear);
+		interestPerDay = interestRateInFraction * perDay;
+		interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+				Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+		System.out
+				.println("-----Post Interest As on Successfully Worked-------");
+
+		DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy",
+				Locale.US);
+		Calendar transactionCalendarDateFormat = Calendar.getInstance();
+		transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0);
+		transactionDate.set(Calendar.DAY_OF_MONTH, 22);
+		TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+		if (Calendar.DAY_OF_MONTH >= 22) {
+			this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+					TRANSACTION_DATE);
+			accountTransactionDetails = this.savingsAccountHelper
+					.getSavingsDetails(savingsId);
+			summary = (HashMap) accountTransactionDetails.get("summary");
+			accountDetailsPostInterest = Float.valueOf(summary.get(
+					"totalInterestPosted").toString());
+
+			nominalAnnualInterest = Float.valueOf(accountDetails.get(
+					"nominalAnnualInterestRate").toString());
+			interestCalculationDaysInYearType = (HashMap) accountDetails
+					.get("interestCalculationDaysInYearType");
+			daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
+					"id").toString());
+			interestRateInFraction = (nominalAnnualInterest / 100);
+			perDay = (double) 1 / (daysInYear);
+			interestPerDay = interestRateInFraction * perDay;
+			interestPosted = (float) (interestPerDay * balance * 19);
+
+			/***
+			 * Apply rounding on interestPosted, actualInterestPosted and verify
+			 * both are same
+			 */
+			decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+					Locale.US));
+			decimalFormat.applyPattern("#.###");
+			interestPosted = new Float(decimalFormat.format(interestPosted));
+			accountDetailsPostInterestPosted = new Float(
+					decimalFormat.format(accountDetailsPostInterestPosted));
+			assertEquals("Verifying interest posted", interestPosted,
+					accountDetailsPostInterestPosted);
+			System.out
+					.println("-----Post Interest As on Successfully Worked----------");
+		}
+		DateFormat lastTransactionDateFormat = new SimpleDateFormat(
+				"dd MMMM yyyy", Locale.US);
+		Calendar postedLastDate = Calendar.getInstance();
+		int numberOfDateOfMonth = postedLastDate
+				.getActualMaximum(Calendar.DAY_OF_MONTH);
+		TRANSACTION_DATE = lastTransactionDateFormat.format(transactionDate
+				.getTime());
+
+		if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) {
+
+			this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+					TRANSACTION_DATE);
+			accountTransactionDetails = this.savingsAccountHelper
+					.getSavingsDetails(savingsId);
+			summary = (HashMap) accountTransactionDetails.get("summary");
+			accountDetailsPostInterest = Float.valueOf(summary.get(
+					"totalInterestPosted").toString());
+
+			nominalAnnualInterest = Float.valueOf(accountDetails.get(
+					"nominalAnnualInterestRate").toString());
+			interestCalculationDaysInYearType = (HashMap) accountDetails
+					.get("interestCalculationDaysInYearType");
+			daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get(
+					"id").toString());
+			interestRateInFraction = (nominalAnnualInterest / 100);
+			perDay = (double) 1 / (daysInYear);
+			interestPerDay = interestRateInFraction * perDay;
+			interestPosted = (float) (interestPerDay * balance * 8);
+
+			/***
+			 * Apply rounding on interestPosted, actualInterestPosted and verify
+			 * both are same
+			 */
+			decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+					Locale.US));
+			decimalFormat.applyPattern("#.###");
+			interestPosted = new Float(decimalFormat.format(interestPosted));
+			accountDetailsPostInterestPosted = new Float(
+					decimalFormat.format(accountDetailsPostInterestPosted));
+			assertEquals("Verifying interest posted", interestPosted,
+					accountDetailsPostInterestPosted);
+			System.out
+					.println("-----Post Interest As on Successfully Worked----------");
+
+		}
+		transactionDate.set(Calendar.DAY_OF_MONTH, 1);
+		TRANSACTION_DATE = dateFormat.format(transactionDate.getTime());
+		this.savingsAccountHelper.postInterestAsOnSavings(savingsId,
+				TRANSACTION_DATE);
+		accountTransactionDetails = this.savingsAccountHelper
+				.getSavingsDetails(savingsId);
+		summary = (HashMap) accountTransactionDetails.get("summary");
+		accountDetailsPostInterest = Float.valueOf(summary.get(
+				"totalInterestPosted").toString());
+
+		nominalAnnualInterest = Float.valueOf(accountDetails.get(
+				"nominalAnnualInterestRate").toString());
+		interestCalculationDaysInYearType = (HashMap) accountDetails
+				.get("interestCalculationDaysInYearType");
+		daysInYear = Integer.valueOf(interestCalculationDaysInYearType
+				.get("id").toString());
+		interestRateInFraction = (nominalAnnualInterest / 100);
+		perDay = (double) 1 / (daysInYear);
+		interestPerDay = interestRateInFraction * perDay;
+		interestPosted = (float) (interestPerDay * balance * 1);
+
+		/***
+		 * Apply rounding on interestPosted, actualInterestPosted and verify
+		 * both are same
+		 */
+		decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(
+				Locale.US));
+		decimalFormat.applyPattern("#.###");
+		interestPosted = new Float(decimalFormat.format(interestPosted));
+		accountDetailsPostInterestPosted = new Float(
+				decimalFormat.format(accountDetailsPostInterestPosted));
+		assertEquals("Verifying interest posted", interestPosted,
+				accountDetailsPostInterestPosted);
+		System.out
+				.println("-----Post Interest As on Successfully Worked----------");
+	}
+       
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSavingsAccountPostInterestWithOverdraft() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+        final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
+
+        /***
+         * Create a client to apply for savings account (overdraft account).
+         */
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+        final String minBalanceForInterestCalculation = null;
+
+        /***
+         * Create savings product with zero opening balance and overdraft
+         * enabled
+         */
+        final String zeroOpeningBalance = "0.0";
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final boolean allowOverdraft = true;
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, zeroOpeningBalance,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
+        Assert.assertNotNull(savingsProductID);
+
+        /***
+         * Apply for Savings account
+         */
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
+        Assert.assertNotNull(savingsProductID);
+
+        HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
+                ACCOUNT_TYPE_INDIVIDUAL);
+        Assert.assertTrue(modifications.containsKey("submittedOnDate"));
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        /***
+         * Approve the savings account
+         */
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
+        Calendar todaysDate = Calendar.getInstance();
+        todaysDate.add(Calendar.MONTH, -1);
+        todaysDate.set(Calendar.DAY_OF_MONTH, 1);
+        final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
+        final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH);
+        todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
+        final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
+
+        Calendar postedDate = Calendar.getInstance();
+        postedDate.set(Calendar.DAY_OF_MONTH, 2);
+
+        final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime());
+
+        /***
+         * Activate the application and verify account status
+         * 
+         * @param activationDate
+         *            this value is every time first day of previous month
+         */
+        savingsStatusHashMap = activateSavingsAccount(savingsId, ACTIVATION_DATE);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        /***
+         * Verify the account summary
+         */
+        final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        this.savingsAccountHelper.calculateInterestForSavings(savingsId);
+        HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        assertEquals(summaryBefore, summary);
+
+        Float balance = Float.valueOf(zeroOpeningBalance);
+
+        /***
+         * Perform withdraw transaction, verify account balance(account balance
+         * will go to negative as no deposits are there prior to this
+         * transaction)
+         */
+        Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
+                ACTIVATION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
+        balance -= new Float(WITHDRAW_AMOUNT);
+        assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
+        assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
+
+        /***
+         * Perform Deposit transaction on last day of month and verify account
+         * balance.
+         * 
+         * @param transactionDate
+         *            this value is every time last day of previous month
+         */
+        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
+                TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
+        balance += new Float(DEPOSIT_AMOUNT);
+        assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
+        assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
+
+        /***
+         * Perform Post interest transaction and verify the posted amount
+         */
+        this.savingsAccountHelper.postInterestForSavings(savingsId);
+        HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
+        summary = (HashMap) accountDetails.get("summary");
+        Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
+
+        /***
+         * Calculate expected interest to be posted, interest should be posted
+         * for one day only because deposit transaction happened on last day of
+         * month before this account balance is negative.
+         */
+        this.savingsAccountHelper.postInterestAsOnSavings(savingsId, POSTED_TRANSACTION_DATE);
+        HashMap accountDetailsPostInterest = this.savingsAccountHelper.getSavingsDetails(savingsId);
+        summary = (HashMap) accountDetails.get("summary");
+        ArrayList interestPostingTransaction = (ArrayList) ((HashMap) ((ArrayList) accountDetails.get("transactions")).get(0)).get("date");
+        Float accountDetailsPostInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
+
+        /***
+         * Calculate expected interest to be posted, interest should be posted
+         * for one day only because deposit transaction happened on last day of
+         * month before this account balance is negative.
+         */
+        final Float nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
+        final HashMap interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
+        final Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
+        double interestRateInFraction = (nominalAnnualInterest / 100);
+        double perDay = (double) 1 / (daysInYear);
+        double interestPerDay = interestRateInFraction * perDay;
+        Float interestPosted = (float) (interestPerDay * balance * 1);
+
+        /***
+         * Apply rounding on interestPosted, actualInterestPosted and verify
+         * both are same
+         */
+        DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
+        decimalFormat.applyPattern("#.###");
+        interestPosted = new Float(decimalFormat.format(interestPosted));
+        actualInterestPosted = new Float(decimalFormat.format(accountDetailsPostInterestPosted));
+        assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted);
+        System.out.println("------Post Interest As On After doing a post interest Successfully worked--------");
+
+        todaysDate = Calendar.getInstance();
+        final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
+
+        Calendar interestPostingDate = Calendar.getInstance();
+        Calendar todysDate = Calendar.getInstance();
+        interestPostingDate.set((int) interestPostingTransaction.get(0), (int) interestPostingTransaction.get(1) - 1,
+                (int) interestPostingTransaction.get(2));
+        final String INTEREST_POSTING_DATE = dateFormat.format(interestPostingDate.getTime());
+        final String TODYS_POSTING_DATE = dateFormat.format(todysDate.getTime());
+        String withdrawBalance = "true";
+
+        if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) {
+            final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
+            validationErrorHelper.closeSavingsAccountPostInterestAndGetBackRequiredField(savingsId, withdrawBalance,
+                    CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
+        } else {
+            final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
+            ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
+                    .closeSavingsAccountPostInterestAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR,
+                            CLOSEDON_DATE);
+            assertEquals("error.msg.postInterest.notDone", savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
+        }
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testPostInterestAsOnSavingsAccountWithOverdraft() {
+        this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
+        final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
+        final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
+
+        /***
+         * Create a client to apply for savings account (overdraft account).
+         */
+        final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+        Assert.assertNotNull(clientID);
+        final String minBalanceForInterestCalculation = null;
+
+        /***
+         * Create savings product with zero opening balance and overdraft
+         * enabled
+         */
+        final String zeroOpeningBalance = "0.0";
+        final String minRequiredBalance = null;
+        final String enforceMinRequiredBalance = "false";
+        final boolean allowOverdraft = true;
+        final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, zeroOpeningBalance,
+                minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
+        Assert.assertNotNull(savingsProductID);
+
+        /***
+         * Apply for Savings account
+         */
+        final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
+        Assert.assertNotNull(savingsProductID);
+
+        HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
+                ACCOUNT_TYPE_INDIVIDUAL);
+        Assert.assertTrue(modifications.containsKey("submittedOnDate"));
+
+        HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
+        SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
+
+        /***
+         * Approve the savings account
+         */
+        savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
+        SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
+
+        DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
+        Calendar todaysDate = Calendar.getInstance();
+        todaysDate.add(Calendar.MONTH, -1);
+        todaysDate.set(Calendar.DAY_OF_MONTH, 1);
+        final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
+        final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH);
+        todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
+        final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
+        
+        Calendar postedDate = Calendar.getInstance();
+        postedDate.set(Calendar.DAY_OF_MONTH, 1);
+       
+        final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime());        
+        Calendar postedLastDate = Calendar.getInstance();
+        int countOfDate=postedDate.getActualMaximum(Calendar.DAY_OF_MONTH);
+        System.out.println("count Of Date---> "+countOfDate);
+        postedLastDate.set(Calendar.DAY_OF_MONTH,countOfDate);
+        final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate.getTime());
+
+        /***
+         * Activate the application and verify account status
+         * 
+         * @param activationDate
+         *            this value is every time first day of previous month
+         */
+        savingsStatusHashMap = activateSavingsAccount(savingsId, ACTIVATION_DATE);
+        SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
+
+        /***
+         * Verify the account summary
+         */
+        final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        this.savingsAccountHelper.calculateInterestForSavings(savingsId);
+        HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
+        assertEquals(summaryBefore, summary);
+
+        Float balance = Float.valueOf(zeroOpeningBalance);
+
+        /***
+         * Perform withdraw transaction, verify account balance(account balance
+         * will go to negative as no deposits are there prior to this
+         * transaction)
+         */
+        Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
+                ACTIVATION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
+        balance -= new Float(WITHDRAW_AMOUNT);
+        assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
+        assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
+
+        /***
+         * Perform Deposit transaction on last day of month and verify account
+         * balance.
+         * 
+         * @param transactionDate
+         *            this value is every time last day of previous month
+         */
+        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
+                TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
+        HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
+        balance += new Float(DEPOSIT_AMOUNT);
+        assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
+        assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
+
+        /***
+         * Perform Post interest transaction and verify the posted amount
+         */
+        this.savingsAccountHelper.postInterestAsOnSavings(savingsId, POSTED_TRANSACTION_DATE);
+        HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
+        summary = (HashMap) accountDetails.get("summary");
+        Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
+        
+    
+        /***
+         * Calculate expected interest to be posted, interest should be posted
+         * for one day only because deposit transaction happened on last day of
+         * month before this account balance is negative.
+         */
+        final Float nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
+        final HashMap interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
+        final Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
+        double interestRateInFraction = (nominalAnnualInterest / 100);
+        double perDay = (double) 1 / (daysInYear);
+        double interestPerDay = interestRateInFraction * perDay;
+        Float interestPosted = (float) (interestPerDay * balance * 1);
+
+        /***
+         * Apply rounding on interestPosted, actualInterestPosted and verify
+         * both are same
+         */
+        DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
+        decimalFormat.applyPattern("#.###");
+        interestPosted = new Float(decimalFormat.format(interestPosted));
+        actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted));
+       assertEquals("Verifying interest posted", interestPosted, actualInterestPosted);           
+       System.out.println("------Post Interest As On Successful Worked--------");
+       
+       this.savingsAccountHelper.postInterestAsOnSavings(savingsId, POSTED_LAST_TRANSACTION_DATE);
+       HashMap accountLastDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
+       summary = (HashMap) accountLastDetails.get("summary");
+       Float actualLastInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
+       
+       final Float nominalLastAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
+       final HashMap interestLastCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
+       final Integer daysLastInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
+       double interestLastRateInFraction = (nominalAnnualInterest / 100);
+       double perLastDay = (double) 1 / (daysInYear);
+       double interestLastPerDay = interestLastRateInFraction * perLastDay;
+       Float interestLastPosted = (float) (interestLastPerDay * balance * 1);
+       
+       DecimalFormat decimalLastFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
+       decimalLastFormat.applyPattern("#.###");
+       interestLastPosted = new Float(decimalLastFormat.format(interestLastPosted));
+       actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted));
+      assertEquals("Verifying interest posted", interestLastPosted, actualInterestPosted);           
+      System.out.println("------Post Interest As On Successful Worked--------");
+       
+    }
+    
+    
+    
     @Test
     public void testSavingsAccount_WITH_WITHHOLD_TAX() {
         this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
index 07917d5..325d23e 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsAccountHelper.java
@@ -47,6 +47,7 @@ public class SavingsAccountHelper {
     private static final String WITHDRAWN_BY_CLIENT_SAVINGS_COMMAND = "withdrawnByApplicant";
     private static final String CALCULATE_INTEREST_SAVINGS_COMMAND = "calculateInterest";
     private static final String POST_INTEREST_SAVINGS_COMMAND = "postInterest";
+    private static final String POST_INTEREST_AS_ON_SAVINGS_COMMAND = "postInterestAsOn";
     private static final String CLOSE_SAVINGS_COMMAND = "close";
     private static final String UPDATE_WITHHOLD_TAX_STATUS = "updateWithHoldTax";
 
@@ -195,6 +196,12 @@ public class SavingsAccountHelper {
         performSavingActions(createSavingsCalculateInterestURL(POST_INTEREST_SAVINGS_COMMAND, savingsId),
                 getCalculatedInterestForSavingsApplicationAsJSON(), "");
     }
+    
+    public void postInterestAsOnSavings(final Integer savingsId, final String today) {
+        System.out.println("--------------------------------- POST INTEREST AS ON FOR SAVINGS --------------------------------");
+        performSavingActions(createSavingsPostInterestAsOnURL(POST_INTEREST_AS_ON_SAVINGS_COMMAND, savingsId),
+                getCalculatedInterestForSavingsApplicationAsJSON(today), CommonConstants.RESPONSE_RESOURCE_ID);
+    }
 
     public Integer addChargesForSavings(final Integer savingsId, final Integer chargeId, boolean addDueDate) {
         System.out.println("--------------------------------- ADD CHARGES FOR SAVINGS --------------------------------");
@@ -286,6 +293,16 @@ public class SavingsAccountHelper {
         System.out.println(savingsAccountCalculatedInterestJson);
         return savingsAccountCalculatedInterestJson;
     }
+    
+    private String getCalculatedInterestForSavingsApplicationAsJSON(final String today) {
+        final HashMap<String, String> map = new HashMap<>();
+        map.put("locale", CommonConstants.locale);
+        map.put("dateFormat", CommonConstants.dateFormat);
+        map.put("transactionDate", today);
+        map.put("postInterestManualOrAutomatic", "true");
+        String savingsAccountCalculatedInterestJson = new Gson().toJson(map);
+        return savingsAccountCalculatedInterestJson;
+    }
 
     private String getSavingsPayChargeJSON(final String amount, final String dueDate) {
         final HashMap<String, Object> map = new HashMap<>();
@@ -321,6 +338,20 @@ public class SavingsAccountHelper {
         map.put("closedOnDate", closedOnDate);
         map.put("withdrawBalance", withdrawBalance);
         map.put("note", "Close Test");
+        
+        String josn = new Gson().toJson(map);
+        return josn;
+    }
+    
+    private String getCloseAccountPostInterestJSON(String withdrawBalance, String closedOnDate) {
+        final HashMap<String, Object> map = new HashMap<>();
+        map.put("locale", CommonConstants.locale);
+        map.put("dateFormat", CommonConstants.dateFormat);
+        map.put("closedOnDate", closedOnDate);
+        map.put("withdrawBalance", withdrawBalance);
+        map.put("note", "Close Test");
+        map.put("postInterestValidationOnClosure", "true");
+        
         String josn = new Gson().toJson(map);
         return josn;
     }
@@ -341,6 +372,10 @@ public class SavingsAccountHelper {
     private String createSavingsCalculateInterestURL(final String command, final Integer savingsID) {
         return SAVINGS_ACCOUNT_URL + "/" + savingsID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
     }
+    
+    private String createSavingsPostInterestAsOnURL(final String command, final Integer savingsID) {
+        return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/transactions/" + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
+    }
 
     private String createChargesURL(final String command, final Integer savingsID, final Integer chargeId) {
         return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/charges/" + chargeId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
@@ -418,6 +453,13 @@ public class SavingsAccountHelper {
         return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID),
                 getCloseAccountJSON(withdrawBalance, closedOnDate), jsonAttributeToGetBack);
     }
+    
+    public Object closeSavingsAccountPostInterestAndGetBackRequiredField(final Integer savingsID, String withdrawBalance,
+            final String jsonAttributeToGetBack, final String closedOnDate) {
+        System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
+        return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID),
+                getCloseAccountPostInterestJSON(withdrawBalance, closedOnDate), jsonAttributeToGetBack);
+    }
 
     private String getPeriodChargeRequestJSON(Integer chargeId, boolean addDueDate) {
         final HashMap<String, Object> map = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java
index fa408d6..fb497c0 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java
@@ -2248,6 +2248,15 @@ public class CommandWrapperBuilder {
         this.href = "/savingsaccounts/" + accountId + "?commad=unassignSavingsOfficer";
         return this;
     }
+    
+    public CommandWrapperBuilder SavingsInterestPostingAsOnDate(final Long accountId) {
+        this.actionName = "POSTINTERESTASONDATE";
+        this.entityName = "SAVINGSACCOUNT";
+        this.savingsId = accountId;
+        this.entityId = null;
+        this.href = "/savingsaccounts/" + accountId + "?command=postInterestAsOn";
+        return this;
+    }
 
     public CommandWrapperBuilder createLoanRescheduleRequest(final String entityName) {
         this.actionName = "CREATE";

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsApiConstants.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsApiConstants.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsApiConstants.java
index 3393f8e..883f9ad 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsApiConstants.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsApiConstants.java
@@ -34,6 +34,7 @@ public class SavingsApiConstants {
     public static final String SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME = "savingsaccountcharge";
 
     // actions
+    public static final String postInterestValidationOnClosure = "postInterestValidationOnClosure";
     public static String summitalAction = ".summital";
     public static String approvalAction = ".approval";
     public static String undoApprovalAction = ".undoApproval";
@@ -244,13 +245,17 @@ public class SavingsApiConstants {
     public static final Set<String> SAVINGS_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(
             Arrays.asList(idParamName, "accountId", accountNoParamName, "currency", "amount", dateParamName, paymentDetailDataParamName,
                     runningBalanceParamName, reversedParamName));
+    
+    public static final Set<String> SAVINGS_ACCOUNT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName,
+            accountNoParamName));
 
     public static final Set<String> SAVINGS_ACCOUNT_ACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
             dateFormatParamName, activatedOnDateParamName));
 
     public static final Set<String> SAVINGS_ACCOUNT_CLOSE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
             dateFormatParamName, closedOnDateParamName, noteParamName, paymentTypeIdParamName, withdrawBalanceParamName,
-            transactionAccountNumberParamName, checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName));
+            transactionAccountNumberParamName, checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName,
+            postInterestValidationOnClosure));
 
     public static final Set<String> SAVINGS_ACCOUNT_CHARGES_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(chargeIdParamName,
             savingsAccountChargeIdParamName, chargeNameParamName, penaltyParamName, chargeTimeTypeParamName, dueAsOfDateParamName,

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java
index 2356319..db2bfd6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java
@@ -91,8 +91,8 @@ public class SavingsAccountTransactionsApiResource {
     @Produces({ MediaType.APPLICATION_JSON })
     public String retrieveTemplate(@PathParam("savingsId") final Long savingsId,
     // @QueryParam("command") final String commandParam,
-            @Context final UriInfo uriInfo) {
-
+            @Context final UriInfo uriInfo) {   
+        
         this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME);
 
         // FIXME - KW - for now just send back generic default information for
@@ -104,7 +104,7 @@ public class SavingsAccountTransactionsApiResource {
 
         final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         return this.toApiJsonSerializer.serialize(settings, savingsAccount,
-                SavingsApiConstants.SAVINGS_TRANSACTION_RESPONSE_DATA_PARAMETERS);
+                SavingsApiConstants.SAVINGS_TRANSACTION_RESPONSE_DATA_PARAMETERS);        
     }
 
     @GET
@@ -142,6 +142,9 @@ public class SavingsAccountTransactionsApiResource {
             } else if (is(commandParam, "withdrawal")) {
                 final CommandWrapper commandRequest = builder.savingsAccountWithdrawal(savingsId).build();
                 result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+            } else if (is(commandParam, "postInterestAsOn")) {
+                final CommandWrapper commandRequest = builder.savingsAccountInterestPosting(savingsId).build();
+                result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
             }
 
             if (result == null) {

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionData.java
index 75b1cc9..d6424ba 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionData.java
@@ -49,6 +49,7 @@ public class SavingsAccountTransactionData {
     private final boolean reversed;
     private final AccountTransferData transfer;
     private final LocalDate submittedOnDate;
+    private final boolean interestedPostedAsOn;
 
     // templates
     final Collection<PaymentTypeData> paymentTypeOptions;
@@ -56,19 +57,19 @@ public class SavingsAccountTransactionData {
     public static SavingsAccountTransactionData create(final Long id, final SavingsAccountTransactionEnumData transactionType,
             final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
             final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed,
-            final AccountTransferData transfer) {
+            final AccountTransferData transfer, final boolean interestedPostedAsOn) {
         final Collection<PaymentTypeData> paymentTypeOptions = null;
         return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency,
-                amount, runningBalance, reversed, transfer, paymentTypeOptions);
+                amount, runningBalance, reversed, transfer, paymentTypeOptions, interestedPostedAsOn);
     }
 
     public static SavingsAccountTransactionData create(final Long id, final SavingsAccountTransactionEnumData transactionType,
-                                                       final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
-                                                       final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed,
-                                                       final AccountTransferData transfer,final LocalDate submittedOnDate) {
+            final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
+            final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed,
+            final AccountTransferData transfer, final LocalDate submittedOnDate, final boolean interestedPostedAsOn) {
         final Collection<PaymentTypeData> paymentTypeOptions = null;
         return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency,
-                amount, runningBalance, reversed, transfer, paymentTypeOptions,submittedOnDate);
+                amount, runningBalance, reversed, transfer, paymentTypeOptions, submittedOnDate, interestedPostedAsOn);
     }
 
     public static SavingsAccountTransactionData template(final Long savingsId, final String savingsAccountNo,
@@ -80,8 +81,9 @@ public class SavingsAccountTransactionData {
         final boolean reversed = false;
         final PaymentDetailData paymentDetailData = null;
         final Collection<CodeValueData> paymentTypeOptions = null;
+        final boolean interestedPostedAsOn = false;
         return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, defaultLocalDate,
-                currency, amount, runningBalance, reversed, null, null);
+                currency, amount, runningBalance, reversed, null, null, interestedPostedAsOn);
     }
 
     public static SavingsAccountTransactionData templateOnTop(final SavingsAccountTransactionData savingsAccountTransactionData,
@@ -90,24 +92,23 @@ public class SavingsAccountTransactionData {
                 savingsAccountTransactionData.paymentDetailData, savingsAccountTransactionData.accountId,
                 savingsAccountTransactionData.accountNo, savingsAccountTransactionData.date, savingsAccountTransactionData.currency,
                 savingsAccountTransactionData.amount, savingsAccountTransactionData.runningBalance, savingsAccountTransactionData.reversed,
-                savingsAccountTransactionData.transfer, paymentTypeOptions);
+                savingsAccountTransactionData.transfer, paymentTypeOptions, savingsAccountTransactionData.interestedPostedAsOn);
     }
 
     private SavingsAccountTransactionData(final Long id, final SavingsAccountTransactionEnumData transactionType,
             final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
             final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed,
-            final AccountTransferData transfer, final Collection<PaymentTypeData> paymentTypeOptions) {
-
-        this(id,transactionType,paymentDetailData,savingsId, savingsAccountNo,date,
-        currency,amount,runningBalance, reversed,
-        transfer, paymentTypeOptions,null);
+            final AccountTransferData transfer, final Collection<PaymentTypeData> paymentTypeOptions, final boolean interestedPostedAsOn) {
 
+        this(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency, amount, runningBalance, reversed,
+                transfer, paymentTypeOptions, null, interestedPostedAsOn);
     }
 
     private SavingsAccountTransactionData(final Long id, final SavingsAccountTransactionEnumData transactionType,
-                                          final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
-                                          final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed,
-                                          final AccountTransferData transfer, final Collection<PaymentTypeData> paymentTypeOptions,final LocalDate submittedOnDate) {
+            final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
+            final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed,
+            final AccountTransferData transfer, final Collection<PaymentTypeData> paymentTypeOptions, final LocalDate submittedOnDate,
+            final boolean interestedPostedAsOn) {
         this.id = id;
         this.transactionType = transactionType;
         this.paymentDetailData = paymentDetailData;
@@ -121,6 +122,7 @@ public class SavingsAccountTransactionData {
         this.transfer = transfer;
         this.paymentTypeOptions = paymentTypeOptions;
         this.submittedOnDate = submittedOnDate;
+        this.interestedPostedAsOn = interestedPostedAsOn;
     }
 
     public static SavingsAccountTransactionData withWithDrawalTransactionDetails(
@@ -135,6 +137,6 @@ public class SavingsAccountTransactionData {
                 savingsAccountTransactionData.accountNo, currentDate, savingsAccountTransactionData.currency,
                 savingsAccountTransactionData.runningBalance, savingsAccountTransactionData.runningBalance,
                 savingsAccountTransactionData.reversed, savingsAccountTransactionData.transfer,
-                savingsAccountTransactionData.paymentTypeOptions);
+                savingsAccountTransactionData.paymentTypeOptions, savingsAccountTransactionData.interestedPostedAsOn);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
index 3807d6e..89efe2d 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
@@ -190,9 +190,10 @@ public class FixedDepositAccount extends SavingsAccount {
     public void updateMaturityDateAndAmountBeforeAccountActivation(final MathContext mc, final boolean isPreMatureClosure,
             final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
         List<SavingsAccountTransaction> allTransactions = new ArrayList<>();
+        final boolean postInterestAsOn = false;
         final Money transactionAmountMoney = Money.of(getCurrency(), this.accountTermAndPreClosure.depositAmount());
         final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
-                this.accountSubmittedOrActivationDate(), transactionAmountMoney, new Date(), null); // TODO:
+                this.accountSubmittedOrActivationDate(), transactionAmountMoney, new Date(), null, postInterestAsOn); // TODO:
                                                                                                     // verify
                                                                                                     // if
                                                                                                     // it
@@ -297,9 +298,11 @@ public class FixedDepositAccount extends SavingsAccount {
 
         final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
                 .fromInt(this.interestCalculationDaysInYearType);
-
+        List<LocalDate> postedAsOnTransactionDates= getManualPostingDates();
+        
         final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
-                accountSubmittedOrActivationDate(), maturityDate, postingPeriodType, financialYearBeginningMonth);
+                accountSubmittedOrActivationDate(), maturityDate, postingPeriodType, financialYearBeginningMonth,
+                postedAsOnTransactionDates);
 
         final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
 
@@ -311,11 +314,14 @@ public class FixedDepositAccount extends SavingsAccount {
         boolean isInterestTransfer = false;
         final Money minBalanceForInterestCalculation = Money.of(getCurrency(), minBalanceForInterestCalculation());
         for (final LocalDateInterval periodInterval : postingPeriodIntervals) {
-
+            boolean isUserPosting = false;
+            if (postedAsOnTransactionDates.contains(periodInterval.endDate())) {
+                isUserPosting = true;
+            }
             final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, transactions,
                     this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
                     maturityDate, interestPostTransactions, isInterestTransfer, minBalanceForInterestCalculation,
-                    isSavingsInterestPostingAtCurrentPeriodEnd);
+                    isSavingsInterestPostingAtCurrentPeriodEnd, isUserPosting);
 
             periodStartingBalance = postingPeriod.closingBalance();
 
@@ -490,8 +496,9 @@ public class FixedDepositAccount extends SavingsAccount {
         final LocalDate interestPostingUpToDate = maturityDate();
         final MathContext mc = MathContext.DECIMAL64;
         final boolean isInterestTransfer = false;
+        final boolean postInterestAsOn = false;
         final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
-                isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
+                isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth, postInterestAsOn);
 
         Money interestPostedToDate = Money.zero(this.currency);
 
@@ -511,7 +518,7 @@ public class FixedDepositAccount extends SavingsAccount {
             final SavingsAccountTransaction postingTransaction = findInterestPostingTransactionFor(interestPostingTransactionDate);
             if (postingTransaction == null) {
                 final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
-                        interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
+                        interestPostingTransactionDate, interestEarnedToBePostedForPeriod, postInterestAsOn);
                 this.transactions.add(newPostingTransaction);
                 recalucateDailyBalanceDetails = true;
             } else {
@@ -519,7 +526,7 @@ public class FixedDepositAccount extends SavingsAccount {
                 if (correctionRequired) {
                     postingTransaction.reverse();
                     final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
-                            interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
+                            interestPostingTransactionDate, interestEarnedToBePostedForPeriod, postInterestAsOn);
                     this.transactions.add(newPostingTransaction);
                     recalucateDailyBalanceDetails = true;
                 }
@@ -549,8 +556,9 @@ public class FixedDepositAccount extends SavingsAccount {
         // post remaining interest
         final Money remainigInterestToBePosted = interestOnMaturity.minus(interestPostedToDate);
         if (!remainigInterestToBePosted.isZero()) {
+            final boolean postInterestAsOn = false;
             final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
-                    accountCloseDate, remainigInterestToBePosted);
+                    accountCloseDate, remainigInterestToBePosted, postInterestAsOn);
             this.transactions.add(newPostingTransaction);
             recalucateDailyBalance = true;
         }
@@ -600,18 +608,21 @@ public class FixedDepositAccount extends SavingsAccount {
 
     @Override
     public void postInterest(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
-            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
+            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth,
+            final boolean postAsInterestOn) {
+        final boolean postInterestAsOn=false;
         final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
         super.postInterest(mc, interestPostingUpToDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
-                financialYearBeginningMonth);
+                financialYearBeginningMonth, postInterestAsOn);
     }
 
     @Override
     public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
-            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
+            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth,
+            final boolean postAsInterestOn) {
         final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
         return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
-                financialYearBeginningMonth);
+                financialYearBeginningMonth, postAsInterestOn);
     }
 
     private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/580840c3/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
index 6ff9c99..733079e 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
@@ -331,9 +331,9 @@ public class RecurringDepositAccount extends SavingsAccount {
 
         final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
                 .fromInt(this.interestCalculationDaysInYearType);
-
+        List<LocalDate> PostedAsOnDates =  getManualPostingDates();
         final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(depositStartDate(),
-                maturityDate, postingPeriodType, financialYearBeginningMonth);
+                maturityDate, postingPeriodType, financialYearBeginningMonth, PostedAsOnDates);
 
         final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
 
@@ -345,10 +345,14 @@ public class RecurringDepositAccount extends SavingsAccount {
         boolean isInterestTransfer = false;
         final Money minBalanceForInterestCalculation = Money.of(getCurrency(), minBalanceForInterestCalculation());
         for (final LocalDateInterval periodInterval : postingPeriodIntervals) {
+            boolean isUserPosting = false;
+            if (PostedAsOnDates.contains(periodInterval.endDate())) {
+                isUserPosting = true;
+            }
             final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, transactions,
                     this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
                     maturityDate, interestPostTransactions, isInterestTransfer, minBalanceForInterestCalculation,
-                    isSavingsInterestPostingAtCurrentPeriodEnd);
+                    isSavingsInterestPostingAtCurrentPeriodEnd, isUserPosting);
 
             periodStartingBalance = postingPeriod.closingBalance();
 
@@ -369,9 +373,10 @@ public class RecurringDepositAccount extends SavingsAccount {
         if (generateFutureTransactions) {
             for (RecurringDepositScheduleInstallment installment : depositScheduleInstallments()) {
                 if (installment.isPrincipalNotCompleted(getCurrency())) {
+                    boolean postInterestAsOn = false;
                     final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
                             installment.dueDate(), installment.getDepositAmountOutstanding(getCurrency()), installment.dueDate().toDate(),
-                            null);
+                            null, postInterestAsOn);
                     allTransactions.add(transaction);
                 }
             }
@@ -598,8 +603,9 @@ public class RecurringDepositAccount extends SavingsAccount {
         }
         final MathContext mc = MathContext.DECIMAL64;
         boolean isInterestTransfer = false;
+        boolean postInterestAsOn =false;
         final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate.minusDays(1), isInterestTransfer,
-                isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
+                isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth, postInterestAsOn);
 
         Money interestPostedToDate = Money.zero(this.currency);
 
@@ -617,7 +623,7 @@ public class RecurringDepositAccount extends SavingsAccount {
             final SavingsAccountTransaction postingTransaction = findInterestPostingTransactionFor(interestPostingTransactionDate);
             if (postingTransaction == null) {
                 final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
-                        interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
+                        interestPostingTransactionDate, interestEarnedToBePostedForPeriod, postInterestAsOn);
                 addTransaction(newPostingTransaction);
                 recalucateDailyBalanceDetails = true;
             } else {
@@ -625,7 +631,7 @@ public class RecurringDepositAccount extends SavingsAccount {
                 if (correctionRequired) {
                     postingTransaction.reverse();
                     final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
-                            interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
+                            interestPostingTransactionDate, interestEarnedToBePostedForPeriod, postInterestAsOn);
                     addTransaction(newPostingTransaction);
                     recalucateDailyBalanceDetails = true;
                 }
@@ -656,8 +662,9 @@ public class RecurringDepositAccount extends SavingsAccount {
         // post remaining interest
         final Money remainigInterestToBePosted = interestOnMaturity.minus(interestPostedToDate);
         if (!remainigInterestToBePosted.isZero()) {
+            final boolean postInterestAsOn = false;
             final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
-                    accountCloseDate, remainigInterestToBePosted);
+                    accountCloseDate, remainigInterestToBePosted, postInterestAsOn);
             addTransaction(newPostingTransaction);
             recalucateDailyBalance = true;
         }
@@ -707,18 +714,18 @@ public class RecurringDepositAccount extends SavingsAccount {
 
     @Override
     public void postInterest(final MathContext mc, final LocalDate postingDate, final boolean isInterestTransfer,
-            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
+            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth,final boolean postInterestAson) {
         final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
         super.postInterest(mc, interestPostingUpToDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
-                financialYearBeginningMonth);
+                financialYearBeginningMonth, postInterestAson);
     }
 
     @Override
     public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
-            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
+            final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth,final boolean postAsInterestOn) {
         final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
         return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
-                financialYearBeginningMonth);
+                financialYearBeginningMonth, postAsInterestOn);
     }
 
     private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {