FINERACT-1825: Fix end of month handling

This commit is contained in:
Adam Saghy
2022-12-05 14:56:40 +01:00
parent a708251c65
commit e5f4cc8199
2 changed files with 115 additions and 125 deletions
@@ -369,26 +369,22 @@ public class AccountingScenarioIntegrationTest {
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec); this.fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
DateFormat currentDateFormat = new SimpleDateFormat("dd");
Calendar todaysDate = Calendar.getInstance(); LocalDate todaysDate = Utils.getLocalDateOfTenant();
todaysDate.add(Calendar.MONTH, -3); todaysDate = todaysDate.minusMonths(3);
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate);
todaysDate.add(Calendar.YEAR, 10); todaysDate = todaysDate.plusYears(10);
final String VALID_TO = dateFormat.format(todaysDate.getTime()); final String VALID_TO = dateFormat.format(todaysDate);
todaysDate = Calendar.getInstance(); todaysDate = Utils.getLocalDateOfTenant();
todaysDate.add(Calendar.MONTH, -1); todaysDate = todaysDate.minusMonths(1);
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate);
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String APPROVED_ON_DATE = dateFormat.format(todaysDate);
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final String ACTIVATION_DATE = dateFormat.format(todaysDate);
Integer currentDate = Integer.valueOf(currentDateFormat.format(todaysDate.getTime())); todaysDate = todaysDate.plusMonths(1).withDayOfMonth(1);
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate);
Integer numberOfDaysLeft = (daysInMonth - currentDate) + 1;
todaysDate.add(Calendar.DATE, numberOfDaysLeft);
final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate.getTime());
final Account assetAccount = this.accountHelper.createAssetAccount(); final Account assetAccount = this.accountHelper.createAssetAccount();
final Account incomeAccount = this.accountHelper.createIncomeAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount();
@@ -451,27 +447,23 @@ public class AccountingScenarioIntegrationTest {
final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account expenseAccount = this.accountHelper.createExpenseAccount();
final Account liabilityAccount = this.accountHelper.createLiabilityAccount(); final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
DateFormat currentDateFormat = new SimpleDateFormat("dd");
Calendar todaysDate = Calendar.getInstance(); LocalDate todaysDate = Utils.getLocalDateOfTenant();
todaysDate.add(Calendar.MONTH, -3); todaysDate = todaysDate.minusMonths(3);
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate);
todaysDate.add(Calendar.YEAR, 10); todaysDate = todaysDate.plusYears(10);
final String VALID_TO = dateFormat.format(todaysDate.getTime()); final String VALID_TO = dateFormat.format(todaysDate);
todaysDate = Calendar.getInstance(); todaysDate = Utils.getLocalDateOfTenant();
todaysDate.add(Calendar.MONTH, -1); todaysDate = todaysDate.minusMonths(1);
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate);
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String APPROVED_ON_DATE = dateFormat.format(todaysDate);
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final String ACTIVATION_DATE = dateFormat.format(todaysDate);
final String EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(todaysDate.getTime()); final String EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(todaysDate);
Integer currentDate = Integer.valueOf(currentDateFormat.format(todaysDate.getTime())); todaysDate = todaysDate.plusMonths(1).withDayOfMonth(1);
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate);
Integer numberOfDaysLeft = (daysInMonth - currentDate) + 1;
todaysDate.add(Calendar.DATE, numberOfDaysLeft);
final String INTEREST_POSTED_DATE = dateFormat.format(todaysDate.getTime());
Integer clientId = ClientHelper.createClient(requestSpec, responseSpec); Integer clientId = ClientHelper.createClient(requestSpec, responseSpec);
ClientHelper.verifyClientCreatedOnServer(requestSpec, responseSpec, clientId); ClientHelper.verifyClientCreatedOnServer(requestSpec, responseSpec, clientId);
@@ -789,6 +789,8 @@ public class ClientSavingsIntegrationTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountWithOverdraft() { public void testSavingsAccountWithOverdraft() {
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build(); final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse); final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
@@ -831,14 +833,13 @@ public class ClientSavingsIntegrationTest {
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); LocalDate todaysDate = Utils.getLocalDateOfTenant();
Calendar todaysDate = Calendar.getInstance(); todaysDate = todaysDate.minusMonths(1);
todaysDate.add(Calendar.MONTH, -1); todaysDate = todaysDate.withDayOfMonth(1);
todaysDate.set(Calendar.DAY_OF_MONTH, 1); final String ACTIVATION_DATE = dateFormat.format(todaysDate);
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final Integer lastDayOfMonth = todaysDate.lengthOfMonth();
final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH); todaysDate = todaysDate.withDayOfMonth(lastDayOfMonth);
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); final String TRANSACTION_DATE = dateFormat.format(todaysDate);
final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
@@ -912,13 +913,14 @@ public class ClientSavingsIntegrationTest {
actualInterestPosted = Float.parseFloat(decimalFormat.format(actualInterestPosted)); actualInterestPosted = Float.parseFloat(decimalFormat.format(actualInterestPosted));
assertEquals(interestPosted, actualInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, actualInterestPosted, "Verifying interest posted");
todaysDate = Calendar.getInstance(); todaysDate = Utils.getLocalDateOfTenant();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate);
String withdrawBalance = "false"; String withdrawBalance = "false";
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper
.closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE); .closeSavingsAccountAndGetBackRequiredField(savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero", assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -964,11 +966,12 @@ public class ClientSavingsIntegrationTest {
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
Calendar todaysDate = Calendar.getInstance();
todaysDate.add(Calendar.MONTH, -1);
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); LocalDate todaysDate = Utils.getLocalDateOfTenant();
todaysDate = todaysDate.minusMonths(1);
final String ACTIVATION_DATE = dateFormat.format(todaysDate);
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
@@ -986,16 +989,16 @@ public class ClientSavingsIntegrationTest {
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(summaryBefore, summary); assertEquals(summaryBefore, summary);
final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH); final Integer lastDayOfMonth = todaysDate.lengthOfMonth();
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); todaysDate = todaysDate.withDayOfMonth(lastDayOfMonth);
final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime()); final String WITHDRAWAL_DATE = dateFormat.format(todaysDate);
Float balance = Float.parseFloat(zeroOpeningBalance); Float balance = Float.parseFloat(zeroOpeningBalance);
// DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM // DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM
// yyyy",Locale.US); // yyyy",Locale.US);
Calendar transactionDate = Calendar.getInstance(); LocalDate transactionDate = Utils.getLocalDateOfTenant();
transactionDate.set(Calendar.DAY_OF_MONTH, 2); transactionDate = transactionDate.withDayOfMonth(2);
String transactionDateValue = dateFormat.format(transactionDate.getTime()); String transactionDateValue = dateFormat.format(transactionDate);
/*** /***
* Perform Deposit transaction on last day of month and verify account balance. * Perform Deposit transaction on last day of month and verify account balance.
@@ -1059,8 +1062,8 @@ public class ClientSavingsIntegrationTest {
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3); transactionDate = transactionDate.withDayOfMonth(3);
transactionDateValue = dateFormat.format(transactionDate.getTime()); transactionDateValue = dateFormat.format(transactionDate);
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue);
accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
@@ -1085,12 +1088,8 @@ public class ClientSavingsIntegrationTest {
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked-------"); LOG.info("-----Post Interest As on Successfully Worked-------");
// DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", transactionDate = transactionDate.withDayOfMonth(22);
// Locale.US); transactionDateValue = dateFormat.format(transactionDate);
Calendar transactionCalendarDateFormat = Calendar.getInstance();
transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0);
transactionDate.set(Calendar.DAY_OF_MONTH, 22);
transactionDateValue = dateFormat.format(transactionDate.getTime());
if (Calendar.DAY_OF_MONTH >= 22) { if (Calendar.DAY_OF_MONTH >= 22) {
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue);
accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
@@ -1115,10 +1114,10 @@ public class ClientSavingsIntegrationTest {
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
DateFormat lastTransactionDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Calendar postedLastDate = Calendar.getInstance(); LocalDate postedLastDate = Utils.getLocalDateOfTenant();
int numberOfDateOfMonth = postedLastDate.getActualMaximum(Calendar.DAY_OF_MONTH); int numberOfDateOfMonth = postedLastDate.lengthOfMonth();
transactionDateValue = lastTransactionDateFormat.format(transactionDate.getTime()); transactionDateValue = dateFormat.format(transactionDate);
if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) { if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) {
@@ -1146,8 +1145,8 @@ public class ClientSavingsIntegrationTest {
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
transactionDate.set(Calendar.DAY_OF_MONTH, 1); transactionDate = transactionDate.withDayOfMonth(1);
transactionDateValue = dateFormat.format(transactionDate.getTime()); transactionDateValue = dateFormat.format(transactionDate);
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue);
accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
@@ -1176,6 +1175,7 @@ public class ClientSavingsIntegrationTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() { public void testSavingsAccountPostInterestOnLastDayWithdrawalWithOverdraft() {
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
/*** /***
@@ -1216,11 +1216,10 @@ public class ClientSavingsIntegrationTest {
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); LocalDate todaysDate = Utils.getLocalDateOfTenant();
Calendar todaysDate = Calendar.getInstance(); todaysDate = todaysDate.minusMonths(1);
todaysDate.add(Calendar.MONTH, -1);
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final String ACTIVATION_DATE = dateFormat.format(todaysDate);
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
@@ -1238,16 +1237,16 @@ public class ClientSavingsIntegrationTest {
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
assertEquals(summaryBefore, summary); assertEquals(summaryBefore, summary);
final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH); final Integer lastDayOfMonth = todaysDate.lengthOfMonth();
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); todaysDate = todaysDate.withDayOfMonth(lastDayOfMonth);
final String WITHDRAWAL_DATE = dateFormat.format(todaysDate.getTime()); final String WITHDRAWAL_DATE = dateFormat.format(todaysDate);
Float balance = Float.parseFloat(zeroOpeningBalance); Float balance = Float.parseFloat(zeroOpeningBalance);
// DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM // DateFormat transactionDateFormat = new SimpleDateFormat("dd MMMM
// yyyy", Locale.US); // yyyy", Locale.US);
Calendar transactionDate = Calendar.getInstance(); LocalDate transactionDate = Utils.getLocalDateOfTenant();
transactionDate.set(Calendar.DAY_OF_MONTH, 2); transactionDate = transactionDate.withDayOfMonth(2);
String transactionDateValue = dateFormat.format(transactionDate.getTime()); String transactionDateValue = dateFormat.format(transactionDate);
/*** /***
* Perform withdraw transaction, verify account balance(account balance will go to negative as no deposits are * Perform withdraw transaction, verify account balance(account balance will go to negative as no deposits are
@@ -1322,8 +1321,8 @@ public class ClientSavingsIntegrationTest {
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
transactionDate.set(Calendar.DAY_OF_MONTH, 3); transactionDate = transactionDate.withDayOfMonth(3);
transactionDateValue = dateFormat.format(transactionDate.getTime()); transactionDateValue = dateFormat.format(transactionDate);
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue);
accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
@@ -1350,10 +1349,9 @@ public class ClientSavingsIntegrationTest {
// DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", // DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy",
// Locale.US); // Locale.US);
Calendar transactionCalendarDateFormat = Calendar.getInstance();
transactionCalendarDateFormat.add(Calendar.DAY_OF_MONTH, 0); transactionDate = transactionDate.withDayOfMonth(22);
transactionDate.set(Calendar.DAY_OF_MONTH, 22); transactionDateValue = dateFormat.format(transactionDate);
transactionDateValue = dateFormat.format(transactionDate.getTime());
if (Calendar.DAY_OF_MONTH >= 22) { if (Calendar.DAY_OF_MONTH >= 22) {
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue);
accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
@@ -1378,10 +1376,9 @@ public class ClientSavingsIntegrationTest {
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
DateFormat lastTransactionDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); LocalDate postedLastDate = Utils.getLocalDateOfTenant();
Calendar postedLastDate = Calendar.getInstance(); int numberOfDateOfMonth = postedLastDate.lengthOfMonth();
int numberOfDateOfMonth = postedLastDate.getActualMaximum(Calendar.DAY_OF_MONTH); transactionDateValue = dateFormat.format(transactionDate);
transactionDateValue = lastTransactionDateFormat.format(transactionDate.getTime());
if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) { if (Calendar.DAY_OF_MONTH == numberOfDateOfMonth) {
@@ -1409,8 +1406,8 @@ public class ClientSavingsIntegrationTest {
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
transactionDate.set(Calendar.DAY_OF_MONTH, 1); transactionDate = transactionDate.withDayOfMonth(1);
transactionDateValue = dateFormat.format(transactionDate.getTime()); transactionDateValue = dateFormat.format(transactionDate);
this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, transactionDateValue);
accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); accountTransactionDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
summary = (HashMap) accountTransactionDetails.get("summary"); summary = (HashMap) accountTransactionDetails.get("summary");
@@ -1433,11 +1430,13 @@ public class ClientSavingsIntegrationTest {
accountDetailsPostInterestPosted = Float.parseFloat(decimalFormat.format(accountDetailsPostInterestPosted)); accountDetailsPostInterestPosted = Float.parseFloat(decimalFormat.format(accountDetailsPostInterestPosted));
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("-----Post Interest As on Successfully Worked----------"); LOG.info("-----Post Interest As on Successfully Worked----------");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testSavingsAccountPostInterestWithOverdraft() { public void testSavingsAccountPostInterestWithOverdraft() {
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build(); final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
@@ -1479,19 +1478,18 @@ public class ClientSavingsIntegrationTest {
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); LocalDate todaysDate = Utils.getLocalDateOfTenant();
Calendar todaysDate = Calendar.getInstance(); todaysDate = todaysDate.minusMonths(1);
todaysDate.add(Calendar.MONTH, -1); todaysDate = todaysDate.withDayOfMonth(1);
todaysDate.set(Calendar.DAY_OF_MONTH, 1); final String ACTIVATION_DATE = dateFormat.format(todaysDate);
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); final Integer lastDayOfMonth = todaysDate.lengthOfMonth();
final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH); todaysDate = todaysDate.withDayOfMonth(lastDayOfMonth);
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth); final String TRANSACTION_DATE = dateFormat.format(todaysDate);
final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
Calendar postedDate = Calendar.getInstance(); LocalDate postedDate = Utils.getLocalDateOfTenant();
postedDate.set(Calendar.DAY_OF_MONTH, 2); postedDate = postedDate.withDayOfMonth(2);
final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime()); final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate);
/*** /***
* Activate the application and verify account status * Activate the application and verify account status
@@ -1577,15 +1575,15 @@ public class ClientSavingsIntegrationTest {
assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted"); assertEquals(interestPosted, accountDetailsPostInterestPosted, "Verifying interest posted");
LOG.info("------Post Interest As On After doing a post interest Successfully worked--------"); LOG.info("------Post Interest As On After doing a post interest Successfully worked--------");
todaysDate = Calendar.getInstance(); todaysDate = Utils.getLocalDateOfTenant();
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); final String CLOSEDON_DATE = dateFormat.format(todaysDate);
Calendar interestPostingDate = Calendar.getInstance(); LocalDate interestPostingDate = LocalDate.of((int) interestPostingTransaction.get(0), (int) interestPostingTransaction.get(1),
Calendar todysDate = Calendar.getInstance();
interestPostingDate.set((int) interestPostingTransaction.get(0), (int) interestPostingTransaction.get(1) - 1,
(int) interestPostingTransaction.get(2)); (int) interestPostingTransaction.get(2));
final String INTEREST_POSTING_DATE = dateFormat.format(interestPostingDate.getTime()); LocalDate todysDate = Utils.getLocalDateOfTenant();
final String TODYS_POSTING_DATE = dateFormat.format(todysDate.getTime());
final String INTEREST_POSTING_DATE = dateFormat.format(interestPostingDate);
final String TODYS_POSTING_DATE = dateFormat.format(todysDate);
String withdrawBalance = "true"; String withdrawBalance = "true";
if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) { if (TODYS_POSTING_DATE.equalsIgnoreCase(INTEREST_POSTING_DATE)) {
@@ -1599,7 +1597,6 @@ public class ClientSavingsIntegrationTest {
CLOSEDON_DATE); CLOSEDON_DATE);
assertEquals("error.msg.postInterest.notDone", savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); assertEquals("error.msg.postInterest.notDone", savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
} }
} }
@Test @Test
@@ -1648,24 +1645,25 @@ public class ClientSavingsIntegrationTest {
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("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(); LocalDate todaysDate = Utils.getLocalDateOfTenant();
postedDate.set(Calendar.DAY_OF_MONTH, 1); todaysDate = todaysDate.minusMonths(1);
todaysDate = todaysDate.withDayOfMonth(1);
final String ACTIVATION_DATE = dateFormat.format(todaysDate);
final Integer lastDayOfMonth = todaysDate.lengthOfMonth();
todaysDate = todaysDate.withDayOfMonth(lastDayOfMonth);
final String TRANSACTION_DATE = dateFormat.format(todaysDate);
final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime()); LocalDate postedDate = Utils.getLocalDateOfTenant();
Calendar postedLastDate = Calendar.getInstance(); postedDate = postedDate.withDayOfMonth(1);
int countOfDate = postedDate.getActualMaximum(Calendar.DAY_OF_MONTH);
final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate);
LocalDate postedLastDate = Utils.getLocalDateOfTenant();
int countOfDate = postedDate.lengthOfMonth();
LOG.info("count Of Date---> {}", countOfDate); LOG.info("count Of Date---> {}", countOfDate);
postedLastDate.set(Calendar.DAY_OF_MONTH, countOfDate); postedLastDate.withDayOfMonth(countOfDate);
final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate.getTime()); final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate);
/*** /***
* Activate the application and verify account status * Activate the application and verify account status