Skip to content

Commit 892833d

Browse files
author
Jose Alberto Hernandez
committed
FINERACT-2181: Any amount payment after reage loan is overpaid
1 parent 63c220e commit 892833d

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4413,3 +4413,59 @@ Feature: LoanReAging
44134413
Then Loan Charges tab has the following data:
44144414
| Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding |
44154415
| Snooze fee | false | Specified due date | 15 May 2024 | Flat | 10.0 | 0.0 | 0.0 | 10.0 |
4416+
4417+
@TestRailId:C4157 @AdvancedPaymentAllocation
4418+
Scenario: Verify Loan in case loan paid-off the status is closed outstanding amount is 0, in case any repayment amount less that paid-off amount the status is active with correct outstanding amount
4419+
When Admin sets the business date to "01 January 2025"
4420+
When Admin creates a client with random data
4421+
And Admin creates a fully customized loan with the following data:
4422+
| 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 |
4423+
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_IR_DAILY_TILL_PRECLOSE_LAST_INSTALLMENT_STRATEGY | 01 January 2025 | 1000.0 | 0 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
4424+
And Admin successfully approves the loan on "01 January 2025" with "1000" amount and expected disbursement date on "01 January 2025"
4425+
When Admin successfully disburse the loan on "01 January 2025" with "1000" EUR transaction amount
4426+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
4427+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4428+
| | | 01 January 2025 | | 1000.0 | | | 0.0 | | 0.0 | 0.0 | | | |
4429+
| 1 | 31 | 01 February 2025 | | 833.33 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4430+
| 2 | 28 | 01 March 2025 | | 666.66 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4431+
| 3 | 31 | 01 April 2025 | | 499.99 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4432+
| 4 | 30 | 01 May 2025 | | 333.32 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4433+
| 5 | 31 | 01 June 2025 | | 166.65 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4434+
| 6 | 30 | 01 July 2025 | | 0.0 | 166.65 | 0.0 | 0.0 | 0.0 | 166.65 | 0.0 | 0.0 | 0.0 | 166.65 |
4435+
Then Loan Repayment schedule has the following data in Total row:
4436+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4437+
| 1000.0 | 0.0 | 0.0 | 0.0 | 1000.0 | 0.0 | 0.0 | 0.0 | 1000.0 |
4438+
Then Loan Transactions tab has the following data:
4439+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
4440+
| 01 January 2025 | Disbursement | 1000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1000.0 | false |
4441+
# --- make early repayment --- #
4442+
When Admin sets the business date to "15 January 2025"
4443+
And Customer makes "AUTOPAY" repayment on "15 January 2025" with 166.65 EUR transaction amount
4444+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
4445+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4446+
| | | 01 January 2025 | | 1000.0 | | | 0.0 | | 0.0 | 0.0 | | | |
4447+
| 1 | 31 | 01 February 2025 | | 833.33 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4448+
| 2 | 28 | 01 March 2025 | | 666.66 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4449+
| 3 | 31 | 01 April 2025 | | 499.99 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4450+
| 4 | 30 | 01 May 2025 | | 333.32 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4451+
| 5 | 31 | 01 June 2025 | | 166.65 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 | 0.0 | 0.0 | 0.0 | 166.67 |
4452+
| 6 | 30 | 01 July 2025 | 15 January 2025 | 0.0 | 166.65 | 0.0 | 0.0 | 0.0 | 166.65 | 166.65 | 166.65 | 0.0 | 0.0 |
4453+
Then Loan Repayment schedule has the following data in Total row:
4454+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4455+
| 1000.0 | 0.0 | 0.0 | 0.0 | 1000.0 | 166.65 | 166.65 | 0.0 | 833.35 |
4456+
Then Loan Transactions tab has the following data:
4457+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
4458+
| 01 January 2025 | Disbursement | 1000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1000.0 | false |
4459+
| 15 January 2025 | Repayment | 166.65 | 166.65 | 0.0 | 0.0 | 0.0 | 833.35 | false |
4460+
# --- re-age loan on 1st installment ---#
4461+
When Admin creates a Loan re-aging transaction by Loan external ID with the following data:
4462+
| frequencyNumber | frequencyType | startDate | numberOfInstallments |
4463+
| 1 | MONTHS | 16 January 2025 | 8 |
4464+
Then Loan Transactions tab has the following data:
4465+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
4466+
| 01 January 2025 | Disbursement | 1000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1000.0 | false |
4467+
| 15 January 2025 | Repayment | 166.65 | 166.65 | 0.0 | 0.0 | 0.0 | 833.35 | false |
4468+
| 15 January 2025 | Re-age | 833.35 | 833.35 | 0.0 | 0.0 | 0.0 | 0.0 | false |
4469+
When Loan Pay-off is made on "15 January 2025"
4470+
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
4471+
Then Loan has 0 outstanding amount

fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reaging/LoanReAgingServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ public CommandProcessingResult reAge(Long loanId, JsonCommand command) {
9696
LoanReAgeParameter reAgeParameter = createReAgeParameter(reAgeTransaction, command);
9797
reAgeTransaction.setLoanReAgeParameter(reAgeParameter);
9898
loanTransactionRepository.saveAndFlush(reAgeTransaction);
99-
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = loanRepaymentScheduleTransactionProcessorFactory
100-
.determineProcessor(loan.transactionProcessingStrategy());
10199
if (reAgeTransaction.getTransactionDate().isBefore(reAgeTransaction.getSubmittedOnDate())
102100
&& !loan.isInterestBearingAndInterestRecalculationEnabled()) {
103101
reprocessLoanTransactionsService.reprocessTransactionsWithPostTransactionChecks(loan, reAgeTransaction.getTransactionDate());
@@ -112,6 +110,9 @@ public CommandProcessingResult reAge(Long loanId, JsonCommand command) {
112110
loanTransactions.add(reAgeTransaction);
113111
reprocessLoanTransactionsService.reprocessParticularTransactions(loan, loanTransactions);
114112
} else {
113+
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = loanRepaymentScheduleTransactionProcessorFactory
114+
.determineProcessor(loan.transactionProcessingStrategy());
115+
115116
loanRepaymentScheduleTransactionProcessor.processLatestTransaction(reAgeTransaction,
116117
new TransactionCtx(loan.getCurrency(), loan.getRepaymentScheduleInstallments(), loan.getActiveCharges(),
117118
new MoneyHolder(loan.getTotalOverpaidAsMoney()), null));

0 commit comments

Comments
 (0)