Skip to content

Commit 8610368

Browse files
oleksii-novikov-onixgalovics
authored andcommitted
FINERACT-2181: Improve validation for reschedule fromDate parameter
1 parent 46f218f commit 8610368

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/LoanRescheduleErrorMessage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public enum LoanRescheduleErrorMessage {
2222

2323
LOAN_CHARGED_OFF("Loan: %s reschedule installment is not allowed. Loan Account is Charged-off"), //
2424
LOAN_RESCHEDULE_DATE_NOT_IN_FUTURE("Loan Reschedule From date (%s) for Loan: %s should be in the future."), //
25+
LOAN_RESCHEDULE_FROM_DATE_INSTALLMENT_NOT_FOUND(
26+
"Validation errors: [rescheduleFromDate] Failed data validation due to: repayment.schedule.installment.does.not.exist."), //
2527
LOAN_LOCKED_BY_COB("Loan is locked by the COB job. Loan ID: %s"), //
2628
LOAN_RESCHEDULE_NOT_ALLOWED_FROM_ZERO_TO_NEW_INTEREST_RATE("Failed data validation due to: newInterestRate."), //
2729
LOAN_RESCHEDULE_NOT_ALLOWED_FROM_CURRENT_INTEREST_RATE_TO_ZERO("The parameter `newInterestRate` must be greater than 0."), //

fineract-e2e-tests-runner/src/test/resources/features/LoanReschedule.feature

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,4 +1432,26 @@ Feature: LoanReschedule
14321432
| 3 | 43 | 15 March 2024 | | 45.56 | 14.67 | 0.69 | 0.0 | 0.0 | 15.36 | 0.0 | 0.0 | 0.0 | 15.36 |
14331433
| 4 | 31 | 15 April 2024 | | 30.56 | 15.0 | 0.36 | 0.0 | 0.0 | 15.36 | 0.0 | 0.0 | 0.0 | 15.36 |
14341434
| 5 | 30 | 15 May 2024 | | 15.44 | 15.12 | 0.24 | 0.0 | 0.0 | 15.36 | 0.0 | 0.0 | 0.0 | 15.36 |
1435-
| 6 | 31 | 15 June 2024 | | 0.0 | 15.44 | 0.12 | 0.0 | 0.0 | 15.56 | 0.0 | 0.0 | 0.0 | 15.56 |
1435+
| 6 | 31 | 15 June 2024 | | 0.0 | 15.44 | 0.12 | 0.0 | 0.0 | 15.56 | 0.0 | 0.0 | 0.0 | 15.56 |
1436+
1437+
Scenario: Verify Progressive Loan reschedule with non-existing installment due date results in validation error
1438+
When Admin sets the business date to "01 January 2024"
1439+
When Admin creates a client with random data
1440+
When Admin creates a fully customized loan with the following data:
1441+
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
1442+
| LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL | 01 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
1443+
And Admin successfully approves the loan on "01 January 2024" with "100" amount and expected disbursement date on "01 January 2024"
1444+
And Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount
1445+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
1446+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
1447+
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
1448+
| 1 | 31 | 01 February 2024 | | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
1449+
| 2 | 29 | 01 March 2024 | | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
1450+
| 3 | 31 | 01 April 2024 | | 50.43 | 16.62 | 0.39 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
1451+
| 4 | 30 | 01 May 2024 | | 33.71 | 16.72 | 0.29 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
1452+
| 5 | 31 | 01 June 2024 | | 16.9 | 16.81 | 0.2 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
1453+
| 6 | 30 | 01 July 2024 | | 0.0 | 16.9 | 0.1 | 0.0 | 0.0 | 17.0 | 0.0 | 0.0 | 0.0 | 17.0 |
1454+
When Admin sets the business date to "02 April 2024"
1455+
Then Loan reschedule with the following data results a 400 error and "LOAN_RESCHEDULE_FROM_DATE_INSTALLMENT_NOT_FOUND" error message
1456+
| rescheduleFromDate | submittedOnDate | adjustedDueDate | graceOnPrincipal | graceOnInterest | extraTerms | newInterestRate |
1457+
| 01 August 2024 | 02 April 2024 | | | | 2 | |

fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void validateForCreateAction(JsonCommand jsonCommand, Loan loan) {
9494
}
9595

9696
if (hasExtraTermsChange) {
97-
validateExtraTerms(dataValidatorBuilder, loan);
97+
validateExtraTerms(dataValidatorBuilder, loan, rescheduleFromDate);
9898
} else if (hasAdjustDueDateChange) {
9999
validateAdjustDueDateChange(dataValidatorBuilder, loan, rescheduleFromDate);
100100
} else if (hasInterestRateChange) {
@@ -124,8 +124,10 @@ private void validateInterestRate(DataValidatorBuilder dataValidatorBuilder, Loa
124124
validateForOverdueCharges(dataValidatorBuilder, loan, installment);
125125
}
126126

127-
private void validateExtraTerms(DataValidatorBuilder dataValidatorBuilder, Loan loan) {
127+
private void validateExtraTerms(DataValidatorBuilder dataValidatorBuilder, Loan loan, LocalDate rescheduleFromDate) {
128128
validateLoanIsActive(loan, dataValidatorBuilder);
129+
final LoanRepaymentScheduleInstallment installment = loan.getRelatedRepaymentScheduleInstallment(rescheduleFromDate);
130+
validateReschedulingInstallment(dataValidatorBuilder, installment);
129131
}
130132

131133
private Integer validateExtraTermsParam(FromJsonHelper fromJsonHelper, JsonElement jsonElement,

0 commit comments

Comments
 (0)