|
64 | 64 | import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; |
65 | 65 | import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper; |
66 | 66 | import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker; |
| 67 | +import org.junit.jupiter.api.AfterEach; |
67 | 68 | import org.junit.jupiter.api.Assertions; |
68 | 69 | import org.junit.jupiter.api.BeforeEach; |
69 | 70 | import org.junit.jupiter.api.Test; |
@@ -5904,7 +5905,7 @@ public void testLoanScheduleWithInterestRecalculationAfterLatePayment() { |
5904 | 5905 | DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); |
5905 | 5906 | dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); |
5906 | 5907 | GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "42", true); |
5907 | | - |
| 5908 | + GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", true); |
5908 | 5909 | final String loanDisbursementDate = "28 January 2021"; |
5909 | 5910 | String firstRepayment = "01 March 2021"; |
5910 | 5911 | final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); |
@@ -5952,11 +5953,11 @@ public void testLoanScheduleWithInterestRecalculationAfterLatePayment() { |
5952 | 5953 | addRepaymentValues(expectedvalues, convertStringDateToCalender("03 May 2021"), 0, false, "198.41", "2021.59", "0.0", "0.0"); |
5953 | 5954 | this.loanTransactionHelper.makeRepayment("04 May 2021", 2220.0F, loanID); |
5954 | 5955 |
|
5955 | | - addRepaymentValues(expectedvalues, convertStringDateToCalender("04 May 2021"), 0, false, "0.0", "63.17", "0.0", "0.0"); |
5956 | | - this.loanTransactionHelper.makeRepayment("01 June 2021", 2220.0F, loanID); |
| 5956 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("04 May 2021"), 0, false, "0.0", "61.88", "0.0", "0.0"); |
| 5957 | + this.loanTransactionHelper.makeRepayment("01 June 2021", 61.88F, loanID); |
5957 | 5958 |
|
5958 | | - addRepaymentValues(expectedvalues, convertStringDateToCalender("01 June 2021"), 0, false, "424.28", "1732.55", "0.0", "0.0"); |
5959 | | - addRepaymentValues(expectedvalues, convertStringDateToCalender("01 July 2021"), 0, false, "446.97", "1773.03", "0.0", "0.0"); |
| 5959 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("01 June 2021"), 0, false, "487.45", "1732.55", "0.0", "0.0"); |
| 5960 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("01 July 2021"), 0, false, "459.37", "1760.63", "0.0", "0.0"); |
5960 | 5961 | loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); |
5961 | 5962 | Assertions.assertNotNull(loanSchedule); |
5962 | 5963 | verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); |
@@ -6018,6 +6019,78 @@ public void testInterestForFirstInstallmentWithInterestRecalculation() { |
6018 | 6019 | WorkingDaysHelper.updateWorkingDays(this.requestSpec, this.responseSpec); |
6019 | 6020 | } |
6020 | 6021 |
|
| 6022 | + @Test |
| 6023 | + public void testLoanScheduleWithInterestRecalculationForLateRepaymentOfLateRepaymentInstallments() { |
| 6024 | + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); |
| 6025 | + WorkingDaysHelper.updateWorkingDaysWeekDays(this.requestSpec, this.responseSpec); |
| 6026 | + DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); |
| 6027 | + dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); |
| 6028 | + GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "42", true); |
| 6029 | + GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", true); |
| 6030 | + final String loanDisbursementDate = "06 May 2022"; |
| 6031 | + String firstRepayment = "27 May 2022"; |
| 6032 | + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); |
| 6033 | + ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); |
| 6034 | + String principalAmount = "7800.00"; |
| 6035 | + String rateOfInterest = "8.9"; |
| 6036 | + String numberOfRepayments = "12"; |
| 6037 | + final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails( |
| 6038 | + LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, |
| 6039 | + LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, |
| 6040 | + LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, |
| 6041 | + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, |
| 6042 | + LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12", numberOfRepayments, principalAmount, |
| 6043 | + rateOfInterest); |
| 6044 | + |
| 6045 | + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate, |
| 6046 | + LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment, numberOfRepayments, |
| 6047 | + principalAmount, rateOfInterest); |
| 6048 | + |
| 6049 | + Assertions.assertNotNull(loanID); |
| 6050 | + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); |
| 6051 | + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); |
| 6052 | + |
| 6053 | + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); |
| 6054 | + loanStatusHashMap = this.loanTransactionHelper.approveLoan(loanDisbursementDate, loanID); |
| 6055 | + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); |
| 6056 | + LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); |
| 6057 | + |
| 6058 | + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); |
| 6059 | + String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); |
| 6060 | + loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID, |
| 6061 | + JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); |
| 6062 | + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); |
| 6063 | + |
| 6064 | + ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); |
| 6065 | + Assertions.assertNotNull(loanSchedule); |
| 6066 | + |
| 6067 | + List<Map<String, Object>> expectedvalues = new ArrayList<>(); |
| 6068 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("27 May 2022"), 0, false, "600.72", "479.28", "0.0", "0.0"); |
| 6069 | + this.loanTransactionHelper.makeRepayment("27 May 2022", 1080.0F, loanID); |
| 6070 | + |
| 6071 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("27 June 2022"), 0, false, "426.98", "653.02", "0.0", "0.0"); |
| 6072 | + this.loanTransactionHelper.makeRepayment("27 June 2022", 1080.0F, loanID); |
| 6073 | + |
| 6074 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("27 July 2022"), 0, false, "485.52", "594.48", "0.0", "0.0"); |
| 6075 | + this.loanTransactionHelper.makeRepayment("27 July 2022", 1080.0F, loanID); |
| 6076 | + |
| 6077 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("29 August 2022"), 0, false, "472.96", "607.04", "0.0", "0.0"); |
| 6078 | + this.loanTransactionHelper.makeRepayment("30 August 2022", 1080.0F, loanID); |
| 6079 | + |
| 6080 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("30 August 2022"), 0, false, "0.0", "17.01", "0.0", "0.0"); |
| 6081 | + this.loanTransactionHelper.makeRepayment("01 September 2022", 17.01F, loanID); |
| 6082 | + |
| 6083 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("01 September 2022"), 0, false, "0.0", "34.02", "0.0", "0.0"); |
| 6084 | + this.loanTransactionHelper.makeRepayment("01 September 2022", 34.02F, loanID); |
| 6085 | + addRepaymentValues(expectedvalues, convertStringDateToCalender("27 September 2022"), 0, false, "637.7", "442.3", "0.0", "0.0"); |
| 6086 | + this.loanTransactionHelper.makeRepayment("27 September 2022", 1080.0F, loanID); |
| 6087 | + |
| 6088 | + loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); |
| 6089 | + Assertions.assertNotNull(loanSchedule); |
| 6090 | + verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); |
| 6091 | + WorkingDaysHelper.updateWorkingDays(this.requestSpec, this.responseSpec); |
| 6092 | + } |
| 6093 | + |
6021 | 6094 | private Calendar convertStringDateToCalender(final String stringDate) { |
6022 | 6095 | DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); |
6023 | 6096 | Calendar date = Calendar.getInstance(); |
@@ -6138,4 +6211,11 @@ private Integer getDayOfMonth(Calendar date) { |
6138 | 6211 |
|
6139 | 6212 | return dayOfMonth; |
6140 | 6213 | } |
| 6214 | + |
| 6215 | + @AfterEach |
| 6216 | + public void tearDown() { |
| 6217 | + GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); |
| 6218 | + GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); |
| 6219 | + } |
| 6220 | + |
6141 | 6221 | } |
0 commit comments